/* ========================================================================
   MAGESKO CORE — feuille de style du socle
   Sections : variables, base, auth (login/register/2fa), shell applicatif
   (topbar + sidebar + hamburger), dashboard, cartes, formulaires, responsive
   ======================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --blue:        #3b82f6;
    --blue-dark:   #2563eb;
    --navy:        #0f2748;
    --navy-light:  #1a3a5f;
    --text:        #1f2937;
    --text-soft:   #6b7280;
    --text-mute:   #9ca3af;
    --white:       #ffffff;
    --bg:          #f4f7fb;
    --border:      #e5e7eb;
    --shadow-sm:   0 1px 3px rgba(0,0,0,0.06);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.10);
    --radius:      12px;
    --sidebar-w:   220px;
    --topbar-h:    60px;
}

html, body { height: 100%; }

body {
    font-family: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    font-size: 16px;
}

a { color: inherit; }

/* ===================== AUTHENTIFICATION ================================ */

.auth-page {
    min-height: 100vh;
    display: flex;
    background: var(--white);
}

.auth-container {
    display: flex;
    flex: 1;
    width: 100%;
}

.auth-left {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 44px;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.auth-left::before {
    content: '';
    position: absolute; top: -40%; right: -30%;
    width: 480px; height: 480px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    border-radius: 50%;
}

.auth-logo { position: relative; z-index: 1; margin-bottom: 46px; }
.auth-logo h1 { font-size: 2.8rem; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 8px; }
.auth-logo p  { font-size: 1rem; opacity: 0.92; font-weight: 300; }

.auth-features { display: flex; flex-direction: column; gap: 30px; position: relative; z-index: 1; }
.feature { display: flex; align-items: flex-start; gap: 16px; }
.feature-icon {
    font-size: 1.8rem;
    width: 50px; height: 50px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    flex-shrink: 0;
}
.feature h3 { font-size: 1.02rem; font-weight: 600; margin-bottom: 4px; }
.feature p  { font-size: 0.86rem; opacity: 0.9; font-weight: 300; }

.auth-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}
.auth-box { width: 100%; max-width: 400px; }
.auth-box h2 { font-size: 1.7rem; font-weight: 700; margin-bottom: 8px; }
.auth-box > p { color: var(--text-soft); margin-bottom: 28px; }

.auth-form { display: flex; flex-direction: column; gap: 15px; margin-bottom: 22px; }
.auth-form input {
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font: inherit; font-size: 0.95rem;
    transition: border-color .2s, box-shadow .2s;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.checkbox-label { display: flex; align-items: center; gap: 10px; font-size: 0.92rem; color: var(--text-soft); cursor: pointer; }
.checkbox-label input { width: 18px; height: 18px; accent-color: var(--blue); }

.auth-footer { text-align: center; color: var(--text-soft); font-size: 0.92rem; }
.auth-footer a { color: var(--blue); text-decoration: none; font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

/* ===================== SHELL APPLICATIF ================================ */

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.topbar {
    height: var(--topbar-h);
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky; top: 0; z-index: 200;
    gap: 16px;
}
.topbar-brand { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.3px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; }
.topbar-2fa, .topbar-user { white-space: nowrap; }
.topbar-user { font-weight: 600; }
.topbar-logout {
    background: rgba(255,255,255,0.9);
    color: var(--blue-dark);
    padding: 7px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.82rem;
}
.topbar-logout:hover { background: var(--white); }

/* Hamburger : caché sur desktop, visible sur mobile */
.hamburger { display: none; flex-direction: column; gap: 4px; cursor: pointer; padding: 6px; }
.hamburger span { width: 22px; height: 2px; background: var(--white); border-radius: 2px; transition: .3s; }

.app-body { display: flex; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    flex-shrink: 0;
    padding: 20px 0;
    transition: transform .3s ease;
}
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-heading {
    padding: 0 20px 12px;
    color: #7da8e0;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    color: #b8cbe6;
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: background .2s, color .2s;
}
.nav-item:hover { background: rgba(59,130,246,0.12); color: var(--white); }
.nav-item.is-active {
    background: rgba(59,130,246,0.22);
    color: var(--white);
    border-left-color: var(--blue);
}
.nav-icon { width: 22px; text-align: center; }
.sidebar-sep { height: 1px; background: rgba(255,255,255,0.1); margin: 14px 20px; }

.nav-backdrop { display: none; }

.content { flex: 1; padding: 28px; min-width: 0; }

.page-header { margin-bottom: 22px; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.4px; }
.page-header p  { color: var(--text-soft); font-size: 0.92rem; }

/* ===================== DASHBOARD ====================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    align-items: start;
}

.empty-dashboard {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 60px 30px;
    text-align: center;
    max-width: 460px;
    margin: 40px auto;
}
.empty-dashboard-icon { font-size: 3rem; margin-bottom: 14px; }
.empty-dashboard h2 { font-size: 1.3rem; margin-bottom: 8px; }
.empty-dashboard p  { color: var(--text-soft); margin-bottom: 22px; }

/* ===================== CARTES (fournies par modules) ================== */

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}
.card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 14px; }

.stat-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; }
.stat-label { font-size: 0.72rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--blue-dark); }

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}

/* ===================== FORMULAIRES ==================================== */

.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 7px; font-weight: 600; font-size: 0.92rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font: inherit; font-size: 0.94rem;
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
}
.form-group input:disabled { background: #f5f5f5; cursor: not-allowed; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-group textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.required::after { content: ' *'; color: #dc2626; }

.radio-group { display: flex; gap: 18px; margin-top: 8px; }
.radio-label { display: flex; align-items: center; gap: 7px; cursor: pointer; font-weight: 400; }
.radio-label input { width: auto; }

.form-actions { display: flex; gap: 12px; margin-top: 24px; }

/* ===================== BOUTONS ======================================= */

.btn-primary, .btn-secondary {
    padding: 11px 22px;
    border: none;
    border-radius: 10px;
    font: inherit; font-size: 0.92rem; font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: transform .15s, box-shadow .2s, background .2s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: var(--white);
    box-shadow: 0 3px 10px rgba(59,130,246,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(59,130,246,0.4); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #eef1f5; }

/* ===================== DIVERS ======================================== */

.muted { color: var(--text-soft); font-size: 0.88rem; }

.alert { padding: 13px 16px; border-radius: 10px; font-size: 0.92rem; border-left: 4px solid; }
.alert-danger  { background: #fee2e2; color: #991b1b; border-color: #dc2626; }
.alert-success { background: #dcfce7; color: #15803d; border-color: #22c55e; }
.alert-info    { background: #e0e7ff; color: #3730a3; border-color: #6366f1; }

.table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.table thead th { text-align: left; padding: 11px 12px; font-size: 0.82rem; color: var(--text-soft); border-bottom: 2px solid var(--border); }
.table tbody td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.table tbody tr:hover { background: #fafbfc; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; }
.badge-en_attente { background: #fef3c7; color: #92400e; }
.badge-payee      { background: #dcfce7; color: #15803d; }
.badge-urgente    { background: #fee2e2; color: #991b1b; }

.link-edit   { color: var(--blue); text-decoration: none; font-weight: 500; }
.link-delete { color: #dc2626; background: none; border: none; cursor: pointer; font: inherit; font-size: 0.9rem; }
.link-edit:hover, .link-delete:hover { text-decoration: underline; }

.empty-state { text-align: center; padding: 36px 20px; color: var(--text-soft); }
.empty-state a { color: var(--blue); font-weight: 600; text-decoration: none; }

.donut-legend { font-size: 0.82rem; display: flex; flex-direction: column; gap: 8px; }
.donut-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; }

/* ===================== PAGE MODULES ================================== */

.modules-list { display: flex; flex-direction: column; gap: 12px; }

.module-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px 20px;
}
.module-info { display: flex; align-items: center; gap: 14px; }
.module-icon {
    font-size: 1.5rem;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    border-radius: 10px;
}
.module-name { font-weight: 600; font-size: 0.98rem; }
.module-slug { font-size: 0.78rem; }

/* Interrupteur (toggle switch) */
.switch { position: relative; display: inline-block; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    display: block;
    width: 48px; height: 26px;
    background: #cbd5e1;
    border-radius: 13px;
    transition: background .25s;
    position: relative;
}
.switch-thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    background: var(--white);
    border-radius: 50%;
    transition: transform .25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .switch-track { background: var(--blue); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(22px); }

/* ===================== RESPONSIVE ==================================== */

@media (max-width: 900px) {
    .hamburger { display: flex; }

    .sidebar {
        position: fixed;
        top: var(--topbar-h); left: 0; bottom: 0;
        z-index: 150;
        transform: translateX(-100%);
    }
    /* quand la case hamburger est cochée, on fait glisser la sidebar */
    .nav-toggle:checked ~ .app-body .sidebar { transform: translateX(0); }
    .nav-toggle:checked ~ .app-body .nav-backdrop {
        display: block;
        position: fixed;
        top: var(--topbar-h); left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 140;
    }

    .content { padding: 20px 16px; }

    .auth-left { display: none; }
    .auth-right { padding: 30px 20px; }
}

@media (max-width: 640px) {
    .topbar-2fa { display: none; }
    .auth-form input { font-size: 16px; }
    .form-group input, .form-group select, .form-group textarea { font-size: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column; }
    .form-actions .btn-primary, .form-actions .btn-secondary { width: 100%; }
    .page-header h1 { font-size: 1.35rem; }
}
