/* ============================================================
   De la suite dans les idées — Gestion
   Feuille de styles principale
   ============================================================ */

/* --- Variables thème sombre (défaut) --- */
:root {
    --rose:          #E8547A;
    --rose-hover:    #d4436a;
    --rose-light:    #FBEAF0;
    --rose-mid:      #F4C0D1;
    --rose-dark:     #99354F;

    --bg:            #1a1a2e;
    --surface:       #16213e;
    --card:          #0f2040;
    --border:        rgba(232, 84, 122, 0.22);
    --border-subtle: rgba(255, 255, 255, 0.06);

    --text:          #e8e8f0;
    --text-muted:    #8888aa;
    --text-faint:    #55556a;

    --success:       #2ea86a;
    --success-bg:    rgba(46, 168, 106, 0.12);
    --warning:       #e0943a;
    --warning-bg:    rgba(224, 148, 58, 0.12);
    --danger:        #e05555;
    --danger-bg:     rgba(224, 85, 85, 0.12);
    --info:          #5588cc;
    --info-bg:       rgba(85, 136, 204, 0.12);

    --font:          'DM Sans', system-ui, sans-serif;
    --radius:        8px;
    --radius-lg:     12px;
    --shadow:        0 2px 12px rgba(0, 0, 0, 0.35);
}

/* --- Thème clair --- */
body.theme-light {
    --bg:            #fff8fa;
    --surface:       #ffffff;
    --card:          #ffffff;
    --border:        #F4C0D1;
    --border-subtle: rgba(0, 0, 0, 0.07);

    --text:          #2a1520;
    --text-muted:    #99354F;
    --text-faint:    #c9a0b0;

    --success-bg:    #edfaf3;
    --warning-bg:    #fff8ee;
    --danger-bg:     #fff0f0;
    --info-bg:       #eef4ff;

    --shadow:        0 2px 12px rgba(153, 53, 79, 0.1);
}

/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--rose); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Page de LOGIN
   ============================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.login-logo {
    font-size: 20px;
    font-weight: 500;
    color: var(--rose);
    letter-spacing: 0.01em;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}

.login-title {
    font-size: 18px;
    font-weight: 500;
    margin: 0 0 24px;
    color: var(--text);
}

.login-footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-faint);
}

/* ============================================================
   Formulaires
   ============================================================ */
.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field textarea,
.field select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: var(--rose);
    box-shadow: 0 0 0 3px rgba(232, 84, 122, 0.15);
}

.field input::placeholder {
    color: var(--text-faint);
}

/* Champ mot de passe avec bouton œil */
.pwd-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.pwd-wrap input[type="password"],
.pwd-wrap input[type="text"] {
    flex: 1;
    padding-right: 42px;
}

.pwd-wrap #btn-eye {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.pwd-wrap #btn-eye:hover,
.pwd-wrap #btn-eye.active { opacity: 1; color: var(--rose); }

/* Champ calculé (lecture seule) */
.field .computed {
    padding: 9px 12px;
    background: rgba(232, 84, 122, 0.08);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--rose);
}

body.theme-light .field .computed {
    background: var(--rose-light);
    color: var(--rose-dark);
}

/* ============================================================
   Boutons
   ============================================================ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: var(--rose);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    text-decoration: none;
}

.btn-primary:hover { background: var(--rose-hover); text-decoration: none; color: #fff; }
.btn-primary:active { transform: scale(0.98); }

.btn-full { width: 100%; justify-content: center; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}

.btn-secondary:hover { background: var(--border-subtle); text-decoration: none; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #c44; }

/* ============================================================
   Alertes / messages
   ============================================================ */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(224,85,85,0.3); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(46,168,106,0.3); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(224,148,58,0.3); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid rgba(85,136,204,0.3); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
    .login-card { padding: 24px 20px; }
}

/* ============================================================
   LAYOUT PRINCIPAL (pages authentifiées)
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-layout:not(.theme-light) .sidebar {
    background: #16213e;
    border-right: 1px solid rgba(232, 84, 122, 0.2);
}
.app-layout.theme-light .sidebar {
    background: #ffffff;
    border-right: 1px solid var(--rose-mid);
}

.sidebar-brand {
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
}

.brand-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--rose);
    line-height: 1.3;
}
.app-layout.theme-light .brand-name { color: var(--rose-dark); }

.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-section {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 12px 18px 5px;
    color: var(--text-faint);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 18px;
    font-size: 13px;
    color: var(--text-muted);
    border-left: 3px solid transparent;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
    background: var(--border-subtle);
    color: var(--text);
    text-decoration: none;
}

.nav-item.active {
    border-left-color: var(--rose);
    color: var(--rose);
    background: rgba(232, 84, 122, 0.1);
}
.app-layout.theme-light .nav-item.active {
    color: var(--rose-dark);
    background: var(--rose-light);
}

.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }

/* Pied de sidebar */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(232, 84, 122, 0.2);
    color: var(--rose);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
}
.app-layout.theme-light .user-avatar {
    background: var(--rose-light);
    color: var(--rose-dark);
}

.user-info { overflow: hidden; }
.user-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 10px;
    color: var(--text-muted);
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.sidebar-action-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    font-family: var(--font);
}
.sidebar-action-btn:hover {
    background: var(--border-subtle);
    color: var(--rose);
    text-decoration: none;
}

/* ===== CONTENU PRINCIPAL ===== */
.main-content {
    flex: 1;
    overflow-x: hidden;
    min-width: 0;
}

.page-container {
    padding: 28px 32px;
    max-width: 1200px;
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--text);
    margin: 0 0 4px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--rose);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.app-layout.theme-light .card-title { color: var(--rose-dark); }

/* ===== GRILLES DE FORMULAIRE ===== */
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

/* ===== KPI ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}

.kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 500;
    color: var(--text);
}

.kpi-value.rose { color: var(--rose); }
.app-layout.theme-light .kpi-value.rose { color: var(--rose-dark); }

.kpi-badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 4px;
    margin-top: 5px;
}
.kpi-badge.up      { background: var(--success-bg); color: var(--success); }
.kpi-badge.neutral { background: rgba(232,84,122,0.1); color: var(--rose); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: relative; }
    .app-shell { flex-direction: column; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid-3 { grid-template-columns: 1fr; }
    .page-container { padding: 16px; }
}
