/* ===== CSS VARIABLES ===== */
:root {
    --sidebar-w: 220px;
    --topbar-h: 52px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-image: url('../images/fond_site/fondsite13.webp');
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    min-height: 100vh;
    color: rgba(255,255,255,0.85);
    display: flex;
}

/* ===== SIDEBAR ===== */
.app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow-y: auto;
    scrollbar-width: none;
    transition: transform 0.3s ease;
}

.app-sidebar::-webkit-scrollbar { display: none; }

.sidebar-logo {
    padding: 20px 16px 10px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo a { display: block; }

.sidebar-logo img {
    width: 100%;
    max-width: 160px;
    height: auto;
    opacity: 0.85;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
    transition: opacity 0.2s;
}

.sidebar-logo img:hover { opacity: 1; }

/* ===== NAV SIDEBAR ===== */
.sidebar-nav {
    flex: 1;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 1.8;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* ===== NAV GROUP (Outils) ===== */
.nav-group {
    display: flex;
    flex-direction: column;
}
.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: rgba(255,255,255,0.8);
    background: none;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}
.nav-group-toggle:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.15);
    color: #fff;
}
.nav-group-label {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}
.nav-group-label svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 1.8;
}
.nav-group-arrow {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0;
    opacity: 0.45;
    transition: transform 0.2s;
}
.nav-group-toggle[aria-expanded="true"] .nav-group-arrow {
    transform: rotate(90deg);
}
.nav-group-items {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 8px;
}
.nav-group-items.open {
    max-height: 500px;
}
.nav-link-sub {
    padding-left: 20px;
    font-size: 0.86rem;
}

/* ===== SIDEBAR BOTTOM ===== */
.sidebar-bottom {
    padding: 12px 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-sidebar-action {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: rgba(255,255,255,0.8);
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-sidebar-action svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.8;
}

.btn-sidebar-action:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.sidebar-username {
    color: rgba(255,255,255,0.55);
    font-size: 0.82rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.sidebar-username svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    stroke-width: 1.8;
}

/* ===== SIDEBAR OVERLAY (mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ===== APP MAIN ===== */
.app-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ===== TOPBAR ===== */
.app-topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-h);
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 15px;
    flex-shrink: 0;
}

/* Hamburger (visible mobile uniquement) */
.sidebar-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

.sidebar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: rgba(255,255,255,0.8);
    border-radius: 2px;
    transition: all 0.3s;
}

/* ===== PAGE BODY ===== */
#page-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 30px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ===== DASHBOARD ===== */
.dashboard-grid {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 25px;
    padding: 20px 0;
}

.module-card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 30px 20px;
    text-align: center;
    text-decoration: none;
    color: rgba(255,255,255,0.85);
    transition: all 0.3s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
}

.module-card:hover {
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
    background: rgba(255, 255, 255, 0.18);
}

.module-icon { font-size: 2.5rem; margin-bottom: 12px; display: flex; align-items: center; justify-content: center; }

.module-icon svg {
    width: 2.6rem;
    height: 2.6rem;
    color: rgba(200, 160, 80, 0.85);
    stroke-width: 1.5;
}
.module-name { font-size: 1.1rem; font-weight: bold; color: #fff; margin-bottom: 6px; }
.module-desc { font-size: 0.8rem; color: rgba(255,255,255,0.5); }

/* ===== DASHBOARD HERO ===== */
.dash-hero {
    position: relative;
    min-height: 45vh;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    margin: 30px 30px 0;
}

.dash-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to bottom, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.25) 50%, rgba(0,0,0,0.62) 100%),
        url('/assets/images/dashboard-hero.jpg') center center / cover no-repeat,
        linear-gradient(135deg, rgba(20,8,5,1) 0%, rgba(30,12,5,1) 50%, rgba(20,8,5,1) 100%);
    border-radius: 16px;
    z-index: 0;
}

.dash-hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px 20px;
    width: 100%;
    max-width: 680px;
}

.dash-hero-title {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
    text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.dash-hero-sub {
    font-size: clamp(0.85rem, 2vw, 1rem);
    color: rgba(255,255,255,0.7);
    margin-bottom: 28px;
    font-style: italic;
}

/* ===== DASHBOARD SEARCH BAR ===== */
.dash-search-bar {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 50px;
    padding: 5px 5px 5px 10px;
    gap: 6px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0,0,0,0.35);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.dash-search-bar:focus-within {
    border-color: rgba(255,255,255,0.45);
    box-shadow: 0 4px 32px rgba(0,0,0,0.5);
}

.search-engine-select {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 30px;
    color: #fff;
    font-size: 0.82rem;
    padding: 7px 10px;
    cursor: pointer;
    outline: none;
    flex-shrink: 0;
    transition: background 0.2s;
}

.search-engine-select:hover  { background: rgba(255,255,255,0.2); }
.search-engine-select option { background: #1a1a2e; color: #fff; }

.search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #fff;
    font-size: 0.95rem;
    padding: 7px 4px;
    min-width: 0;
}

.search-input::placeholder { color: rgba(255,255,255,0.45); }

.search-btn {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 30px;
    color: #fff;
    font-size: 1rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
}

.search-btn:hover  { background: rgba(255,255,255,0.32); }
.search-btn:active { transform: scale(0.94); }
.search-btn svg    { width: 18px; height: 18px; }

/* ===== DASHBOARD MODULES SECTION ===== */
.dash-modules {
    padding: 30px 30px 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.dash-modules-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.38);
    margin-bottom: 20px;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
}

.login-container {
    background: rgba(0, 0, 0, 0.50);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 40px;
    width: 380px;
    text-align: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.login-logo img { width: 200px; margin-bottom: 10px; }

.login-logo p {
    color: rgba(255,255,255,0.5);
    font-style: italic;
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.login-container input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 15px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.login-container input:focus { border-color: rgba(255, 255, 255, 0.5); }
.login-container input::placeholder { color: rgba(255,255,255,0.4); }

.login-container button {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.2s;
}

.login-container button:hover { background: rgba(255,255,255,0.3); }

.error-msg {
    background: rgba(200, 50, 50, 0.3);
    border: 1px solid rgba(200, 50, 50, 0.5);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: #ff9999;
}

/* ===== PASSWORD TOGGLE ===== */
.password-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.password-wrapper input { width: 100%; margin-bottom: 0; }

.password-wrapper .eye-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.5);
    font-size: 1.1rem;
    width: auto;
    padding: 0;
}

.password-wrapper .eye-btn:hover { color: rgba(255,255,255,0.85); }

/* ===== TOOLBAR & BUTTONS ===== */
.toolbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-secondary {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: rgba(255,255,255,0.8);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-secondary:hover { background: rgba(255,255,255,0.18); }

/* ===== LOGOUT BUTTON ===== */
.btn-logout {
    padding: 8px 14px;
    background: rgba(200, 80, 80, 0.15);
    border: 1px solid rgba(200, 80, 80, 0.35);
    border-radius: 8px;
    color: #ff9999;
    text-decoration: none;
    font-size: 0.82rem;
    transition: all 0.2s;
    text-align: center;
}

.btn-logout:hover {
    background: rgba(200, 80, 80, 0.3);
    color: #fff;
}

/* ===== FOOTER ===== */
.site-footer {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 14px 30px;
    flex-shrink: 0;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 1400px;
    margin: 0 auto;
}

.footer-copy { color: rgba(255,255,255,0.45); font-size: 0.8rem; }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }

.footer-links a {
    color: rgba(255,255,255,0.45);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.footer-links a:hover { color: rgba(255,255,255,0.85); }

/* ===== OVERRIDES MODULES DANS NOUVEAU LAYOUT ===== */

/* Avatar : forcer position statique dans la sidebar */
.app-sidebar #avatar-widget {
    position: static !important;
    display: flex !important;
    justify-content: center;
    padding: 10px 0 16px;
    animation: none !important;
}

.app-sidebar #avatar-trigger {
    width: 150px !important;
    height: 150px !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
}

/* Météo : forcer position statique dans la topbar */
.app-topbar .weather-module {
    position: static !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    z-index: auto !important;
    animation: none !important;
}

/* main-content : annuler ancien padding-left de l'avatar */
.main-content {
    padding-left: 30px !important;
    margin-top: 0 !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    /* ----- Sidebar ----- */
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
    }

    /* ----- Topbar mobile ----- */
    .app-topbar {
        padding: 0 12px;
        gap: 10px;
        /* Fix bug iOS Safari : position:sticky + backdrop-filter capture les touch events
           sur les éléments juste en dessous. On désactive le blur et on compense avec
           un fond plus opaque. */
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(0, 0, 0, 0.82);
    }

    .weather-module .wm-location { display: none; }
    .weather-module .wm-sep      { display: none; }

    /* ----- Content ----- */
    .main-content {
        padding: 15px;
    }

    /* ----- Dashboard hero ----- */
    .dash-hero {
        min-height: 200px;
        margin: 15px 15px 0;
        border-radius: 12px;
    }

    .dash-hero-content {
        padding: 24px 16px 20px;
    }

    .dash-hero-sub {
        margin-bottom: 18px;
        font-size: 0.83rem;
    }

    /* ----- Barre de recherche mobile ----- */
    .dash-search-bar {
        border-radius: 14px;
        flex-wrap: wrap;
        padding: 8px;
        gap: 8px;
    }

    .search-engine-select {
        width: 100%;
        border-radius: 8px;
        font-size: 0.85rem;
        padding: 8px 10px;
    }

    .search-input {
        font-size: 1rem;
        padding: 6px 4px;
    }

    .search-btn {
        width: 38px;
        height: 38px;
        border-radius: 8px;
        margin-left: auto;
    }

    /* ----- Dashboard modules ----- */
    .dash-modules {
        padding: 16px 14px 30px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
        padding: 10px 0;
    }

    .module-card {
        padding: 22px 12px 18px;
        border-radius: 14px;
    }

    .module-icon svg {
        width: 2rem;
        height: 2rem;
    }

    .module-name {
        font-size: 0.95rem;
    }

    .module-desc {
        font-size: 0.74rem;
    }

    /* ----- Footer ----- */
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
        gap: 15px;
    }
}

@media (max-width: 420px) {
    .dash-hero-title {
        font-size: 1.5rem;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
