/* Authenticated Layout Styles - Sidebar Layout */

.authenticated-layout {
    display: flex;
    min-height: 100vh;
    background: var(--background);
}

/* Sidebar */
.sidebar-auth {
    width: 280px;
    background: linear-gradient(180deg, hsl(18, 80%, 40%) 0%, var(--bs-primary) 100%);
    color: white;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: width 0.3s ease;
}

/* Sidebar fermé par défaut */
.sidebar-auth.collapsed {
    width: 80px;
}

/* Ouvrir le sidebar au survol (desktop uniquement) */
@media (min-width: 768px) {
    .sidebar-auth.collapsed:hover {
        width: 280px;
    }
    
    .sidebar-auth.collapsed:hover .logo-text,
    .sidebar-auth.collapsed:hover .user-info,
    .sidebar-auth.collapsed:hover .nav-section-title,
    .sidebar-auth.collapsed:hover .nav-item-auth span:not(.nav-icon),
    .sidebar-auth.collapsed:hover .progress-sidebar,
    .sidebar-auth.collapsed:hover .logout-button span:not(.nav-icon) {
        display: block;
    }
    
    .sidebar-auth.collapsed:hover .nav-item-auth,
    .sidebar-auth.collapsed:hover .logout-button {
        justify-content: flex-start;
    }
    
    .sidebar-auth.collapsed:hover .sidebar-logo {
        justify-content: flex-start;
    }
    
    /* Réafficher les éléments cachés au survol (mais PAS les sous-menus) */
    .sidebar-auth.collapsed:hover .nav-group-caret {
        display: block;
    }
    
    /* Les sous-menus restent fermés par défaut, même quand le sidebar s'ouvre */
    .sidebar-auth.collapsed:hover .nav-submenu {
        display: block; /* Permet l'affichage mais reste fermé (max-height: 0) */
    }
    
    /* Les sous-menus s'ouvrent uniquement au survol d'un nav-group spécifique */
    .sidebar-auth.collapsed:hover .nav-group:hover .nav-submenu {
        max-height: 500px;
        opacity: 1;
    }
}

.sidebar-auth.collapsed .logo-text,
.sidebar-auth.collapsed .user-info,
.sidebar-auth.collapsed .nav-section-title,
.sidebar-auth.collapsed .nav-item-auth span:not(.nav-icon),
.sidebar-auth.collapsed .progress-sidebar,
.sidebar-auth.collapsed .logout-button span:not(.nav-icon) {
    display: none;
}

.sidebar-auth.collapsed .nav-item-auth,
.sidebar-auth.collapsed .logout-button {
    justify-content: center;
}

.sidebar-auth.collapsed .sidebar-logo {
    justify-content: center;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bs-primary);
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
}

.user-info {
    font-size: 0.875rem;
    opacity: 0.9;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    padding: 0 1.5rem;
    margin-bottom: 0.75rem;
}

.nav-item-auth {
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item-auth:hover {
    background: rgba(255,255,255,0.1);
    border-left-color: white;
    color: white;
}

.nav-item-auth.active {
    background: rgba(255,255,255,0.15);
    border-left-color: white;
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    text-align: center;
}

/* Nav icon accent colors */
.nav-icon-primary {
    color: #fffbeb;
}

.nav-icon-teal {
    color: var(--gscv-teal);
}

.nav-icon-green {
    color: var(--gscv-green);
}

.nav-icon-orange {
    color: hsl(18, 80%, 90%);
}

.nav-icon-gold {
    color: #facc15;
}

.nav-icon-muted {
    color: rgba(255,255,255,0.85);
}

/* Nav groups & submenus (hover to expand) */
.nav-group {
    position: relative;
}

.nav-group-header {
    cursor: default;
}

.nav-group-caret {
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.8;
}

.nav-submenu {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.nav-sub-item {
    padding-left: 2.75rem;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.02);
}

/* Les sous-menus s'ouvrent uniquement au survol d'un nav-group */
.nav-group:hover .nav-submenu {
    max-height: 500px;
    opacity: 1;
}

/* Ouverture au clic (mobile / touch) */
.nav-group.open .nav-submenu {
    max-height: 500px;
    opacity: 1;
}

.nav-group.open .nav-group-caret i {
    transform: rotate(90deg);
    display: inline-block;
    transition: transform 0.2s ease;
}

/* Quand le sidebar est collapsed, les sous-menus sont cachés */
.sidebar-auth.collapsed .nav-submenu {
    display: none;
}

/* Quand le sidebar collapsed s'ouvre au survol, permettre l'affichage des sous-menus mais les garder fermés */
@media (min-width: 768px) {
    .sidebar-auth.collapsed:hover .nav-submenu {
        display: block;
        /* Reste fermé par défaut (max-height: 0, opacity: 0) */
    }
    
    /* Seul le nav-group survolé ouvre son sous-menu */
    .sidebar-auth.collapsed:hover .nav-group:hover .nav-submenu {
        max-height: 500px;
        opacity: 1;
    }
}

/* Logout Section */
.logout-section {
    padding: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

.logout-form {
    margin: 0;
    width: 100%;
}

.logout-button {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: inherit;
    font-family: inherit;
}

.logout-button:hover {
    background: rgba(255,255,255,0.1);
    border-left-color: white;
    color: white;
}

.logout-button:active {
    background: rgba(255,255,255,0.15);
}

.sidebar-auth.collapsed .logout-section {
    border-top: none;
    padding: 0;
}

.sidebar-auth.collapsed .logout-button {
    justify-content: center;
    padding: 0.75rem;
    width: 100%;
}

.sidebar-auth.collapsed .logout-button span:not(.nav-icon) {
    display: none;
}

.sidebar-auth.collapsed .logout-section {
    padding: 0;
}

.progress-sidebar {
    padding: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.progress-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-bar-sidebar {
    height: 8px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill-sidebar {
    height: 100%;
    background: white;
    border-radius: 10px;
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Toggle Button */
.sidebar-toggle {
    position: absolute;
    top: 1.5rem;
    right: -15px;
    width: 30px;
    height: 30px;
    background: white;
    border: 2px solid var(--bs-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bs-primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    z-index: 1001;
}

.sidebar-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.sidebar-auth.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* Main Content */
.main-content-auth {
    margin-left: 280px;
    flex: 1;
    padding: 0rem;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    background: #f8fafc;
}

.main-content-auth.sidebar-collapsed,
.sidebar-auth.collapsed ~ .main-content-auth {
    margin-left: 80px;
}

/* Ajuster le contenu principal au survol du sidebar (desktop uniquement) */
@media (min-width: 768px) {
    .sidebar-auth.collapsed:hover ~ .main-content-auth {
        margin-left: 280px;
    }
}

/* Top bar (notifications + avatar) */
.topbar-auth {
    position: sticky;
    top: 0;
    z-index: 10;
    padding-bottom: 0.5rem;
}

.btn-icon-notification {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: none;
    background: white;
    box-shadow: 0 2px 8px rgba(148, 163, 184, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-icon-notification:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(148, 163, 184, 0.5);
    background: #f8fafc;
}

.notification-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 0 0 2px white;
}

.topbar-user {
    position: relative;
}

.topbar-user-btn {
    border: none;
    background: white;
    border-radius: 999px;
    padding: 4px 10px 4px 4px;
    box-shadow: 0 2px 8px rgba(148, 163, 184, 0.4);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.topbar-user-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(148, 163, 184, 0.5);
    background: #f8fafc;
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: linear-gradient(135deg, hsl(18, 80%, 40%) 0%, var(--bs-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.topbar-username {
    font-size: 0.85rem;
    font-weight: 600;
    color: #0f172a;
}

.topbar-user-role {
    font-size: 0.75rem;
    color: #6b7280;
}

.topbar-user-menu {
    position: absolute;
    top: 110%;
    right: 0;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
    padding: 0.5rem;
    min-width: 180px;
    display: none;
}

.topbar-user:hover .topbar-user-menu {
    display: block;
}

.topbar-user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: #0f172a;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.topbar-user-menu-item i {
    width: 18px;
    text-align: center;
    color: #64748b;
}

.topbar-user-menu-item:hover {
    background: #f8fafc;
}

.topbar-user-menu-item.logout-inline-form {
    margin: 0;
}

.topbar-user-menu-item.logout-inline-form button {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    font-size: 0.875rem;
    color: #b91c1c;
    cursor: pointer;
}

.topbar-user-menu-item.logout-inline-form button i {
    color: #b91c1c;
}

/* Profile Banner */
.profile-banner {
    background: linear-gradient(135deg, hsl(18, 80%, 40%) 0%, var(--bs-primary) 100%);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 2rem;
    box-shadow: 0 4px 12px rgba(234, 119, 61, 0.2);
}

.avatar-large {
    width: 96px;
    height: 96px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bs-primary);
    font-size: 2.5rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.profile-info-banner {
    flex: 1;
}

.profile-name-large {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.profile-id {
    font-size: 0.875rem;
    opacity: 0.9;
}

.progress-box-banner {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.25rem;
    min-width: 200px;
}

.progress-label-banner {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-bar-banner {
    height: 8px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill-banner {
    height: 100%;
    background: white;
    border-radius: 10px;
    transition: width 0.5s ease;
}

.progress-value-banner {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Content Card */
.content-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
}

.card-header-custom {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f1f5f9;
}

.card-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, hsl(18, 80%, 40%) 0%, var(--bs-primary) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.125rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
}

/* Form Elements */
.form-label-auth {
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.input-modern,
.select-modern {
    border: 2px solid #e2e8f0;
    background: white;
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
    transition: all 0.2s;
    width: 100%;
}

.input-modern:focus,
.select-modern:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(234, 119, 61, 0.1);
    outline: none;
}

.input-group-modern {
    display: flex;
}

.input-group-text-modern {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px solid #e2e8f0;
    border-right: none;
    padding: 0.625rem 0.875rem;
    border-radius: 8px 0 0 8px;
    color: #64748b;
}

.input-group-modern .input-modern {
    border-left: none;
    border-radius: 0 8px 8px 0;
}

/* Action Cards */
.action-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.action-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.action-card:hover {
    border-color: var(--bs-primary);
    background: white;
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.08);
}

.action-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, hsl(18, 80%, 40%) 0%, hsl(18, 80%, 54%) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: white;
    font-size: 1.75rem;
    box-shadow: 0 4px 12px rgba(234, 119, 61, 0.3);
}

.action-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.action-description {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 1rem;
}

.btn-action {
    width: 100%;
    background: white;
    border: 2px solid #e2e8f0;
    color: #475569;
    font-weight: 600;
    padding: 0.625rem;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-action:hover {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

/* Table */
.table-modern {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.table-modern table {
    margin: 0;
    width: 100%;
}

.table-modern thead {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.table-modern thead th {
    border: none;
    border-bottom: 2px solid #e2e8f0;
    padding: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-modern tbody td {
    border: none;
    border-bottom: 1px solid #f1f5f9;
    padding: 1rem;
    vertical-align: middle;
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

.table-modern tbody tr:hover {
    background: #f8fafc;
}

.badge-modern {
    background: linear-gradient(135deg, hsl(18, 80%, 40%) 0%, var(--bs-primary) 100%);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.row-number {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #475569 0%, #64748b 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
}

/* Action Bar */
.action-bar {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
    margin-top: 2rem;
}

.btn-modern {
    padding: 0.75rem 1.75rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary-modern {
    background: linear-gradient(135deg, hsl(18, 80%, 40%) 0%, var(--bs-primary) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(234, 119, 61, 0.3);
}

.btn-primary-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(234, 119, 61, 0.4);
    color: white;
}

.btn-secondary-modern {
    background: white;
    color: #475569;
    border: 2px solid #e2e8f0;
}

.btn-secondary-modern:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.btn-add-modern {
    background: linear-gradient(135deg, var(--gscv-teal) 0%, hsl(178, 45%, 45%) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(178, 45%, 40%, 0.3);
}

.btn-add-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(178, 45%, 40%, 0.4);
    color: white;
}

@media (max-width: 768px) {
    .sidebar-auth {
        transform: translateX(-100%);
    }
    
    .sidebar-auth.mobile-open {
        transform: translateX(0);
    }

    /* Sur mobile, quand le menu est ouvert, on force l’affichage complet
       même si la sidebar a la classe .collapsed (width: 80px). */
    .sidebar-auth.mobile-open,
    .sidebar-auth.mobile-open.collapsed {
        width: 280px !important;
    }

    /* Ré-afficher textes/sections quand mobile-open */
    .sidebar-auth.mobile-open .logo-text,
    .sidebar-auth.mobile-open .user-info,
    .sidebar-auth.mobile-open .nav-section-title,
    .sidebar-auth.mobile-open .nav-item-auth span:not(.nav-icon),
    .sidebar-auth.mobile-open .progress-sidebar,
    .sidebar-auth.mobile-open .logout-button span:not(.nav-icon) {
        display: block !important;
    }

    .sidebar-auth.mobile-open .nav-item-auth,
    .sidebar-auth.mobile-open .logout-button,
    .sidebar-auth.mobile-open .sidebar-logo {
        justify-content: flex-start;
    }

    /* Sur mobile: les groupes doivent être cliquables (pas uniquement hover) */
    .sidebar-auth.mobile-open .nav-group-header {
        cursor: pointer;
        user-select: none;
    }

    /* Sur mobile: garantir que les sous-menus peuvent s'afficher */
    .sidebar-auth.mobile-open .nav-submenu {
        display: block;
    }
    
    .main-content-auth {
        margin-left: 0;
    }
    
    .sidebar-auth.collapsed ~ .main-content-auth {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: block !important;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 999;
        width: 48px;
        height: 48px;
        background: linear-gradient(135deg, hsl(18, 80%, 40%) 0%, var(--bs-primary) 100%);
        border: none;
        border-radius: 12px;
        color: white;
        font-size: 1.25rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        cursor: pointer;
    }
    
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .mobile-overlay.active {
        display: block !important;
    }
    
    .profile-banner {
        flex-direction: column;
        text-align: center;
    }
    
    .progress-box-banner {
        width: 100%;
    }
    
    .action-cards-grid {
        grid-template-columns: 1fr;
    }
    
    .action-bar {
        flex-direction: column;
    }
}

.mobile-menu-btn {
    display: none;
}

