/* ============================================
   Coffre-Assur - Main Stylesheet
   ============================================ */

:root {
    --primary: #0f3460;
    --primary-dark: #0a2647;
    --secondary: #533483;
    --accent: #00d2ff;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --sidebar-width: 260px;
    --header-height: 60px;
    --bg-light: #f4f6f9;
    --text-muted: #6c757d;
}

/* ---- Reset & Base ---- */
* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-light);
    margin: 0;
    color: #333;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--secondary); }

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 60%, var(--secondary) 100%);
    color: #fff;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h2 {
    font-size: 20px;
    margin: 8px 0 2px;
    font-weight: 700;
}

.sidebar-brand small {
    opacity: 0.6;
    font-size: 11px;
}

.sidebar-brand .brand-icon {
    font-size: 36px;
    color: var(--accent);
}

.sidebar-menu {
    list-style: none;
    padding: 10px 0;
    margin: 0;
}

.sidebar-menu li { margin: 2px 0; }

.sidebar-menu .menu-header {
    padding: 12px 20px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.75);
    transition: all 0.2s;
    font-size: 13.5px;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-left-color: var(--accent);
}

.sidebar-menu a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar-menu a i { font-size: 18px; width: 22px; text-align: center; }

.sidebar-menu .badge {
    margin-left: auto;
    font-size: 10px;
}

/* ---- Sidebar collapsible submenus ---- */
.sidebar-menu .submenu-toggle {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.75);
    transition: all 0.2s;
    font-size: 13.5px;
    border-left: 3px solid transparent;
}

.sidebar-menu .submenu-toggle:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-left-color: var(--accent);
}

.sidebar-menu .submenu-toggle.open {
    color: #fff;
    background: rgba(255,255,255,0.05);
}

.sidebar-menu .submenu-toggle .submenu-arrow {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.25s ease;
    opacity: 0.5;
}

.sidebar-menu .submenu-toggle.open .submenu-arrow {
    transform: rotate(90deg);
    opacity: 0.8;
}

.sidebar-menu .submenu-toggle i:first-child {
    font-size: 18px;
    width: 22px;
    text-align: center;
}

.sidebar-menu .submenu-items {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.sidebar-menu .submenu-items.open {
    max-height: 500px;
}

.sidebar-menu .submenu-items li { margin: 0; }

.sidebar-menu .submenu-items a {
    padding: 7px 20px 7px 38px;
    font-size: 12.5px;
    gap: 10px;
    border-left: 3px solid transparent;
}

.sidebar-menu .submenu-items a i {
    font-size: 14px;
    width: 18px;
}

.sidebar-menu .submenu-items a:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
    border-left-color: var(--accent);
}

.sidebar-menu .submenu-items a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: var(--accent);
    font-weight: 600;
}

/* ---- Header ---- */
.main-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 999;
}

.main-header .search-box {
    display: flex;
    align-items: center;
    background: var(--bg-light);
    border-radius: 8px;
    padding: 6px 14px;
    width: 350px;
}

.main-header .search-box input {
    border: none;
    background: none;
    outline: none;
    width: 100%;
    font-size: 13px;
    margin-left: 8px;
}

.main-header .user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.main-header .user-info {
    text-align: right;
    line-height: 1.3;
}

.main-header .user-info .name { font-weight: 600; font-size: 13px; }
.main-header .user-info .role { font-size: 11px; color: var(--text-muted); }

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 24px;
    min-height: calc(100vh - var(--header-height));
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0;
}

.page-header .breadcrumb {
    font-size: 12px;
    margin: 4px 0 0;
    color: var(--text-muted);
}

/* ---- Cards & Widgets ---- */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-card .stat-trend {
    font-size: 12px;
    margin-top: 8px;
}

/* ---- Tables ---- */
.table-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.table-container .table-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.table-container .table-header h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.table { margin: 0; font-size: 13px; }
.table thead th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid #eee;
    padding: 10px 12px;
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 12px;
    vertical-align: middle;
}

.table tbody tr:hover { background: #f8f9ff; }

/* ---- Status Badges ---- */
.badge-actif { background: #d4edda; color: #155724; }
.badge-resilie { background: #f8d7da; color: #721c24; }
.badge-en-attente { background: #fff3cd; color: #856404; }
.badge-suspendu { background: #d6d8db; color: #383d41; }

/* ---- Forms ---- */
.form-section {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}

.form-section h5 {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--bg-light);
}

.form-section h5 i { margin-right: 8px; }

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}

.form-control, .form-select {
    font-size: 13px;
    border-radius: 6px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15,52,96,0.15);
}

/* ---- Action buttons ---- */
.btn-sm { font-size: 12px; padding: 4px 10px; }
.btn-action { padding: 4px 8px; font-size: 13px; line-height: 1; }

.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 4px;
}

/* ---- Flash messages ---- */
.flash-container { margin-bottom: 16px; }

/* ---- Fiche Adhérent Detail ---- */
.fiche-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.fiche-header .fiche-name {
    font-size: 24px;
    font-weight: 700;
}

.fiche-header .fiche-meta {
    opacity: 0.8;
    font-size: 13px;
    margin-top: 4px;
}

.fiche-tabs .nav-link {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
}

.fiche-tabs .nav-link.active {
    color: var(--primary);
    font-weight: 600;
}

/* ---- Login ---- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 400px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    padding: 30px;
    text-align: center;
}

.login-body { padding: 30px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .main-header { left: 0; }
    .main-header .search-box { display: none; }
}
