/* =====================================
   NAVBAR - Apple-Inspired Design
   ===================================== */

/* Global font size setting - 1rem = 14px for consistency across all pages */
html {
    font-size: 14px;
}

/* Body padding to compensate for fixed navbar */
body {
    padding-top: 60px;
}

/* Backdrop overlay pour fermer les menus en cliquant en dehors */
.navbar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.navbar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

:root {
    /* Apple-inspired color palette */
    --primary: #0271E8;
    --primary-dark: #0056b3;
    --white: #ffffff;
    --gray-50: #f9f9f9;
    --gray-100: #f5f5f7;
    --gray-200: #e5e5e7;
    --gray-300: #d2d2d7;
    --gray-400: #a1a1a6;
    --gray-500: #86868b;
    --gray-700: #515154;
    --gray-800: #1d1d1f;
    --gray-900: #000000;
    
    /* Typography */
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    
    /* Radius */
    --radius-sm: 8px;
}

/* Navbar Container */
.navbar-apple {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    padding: 12px 0;
    font-family: var(--font-family);
    transition: var(--transition-normal);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.navbar-apple .container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

/* Force le header à rester sur une ligne en mobile */
@media (max-width: 991.98px) {
    .navbar-apple .container > .navbar-brand,
    .navbar-apple .container > .navbar-mobile-actions,
    .navbar-apple .container > .navbar-toggler {
        flex-shrink: 0;
    }

    .navbar-apple .navbar-collapse {
        flex-basis: 100%;
        width: 100%;
    }
}

/* Brand */
.navbar-apple .navbar-brand {
    color: var(--gray-800) !important;
    font-weight: var(--font-weight-semibold);
    font-size: 1.25rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
    letter-spacing: -0.01em;
}

.navbar-apple .navbar-brand:hover {
    color: var(--primary) !important;
    transform: translateY(-1px);
}

.navbar-apple .navbar-brand i {
    color: var(--primary);
    font-size: 1.1rem;
}

/* Navigation Links */
.navbar-apple .nav-link {
    color: var(--gray-700) !important;
    font-weight: var(--font-weight-medium);
    font-size: 0.95rem;
    padding: 8px 16px !important;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    position: relative;
}

.navbar-apple .nav-link:hover {
    color: var(--primary) !important;
    background: rgba(0, 122, 255, 0.08);
    transform: translateY(-1px);
}

.navbar-apple .nav-link.active {
    color: var(--primary) !important;
    background: rgba(0, 122, 255, 0.1);
}

.navbar-apple .nav-link i {
    font-size: 0.9rem;
    opacity: 0.8;
    transition: var(--transition-fast);
}

.navbar-apple .nav-link:hover i {
    opacity: 1;
    color: var(--primary);
}

/* Mobile Actions Container */
.navbar-apple .navbar-mobile-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

/* Position à droite en mobile */
@media (max-width: 991.98px) {
    .navbar-apple .navbar-mobile-actions {
        margin-left: auto;
        margin-right: 8px;
    }
}

/* Position à droite en desktop */
@media (min-width: 992px) {
    .navbar-apple .navbar-collapse {
        flex: 1;
        display: flex !important;
    }

    .navbar-apple .navbar-collapse .navbar-nav.me-auto {
        flex: 1;
        justify-content: center;
    }

    .navbar-apple .navbar-collapse .navbar-nav.ms-auto {
        flex: 0;
        display: flex;
        align-items: center;
    }

    /* Cacher la zone mobile-actions en desktop pour utilisateurs connectés */
    .user-authenticated .navbar-apple .navbar-mobile-actions {
        display: none !important;
    }

    /* Afficher la zone mobile-actions en desktop pour utilisateurs non connectés */
    body:not(.user-authenticated) .navbar-apple .navbar-mobile-actions {
        order: 1;
        margin-right: 8px;
        margin-left: 0;
    }
}

/* Always Visible Links - "Mes frises" & "Connexion" */
.navbar-apple .nav-link-always-visible {
    display: inline-flex !important;
}

/* Desktop: "Mes frises" in navbar-collapse (user connected) looks like other nav items */
@media (min-width: 992px) {
    .user-authenticated .navbar-apple .navbar-collapse .nav-link-always-visible:not(.nav-link-login) {
        color: var(--gray-700) !important;
        background: transparent !important;
        font-weight: var(--font-weight-medium) !important;
        font-size: 0.95rem !important;
        padding: 8px 16px !important;
        margin-top: 0 !important;
        border-radius: var(--radius-sm) !important;
        gap: 6px !important;
    }

    .user-authenticated .navbar-apple .navbar-collapse .nav-link-always-visible:not(.nav-link-login):hover {
        background: rgba(0, 122, 255, 0.08) !important;
        color: var(--primary) !important;
        transform: translateY(-1px);
    }

    /* Active state for "Mes frises" (user connected) */
    .user-authenticated .navbar-apple .navbar-collapse .nav-link-always-visible:not(.nav-link-login).active {
        color: var(--primary) !important;
        background: rgba(0, 122, 255, 0.1) !important;
    }

    /* Desktop: "Mes frises" in navbar-mobile-actions (user NOT connected) keeps highlight */
    body:not(.user-authenticated) .navbar-apple .navbar-mobile-actions .nav-link-always-visible:not(.nav-link-login) {
        color: var(--primary) !important;
        background: rgba(0, 122, 255, 0.1) !important;
        font-weight: var(--font-weight-semibold) !important;
        font-size: 0.85rem !important;
        padding: 6px 12px !important;
        white-space: nowrap;
        margin-top: 3px;
        border-radius: var(--radius-sm);
    }

    body:not(.user-authenticated) .navbar-apple .navbar-mobile-actions .nav-link-always-visible:not(.nav-link-login):hover {
        background: rgba(0, 122, 255, 0.15) !important;
    }
}

/* Mobile: Keep original highlight style for "Mes frises" (but not "Connexion" button) */
@media (max-width: 991px) {
    .navbar-apple .nav-link-always-visible:not(.nav-link-login) {
        color: var(--primary) !important;
        background: rgba(0, 122, 255, 0.1);
        font-weight: var(--font-weight-semibold);
        font-size: 0.85rem;
        padding: 6px 12px !important;
        white-space: nowrap;
        margin-top: 3px;
    }

    .navbar-apple .nav-link-always-visible:not(.nav-link-login):hover {
        background: rgba(0, 122, 255, 0.15);
    }
}

/* Style spécifique pour le bouton Connexion */
.navbar-apple .nav-link-login {
    background: linear-gradient(135deg, var(--primary) 0%, #0056b3 100%);
    color: var(--white) !important;
    box-shadow: 0 2px 8px rgba(2, 113, 232, 0.3);
}

.navbar-apple .nav-link-login:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004494 100%);
    box-shadow: 0 4px 12px rgba(2, 113, 232, 0.4);
}

/* Navbar toggler adjustment */
.navbar-apple .navbar-toggler {
    flex-shrink: 0;
}

/* Masquer le lien Connexion du menu (déjà visible dans le header en mobile et desktop) */
.navbar-apple .nav-item-login-desktop {
    display: none !important;
}

/* Masquer "Mes frises" du menu en mobile (déjà visible dans le header) */
@media (max-width: 991.98px) {
    .navbar-apple .nav-item-mes-frises-desktop {
        display: none !important;
    }

    /* Masquer Thèmes, Événements, Périodes en mobile (déjà dans le menu Actions) */
    .navbar-apple .nav-item-actions-desktop-only {
        display: none !important;
    }
}

@media (min-width: 992px) {
    .navbar-apple .navbar-toggler {
        display: none !important;
    }
}

/* Dropdown */
.navbar-apple .dropdown-toggle {
    border: none;
    background: none;
}

.navbar-apple .dropdown-toggle::after {
    border-top-color: var(--gray-600);
    transition: var(--transition-fast);
}

.navbar-apple .dropdown-toggle:hover::after {
    border-top-color: var(--primary);
}

.navbar-apple .dropdown-menu {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 8px;
    margin-top: 8px;
    min-width: 180px;
    z-index: 1000;
}

.navbar-apple .dropdown-item {
    color: var(--gray-700);
    font-weight: var(--font-weight-medium);
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 6px;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-apple .dropdown-item:hover {
    color: var(--primary);
    background: rgba(0, 122, 255, 0.08);
    transform: translateY(-1px);
}

.navbar-apple .dropdown-item i {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Badge */
.navbar-apple .badge {
    background: linear-gradient(135deg, #ff3b30 0%, #d70015 100%) !important;
    color: var(--white);
    font-size: 0.7rem;
    font-weight: var(--font-weight-semibold);
    padding: 3px 6px;
    border-radius: 10px;
    margin-left: 6px;
    box-shadow: 0 2px 4px rgba(255, 59, 48, 0.3);
}

/* Actions Toggle Button (Mobile) */
.navbar-apple .navbar-actions-toggle {
    display: none;
}

@media (max-width: 991.98px) {
    .navbar-apple .navbar-actions-toggle {
        display: flex;
        border: none;
        padding: 6px 10px;
        border-radius: var(--radius-sm);
        background: rgba(0, 122, 255, 0.1);
        color: var(--primary);
        transition: var(--transition-fast);
        height: 32px;
        align-items: center;
        justify-content: center;
        gap: 6px;
        cursor: pointer;
        margin-right: 8px;
        flex-shrink: 0;
    }
}

.navbar-apple .navbar-actions-toggle:hover {
    background: rgba(0, 122, 255, 0.15);
}

.navbar-apple .navbar-actions-toggle:focus {
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    outline: none;
}

.navbar-apple .navbar-actions-toggle i {
    font-size: 0.9rem;
    color: var(--primary);
}

.navbar-apple .navbar-actions-label {
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold);
    color: var(--primary);
    white-space: nowrap;
}

.navbar-apple .navbar-actions-chevron {
    font-size: 0.7rem;
    color: var(--primary);
    transition: transform 0.3s ease;
}

/* Rotation du chevron quand le menu est ouvert */
.navbar-apple .navbar-actions-toggle[aria-expanded="true"] .navbar-actions-chevron {
    transform: rotate(180deg);
}

/* Actions Collapse (Mobile) */
.navbar-apple .navbar-actions-collapse {
    flex-basis: 100%;
    width: 100%;
}

@media (min-width: 992px) {
    .navbar-apple .navbar-actions-collapse {
        display: none !important;
    }
}

@media (max-width: 991.98px) {
    .navbar-apple .navbar-actions-collapse {
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        border-radius: var(--radius-sm);
        padding: 16px;
        margin-top: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        border: 1px solid rgba(0, 0, 0, 0.1);
    }

    .navbar-apple .navbar-actions-collapse .nav-link {
        padding: 7px 13px !important;
        margin: 2px 0;
    }
}

/* Toggler for mobile */
.navbar-apple .navbar-toggler {
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.05);
    transition: var(--transition-fast);
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar-apple .navbar-toggler:hover {
    background: rgba(0, 122, 255, 0.1);
}

.navbar-apple .navbar-toggler:focus {
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.navbar-apple .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='m4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    width: 18px;
    height: 18px;
}

/* Mobile Responsive */
@media (max-width: 991.98px) {
    .navbar-apple .navbar-collapse {
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        border-radius: var(--radius-sm);
        padding: 16px;
        margin-top: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        border: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .navbar-apple .nav-link {
        padding: 7px 13px !important;
        margin: 2px 0;
    }
    
    .navbar-apple .dropdown-menu {
        position: static;
        background: rgba(0, 122, 255, 0.05);
        border: none;
        box-shadow: none;
        margin: 8px 0;
        backdrop-filter: none;
    }
}

/* Scroll effect */
.navbar-apple.scrolled {
    background: rgba(255, 255, 255, 0.98) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Animation on load - removed */

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .navbar-apple .nav-link,
    .navbar-apple .dropdown-item,
    .navbar-apple .navbar-brand {
        transition: none;
    }
}

/* Focus states for accessibility */
.navbar-apple .nav-link:focus,
.navbar-apple .dropdown-item:focus,
.navbar-apple .navbar-brand:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Impersonation indicator */
.navbar-apple .impersonation-exit {
    background: rgba(255, 193, 7, 0.1) !important;
    border: 1px solid rgba(255, 193, 7, 0.3) !important;
    border-radius: var(--radius-sm) !important;
    margin-right: 12px;
    animation: pulse 2s infinite;
}

.navbar-apple .impersonation-exit:hover {
    background: rgba(255, 193, 7, 0.2) !important;
    border-color: rgba(255, 193, 7, 0.5) !important;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(255, 193, 7, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
    }
}