/* ═══════════════════════════════════════════════════════════════════
   Thème StouxASP — inspiré du design de StouxPro
   Variables + composants réutilisables (sidebar, cartes, boutons,
   tableaux, modals, badges KPI).
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --color-primary: #2a4797;
    --color-primary-hover: #223a7c;
    --color-primary-text: #ffffff;
    --color-secondary: #f97316;
    --color-secondary-hover: #ea6a0a;

    --color-bg: #f4f7f9;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;
    --color-text: #111827;
    --color-text-muted: #6b7280;

    --color-sidebar-bg: #ffffff;
    --color-sidebar-active: #2a4797;

    --color-success: #16a34a;
    --color-success-bg: #dcfce7;
    --color-success-text: #166534;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-danger-bg: #fef2f2;

    --radius-sm: .35rem;
    --radius-md: .5rem;
    --radius-lg: .6rem;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
}

/* ── Layout : sidebar + contenu ── */
.stx-shell { display: flex; align-items: flex-start; min-height: 100vh; }

.stx-sidebar {
    width: 220px;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
}

.stx-sidebar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0 1.1rem 1rem;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--color-primary);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: .75rem;
}

.stx-sidebar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.1rem 1rem;
    margin-bottom: .5rem;
}
.stx-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.stx-sidebar-user-name { font-size: .82rem; font-weight: 600; color: var(--color-text); line-height: 1.2; }
.stx-sidebar-user-sub { font-size: .72rem; color: var(--color-text-muted); }

.stx-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .6rem; }
.stx-nav-section {
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--color-text-muted); padding: .9rem .5rem .35rem;
}
.stx-nav a {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem .6rem;
    border-radius: var(--radius-sm);
    color: #374151;
    font-size: .85rem; font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.stx-nav a:hover { background: #f3f4f6; color: var(--color-primary); }
.stx-nav a.active { background: var(--color-primary); color: #fff; }
.stx-nav a svg { width: 16px; height: 16px; flex-shrink: 0; }

.stx-main { flex: 1; min-width: 0; padding: 1.25rem; }

.app-container {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0px 0px 20px 0px rgb(76 87 125 / 2%);
    padding: 1.25rem;
}

/* ── Boutons ── */
.btnvalider, .stx-btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    background-color: var(--color-primary);
    padding: .5rem 1rem; font-size: .9rem; font-weight: 600;
    color: var(--color-primary-text);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: background-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.btnvalider:hover, .stx-btn-primary:hover { background-color: var(--color-primary-hover); }
.btnvalider:disabled, .stx-btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btnannuler, .stx-btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--color-border);
    background: #fff; color: #374151;
    padding: .5rem 1rem; font-size: .9rem; font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btnannuler:hover, .stx-btn-secondary:hover { background: #f3f4f6; }

.stx-btn-danger {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    background-color: var(--color-danger);
    padding: .5rem 1rem; font-size: .9rem; font-weight: 600;
    color: #fff; cursor: pointer;
    transition: background-color 0.15s;
}
.stx-btn-danger:hover { background-color: var(--color-danger-hover); }

/* ── Cartes KPI ── */
.stx-kpi { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: .9rem 1.1rem; }
.stx-kpi-label { font-size: .78rem; color: var(--color-text-muted); font-weight: 600; margin-bottom: .3rem; }
.stx-kpi-value { font-size: 1.5rem; font-weight: 800; color: var(--color-text); }
.stx-badge { display: inline-block; padding: .1rem .45rem; border-radius: 99px; font-size: .68rem; font-weight: 700; }
.stx-badge-up { background: var(--color-success-bg); color: var(--color-success-text); }
.stx-badge-down { background: var(--color-danger-bg); color: var(--color-danger); }

/* ── Tableaux ── */
.stx-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .85rem; }
.stx-table thead th {
    background: var(--color-primary); color: #fff;
    text-align: left; padding: .6rem .75rem;
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    white-space: nowrap;
}
.stx-table thead th:first-child { border-top-left-radius: var(--radius-sm); }
.stx-table thead th:last-child { border-top-right-radius: var(--radius-sm); }
.stx-table tbody td { padding: .55rem .75rem; border-bottom: 1px solid var(--color-border); }
.stx-table tbody tr:nth-child(even) { background: #f9fafb; }
.stx-table tbody tr:hover { background: #eef2ff; }

/* ── Modals ── */
.stx-modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,.45); align-items: center; justify-content: center;
}
.stx-modal-overlay.open, .stx-modal-overlay.stx-open { display: flex; }
.stx-modal-box {
    background: #fff; border-radius: var(--radius-lg);
    width: 420px; max-width: 92vw; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 24px 72px rgba(0,0,0,.35);
}
.stx-modal-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.stx-modal-head h2 { font-size: 1.05rem; font-weight: 700; color: var(--color-text); margin: 0; }
.stx-modal-body { padding: 1.25rem; }
.stx-modal-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: .6rem; }

/* ── Champs de formulaire ── */
.stx-field { display: block; width: 100%; padding: .55rem .7rem; border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg); font-size: .88rem; transition: border-color .15s, box-shadow .15s; }
.stx-field:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(42,71,151,.12); background: #fff; }
.stx-label { display: block; font-size: .82rem; font-weight: 600; color: #374151; margin-bottom: .35rem; }
