/**
 * Design System - Base Styles
 * Intranet Lycée du Pays de Bray
 * 
 * Styles de base extraits de base.html.twig
 * Inclut : reset, body, header, navigation, dropdowns, flash messages
 */

/* =============================================
   RESET & BASE
   ============================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-body);
    min-height: 100vh;
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =============================================
   HEADER & NAVIGATION
   ============================================= */
header {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--bg-glass-border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.app-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-main);
    transition: color var(--transition-normal);
}

.nav-links a:hover {
    color: var(--primary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* =============================================
   ICON BUTTONS
   ============================================= */
.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.icon-btn:hover,
.icon-btn.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* =============================================
   DROPDOWNS
   ============================================= */
.dropdown-container {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    /* Stronger shadow for better lift/contrast against background */
    box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.2), 0 10px 20px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-dark);
    /* Stronger border */
    z-index: 1000;
    min-width: 320px;
    overflow: hidden;
    transform-origin: top right;
    animation: scaleIn 0.2s ease-out;
}

.dropdown-menu.show {
    display: block;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* App Grid in Dropdown */
.app-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 1rem;
    gap: 0.75rem;
}

.app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
    text-align: center;
    gap: 0.5rem;
}

.app-item:hover {
    background: var(--primary-light);
    color: var(--primary);
    transform: translateY(-2px);
}

.app-icon-wrapper {
    width: 48px;
    height: 48px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.app-item:hover .app-icon-wrapper {
    box-shadow: var(--shadow-primary);
    color: var(--primary);
}

.app-label {
    font-size: 0.75rem;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    max-width: 100%;
}

/* =============================================
   USER MENU
   ============================================= */
.user-header-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    /* Increased contrast from border-main */
    padding: 0.35rem 1rem 0.35rem 0.35rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-normal);
    color: var(--text-main);
    font-family: inherit;
    box-shadow: var(--shadow-md);
    /* Increased shadow from sm */
}

.user-header-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.user-name-btn {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-main);
}

.user-menu-dropdown {
    min-width: 320px;
    padding: 0;
    overflow: hidden;
}

.user-header-card {
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
}

.user-header-avatar-container {
    margin-bottom: 0.5rem;
    position: relative;
}

.user-header-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--bg-body);
    box-shadow: var(--shadow-md);
}

.user-header-avatar-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 600;
    border: 4px solid var(--bg-body);
    box-shadow: var(--shadow-md);
}

.user-header-greeting {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
}

.user-header-email {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

/* Role Badges */
.user-role-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}

.badge-admin {
    background: #fee2e2;
    color: #dc2626;
}

.badge-teacher {
    background: #dbeafe;
    color: #2563eb;
}

.badge-student {
    background: #dcfce7;
    color: #16a34a;
}

.badge-staff {
    background: #ffedd5;
    color: #ea580c;
}

/* Manage Account Button */
.account-manage-btn {
    margin-top: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    background: transparent;
    border: 1px solid var(--border-dark);
    border-radius: 100px;
    /* Pill shape */
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-normal);
}

.account-manage-btn:hover {
    background: var(--primary-50);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0.5rem 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.5rem;
    text-decoration: none;
    color: var(--text-main);
    transition: background var(--transition-normal);
    font-size: 0.9rem;
    font-weight: 500;
}

.menu-item:hover {
    background: var(--bg-card-hover);
    color: var(--primary);
}

.menu-item i {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.menu-item:hover i {
    color: var(--primary);
}

.logout-item {
    color: var(--error);
}

.logout-item i {
    color: var(--error) !important;
}

.logout-item:hover {
    background: var(--error-light);
    color: var(--error-dark);
}

/* =============================================
   AVATAR
   ============================================= */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    aspect-ratio: 1;
}

.avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
main {
    max-width: 1200px;
    margin: 1.5rem auto 2rem;
    padding: 0 2rem;
}

/* =============================================
   FLASH MESSAGES
   ============================================= */
.flash-message {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.flash-success {
    background: var(--success-light);
    color: var(--success-dark);
    border: 1px solid var(--success);
}

.flash-error {
    background: var(--error-light);
    color: var(--error-dark);
    border: 1px solid var(--error);
}

.flash-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
    border: 1px solid var(--warning);
}

.flash-info {
    background: var(--info-light);
    color: var(--info-dark);
    border: 1px solid var(--info);
}

/* =============================================
   THEME SELECTOR (in user menu)
   ============================================= */
.theme-selector {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border-light);
}

.theme-selector-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    display: block;
}

.theme-options {
    display: flex;
    gap: 0.5rem;
}

.theme-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
}

.theme-btn:hover {
    transform: scale(1.1);
}

.theme-btn.active {
    border-color: var(--text-main);
    box-shadow: 0 0 0 2px var(--bg-card);
}

.theme-btn[data-theme="default"] {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.theme-btn[data-theme="ocean"] {
    background: linear-gradient(135deg, #0891b2, #0ea5e9);
}

.theme-btn[data-theme="forest"] {
    background: linear-gradient(135deg, #059669, #10b981);
}

.theme-btn[data-theme="sunset"] {
    background: linear-gradient(135deg, #ea580c, #f59e0b);
}

.theme-btn[data-theme="dark"] {
    background: linear-gradient(135deg, #1e293b, #334155);
}

/* =============================================
   BOTTOM NAVIGATION (Mobile Only)
   ============================================= */
.bottom-nav {
    display: none;
    /* Hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--bg-glass-border);
    padding: 0.5rem 1rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    /* Safe area for iPhone X+ */
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    /* Fix for mobile scrolling issues */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    transition: all var(--transition-normal);
    padding: 0.5rem;
    border-radius: 8px;
    flex: 1;
}

.bottom-nav-item i {
    width: 24px;
    height: 24px;
    transition: all var(--transition-normal);
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active i {
    transform: translateY(-2px);
}

/* FAB (Floating Action Button) style for the center item if needed */
.bottom-nav-fab {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
    transform: translateY(-20px);
    margin-bottom: -20px;
    transition: all var(--transition-normal);
}

.bottom-nav-item:hover .bottom-nav-fab {
    transform: translateY(-24px) scale(1.05);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.5);
}

button.bottom-nav-item {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    box-shadow: none;
    /* Ensure no shadow on container */
    font-family: inherit;
}

/* =============================================
   RESPONSIVE OVERRIDES
   ============================================= */
@media (max-width: 768px) {

    /* Show Bottom Nav */
    .bottom-nav {
        display: flex;
    }

    /* Adjust Main Content to not be hidden by Bottom Nav */
    body {
        padding-bottom: 80px;
        /* Height of bottom nav + extra space */
    }

    /* FULLSCREEN MENUS (Mobile) */
    .dropdown-container {
        position: static;
        /* Allows menu to be relative to screen/header */
    }

    .dropdown-menu {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        /* Fallback */
        height: 100dvh;
        /* Modern viewport height */
        margin-top: 0;
        border-radius: 0;
        border: none;
        z-index: 2000;
        /* Above everything */
        padding: 4rem 1rem 6rem 1rem;
        /* Top for close btn, Bottom for nav */
        overflow-y: auto;
        background: var(--bg-body);
        /* Solid background */
        transform-origin: bottom center;
        animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .dropdown-menu.show {
        display: flex !important;
        flex-direction: column;
        align-items: center;
    }

    /* Add a "Close" indicator or simplified styling */
    .dropdown-menu::before {
        content: "";
        position: absolute;
        top: 1rem;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 5px;
        background: var(--border-light);
        border-radius: 3px;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .dropdown-menu.closing {
        animation: slideDown 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    @keyframes slideDown {
        from {
            transform: translateY(0);
            opacity: 1;
        }

        to {
            transform: translateY(100%);
            opacity: 0;
        }
    }

    /* Hide Desktop Navigation Elements */
    .nav-links,
    .user-name-btn,
    .theme-selector-label {
        display: none;
    }

    /* Minimal Header (Mobile) - Logo only */
    header {
        padding: 0.5rem 1rem;
    }

    header .nav-actions {
        display: none;
    }

    header .logo {
        font-size: 1rem;
    }

    header .logo i {
        width: 22px !important;
        height: 22px !important;
    }
}

/* =============================================
   DROPDOWN ADJUSTMENTS (Root Level)
   ============================================= */
.dropdown-menu {
    position: fixed;
    /* Default to fixed (handled by JS on desktop, CSS on mobile) */
    z-index: 2000;
}


@media (max-width: 768px) {

    /* Grid Adjustments */
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    main {
        padding: 0 1rem;
        margin-top: 1rem;
    }

    /* Hero Section Adjustments */
    .hero-section {
        padding: 1.5rem;
    }

    .hero-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .hero-stat {
        width: 100%;
    }
}

/* =============================================
   UTILITIES
   ============================================= */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}