/* ============================================================
   FormaRH v7 — Design System
   Polices : Instrument Serif + Geist
   Palette : Ardoise foncé (#141210) + Ambre (#B8721A)
   ============================================================ */

/* === VARIABLES === */
:root {
    --accent:        #B8721A;
    --accent-mid:    #C98830;
    --accent-light:  #F5E9D8;
    --accent-dark:   #8A5512;

    --sidebar-bg:    #141210;
    --sidebar-text:  #A09890;
    --sidebar-hover: #1E1A16;
    --sidebar-active:#B8721A;

    --bg:            #F7F6F3;
    --surface:       #FFFFFF;
    --surface2:      #F0EDE8;
    --border:        #E5E0D8;
    --border-light:  #EDE9E2;

    --text:          #1A1714;
    --text-muted:    #6B6560;
    --text-subtle:   #9B9590;

    --success:       #1A7A4A;
    --success-light: #E8F5EE;
    --success-mid:   #2EA06A;
    --warning:       #8A6200;
    --warning-light: #FEF3CD;
    --danger:        #B91C1C;
    --danger-light:  #FEE2E2;
    --info:          #1E5F8F;
    --info-light:    #DBEAFE;

    --radius:        8px;
    --radius-lg:     12px;
    --radius-xl:     16px;
    --shadow:        0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
    --shadow-lg:     0 4px 12px rgba(0,0,0,.12), 0 12px 40px rgba(0,0,0,.06);
    --transition:    all .18s ease;

    --font-display:  'Instrument Serif', Georgia, serif;
    --font-body:     'Geist', system-ui, sans-serif;

    --sidebar-width: 260px;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
img { max-width: 100%; }

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    height: 100vh;
    position: fixed;
    left: 0; top: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: #2a2520 transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #2a2520; border-radius: 4px; }

.sidebar-header {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid #1E1A16;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.logo-mark {
    width: 34px; height: 34px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.logo-text {
    color: #fff;
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: .01em;
}

.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
}
.nav-section {
    padding: 1rem 1.25rem .3rem;
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #4A4540;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem 1.25rem;
    color: var(--sidebar-text);
    font-size: .85rem;
    font-weight: 450;
    border-radius: 0;
    transition: var(--transition);
    position: relative;
    cursor: pointer;
}
.nav-item:hover {
    background: var(--sidebar-hover);
    color: #D4C8B8;
}
.nav-item.active {
    background: rgba(184,114,26,.12);
    color: var(--accent-mid);
}
.nav-item.active .nav-icon { stroke: var(--accent-mid); }
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}
.nav-icon {
    width: 16px; height: 16px;
    stroke: var(--sidebar-text);
    flex-shrink: 0;
    transition: var(--transition);
}
.nav-item:hover .nav-icon { stroke: #D4C8B8; }
.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: .1rem .4rem;
    border-radius: 20px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #1E1A16;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .65rem;
}
.user-avatar {
    width: 32px; height: 32px;
    background: var(--accent);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name {
    color: #D4C8B8;
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role { color: #4A4540; font-size: .7rem; }
.logout-btn {
    color: #4A4540;
    transition: var(--transition);
    display: flex;
    align-items: center;
}
.logout-btn:hover { color: var(--danger); }

/* === MAIN CONTENT === */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    min-height: 100vh;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.page-title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.65rem;
    font-weight: 400;
    color: var(--text);
    line-height: 1.2;
}
.page-subtitle {
    color: var(--text-muted);
    font-size: .875rem;
    margin-top: .25rem;
}
.page-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

/* === CARDS === */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.card-title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
}
.card-body { padding: 1.25rem; }
.card-footer {
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--border-light);
    background: var(--surface2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.stat-card-accent {
    border-left: 3px solid var(--accent);
}
.stat-card-success {
    border-left: 3px solid var(--success-mid);
}
.stat-card-warning {
    border-left: 3px solid #E6A817;
}
.stat-card-danger {
    border-left: 3px solid var(--danger);
}
.stat-card-info {
    border-left: 3px solid var(--info);
}
.stat-label {
    font-size: .75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .4rem;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--text);
    line-height: 1;
}
.stat-sub {
    font-size: .75rem;
    color: var(--text-subtle);
    margin-top: .35rem;
}

/* === BOUTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    font-size: .85rem;
    font-weight: 500;
    font-family: var(--font-body);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface2); color: var(--text); }
.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.btn-success:hover { background: #145c38; color: #fff; }
.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover { background: #991b1b; color: #fff; }
.btn-warning {
    background: var(--warning);
    color: #fff;
    border-color: var(--warning);
}
.btn-warning:hover { background: #6b4a00; color: #fff; }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm {
    padding: .3rem .7rem;
    font-size: .78rem;
    gap: .3rem;
}
.btn-lg {
    padding: .7rem 1.5rem;
    font-size: .95rem;
}
.btn-icon {
    width: 32px; height: 32px;
    padding: 0;
    justify-content: center;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* === FORMULAIRES === */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: .35rem;
    letter-spacing: .01em;
}
.form-label .required { color: var(--danger); margin-left: .15rem; }
.form-control {
    width: 100%;
    padding: .5rem .75rem;
    font-size: .875rem;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
    line-height: 1.5;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(184,114,26,.1);
}
.form-control:disabled, .form-control[readonly] {
    background: var(--surface2);
    color: var(--text-muted);
    cursor: not-allowed;
}
.form-control.is-invalid { border-color: var(--danger); }
.form-hint {
    font-size: .75rem;
    color: var(--text-subtle);
    margin-top: .25rem;
}
.form-error {
    font-size: .75rem;
    color: var(--danger);
    margin-top: .25rem;
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Checkbox / Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-size: .875rem;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* === TABLES === */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
thead tr {
    border-bottom: 1px solid var(--border);
}
thead th {
    padding: .7rem 1rem;
    text-align: left;
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
    background: var(--surface2);
}
thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius-lg) 0 0; }
tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background .12s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td {
    padding: .75rem 1rem;
    color: var(--text);
    vertical-align: middle;
}
.table-actions {
    display: flex;
    align-items: center;
    gap: .35rem;
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .55rem;
    font-size: .72rem;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-secondary { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-accent  { background: var(--accent-light);  color: var(--accent-dark); }

/* === ALERTES === */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .875rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
    position: relative;
    animation: alertSlideIn .25s ease, alertFadeOut .4s ease 3.6s forwards;
}
@keyframes alertSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes alertFadeOut {
    from { opacity: 1; max-height: 200px; margin-bottom: 1rem; }
    to   { opacity: 0; max-height: 0; margin-bottom: 0; padding: 0; overflow: hidden; }
}
.alert-success { background: var(--success-light); color: var(--success); border-left: 3px solid var(--success-mid); }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border-left: 3px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-left: 3px solid #E6A817; }
.alert-info    { background: var(--info-light);    color: var(--info);    border-left: 3px solid var(--info); }
.alert-close {
    position: absolute; right: .75rem; top: .75rem;
    background: none; border: none; cursor: pointer;
    color: inherit; opacity: .6; font-size: 1rem;
    line-height: 1; padding: 0;
}
.alert-close:hover { opacity: 1; }

/* === PROGRESS === */
.progress {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width .4s ease;
}
.progress-bar.success { background: var(--success-mid); }
.progress-bar.warning { background: #E6A817; }
.progress-bar.danger  { background: var(--danger); }

/* === FILTRES === */
.filters-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.filters-bar .form-control {
    min-width: 150px;
    flex: 1;
}
.filters-bar select.form-control { max-width: 200px; }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-subtle);
}
.empty-state svg {
    width: 48px; height: 48px;
    stroke: var(--border);
    margin-bottom: 1rem;
}
.empty-state h3 {
    font-size: .95rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: .5rem;
}
.empty-state p { font-size: .85rem; }

/* === BREADCRUMB === */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: .75rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--border); }
.breadcrumb-current { color: var(--text); font-weight: 500; }

/* === TABS === */
.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}
.tab-link {
    padding: .6rem 1rem;
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    cursor: pointer;
}
.tab-link:hover { color: var(--text); }
.tab-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* === GRILLE CALENDRIER === */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.calendar-day-header {
    padding: .5rem;
    text-align: center;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    background: var(--surface2);
}
.calendar-day {
    min-height: 100px;
    background: var(--surface);
    padding: .4rem;
    border: 1px solid var(--border-light);
}
.calendar-day.other-month { background: var(--surface2); opacity: .5; }
.calendar-day.today { border-color: var(--accent); background: var(--accent-light); }
.calendar-date {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: .25rem;
}
.calendar-event {
    font-size: .68rem;
    padding: .15rem .3rem;
    border-radius: 3px;
    margin-bottom: 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* === CARDS STATUT (groupes/statut.php) === */
.statut-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.statut-card {
    padding: 1.25rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}
.statut-card:hover { border-color: var(--accent-mid); background: var(--accent-light); }
.statut-card.selected { border-color: var(--accent); background: var(--accent-light); }
.statut-card input[type="radio"] {
    position: absolute;
    opacity: 0;
}
.statut-card-icon { font-size: 1.5rem; margin-bottom: .5rem; }
.statut-card-label { font-weight: 600; font-size: .9rem; }
.statut-card-desc { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }

/* === WORKFLOW FACTURE === */
.workflow-steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 1.5rem;
}
.workflow-step {
    flex: 1;
    text-align: center;
    position: relative;
    padding: .75rem .5rem;
}
.workflow-step::after {
    content: '';
    position: absolute;
    right: 0; top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}
.workflow-step:last-child::after { display: none; }
.step-circle {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--surface2);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto .4rem;
    font-size: .75rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
}
.workflow-step.done .step-circle { background: var(--success-light); border-color: var(--success-mid); color: var(--success); }
.workflow-step.current .step-circle { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.step-label { font-size: .72rem; color: var(--text-muted); font-weight: 500; }
.workflow-step.done .step-label { color: var(--success); }
.workflow-step.current .step-label { color: var(--accent); font-weight: 600; }

/* === DIVERS === */
.divider {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 1.25rem 0;
}
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.font-display { font-family: var(--font-display); font-style: italic; }
.fs-sm { font-size: .8rem; }
.fs-xs { font-size: .72rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-mono { font-family: 'Geist Mono', monospace; }

/* Grid layout */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
.col-span-2 { grid-column: span 2; }

/* Impression */
@media print {
    .sidebar { display: none !important; }
    .main-content { margin-left: 0; padding: 0; }
    .page-header .page-actions { display: none; }
    .btn { display: none; }
    .no-print { display: none !important; }
}

/* === LOGIN PAGE === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--sidebar-bg);
    padding: 2rem;
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 2rem;
}
.login-title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.4rem;
    color: var(--text);
    margin-bottom: .25rem;
}
.login-subtitle {
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}
