/* ==========================================================================
   FacturIA — Design system
   Palette : registre comptable moderne (navy / papier froid / émeraude)
   Typo    : Fraunces (titres) + Inter (interface) + IBM Plex Mono (montants)
   ========================================================================== */

:root {
    /* Couleurs */
    --ink: #101c2e;
    --ink-soft: #3b4a63;
    --navy-900: #0f1b32;
    --navy-800: #16294d;
    --navy-700: #1f3660;
    --paper: #f4f6f8;
    --paper-raised: #ffffff;
    --border: #dde3ea;
    --border-soft: #eaeef2;
    --emerald: #0e8f6f;
    --emerald-dark: #0b7458;
    --emerald-tint: #e7f5f0;
    --amber: #c87f1a;
    --amber-tint: #fbf0e0;
    --red: #b5432f;
    --red-tint: #fbeae7;

    /* Typo */
    --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

    /* Forme */
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(16, 28, 46, 0.06);
    --shadow-md: 0 4px 16px rgba(16, 28, 46, 0.08);
    --sidebar-width: 248px;
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

img, svg {
    max-width: 100%;
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    color: var(--ink);
    font-weight: 600;
    letter-spacing: -0.01em;
}

a {
    color: var(--navy-700);
}

a:hover {
    color: var(--emerald-dark);
}

.text-muted {
    color: var(--ink-soft) !important;
}

/* Montants, numéros de facture, devises : toujours en monospace, aligné */
.figure, .amount, .invoice-number, td.num, th.num {
    font-family: var(--font-mono);
    letter-spacing: -0.01em;
}

/* ==========================================================================
   Layout applicatif : sidebar fixe + zone de contenu
   ========================================================================== */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--navy-800);
    color: #cfd9ea;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    padding: 24px 16px;
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 24px;
    color: #ffffff;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.25rem;
    text-decoration: none;
}

.sidebar-brand:hover {
    color: #ffffff;
}

.sidebar-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--emerald);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #b7c4da;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.sidebar-link.active {
    background: rgba(14, 143, 111, 0.18);
    color: #ffffff;
    border-left-color: var(--emerald);
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 14px;
    margin-top: 14px;
}

.sidebar-plan {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 8px;
    font-size: 0.82rem;
}

.main-area {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    padding: 32px 40px 60px;
    width: 100%;
    max-width: 1440px;
    flex-grow: 1;
}

.topbar-guest {
    background: var(--navy-800);
}

/* ==========================================================================
   Composants
   ========================================================================== */

.card, .card-stat, .pricing-card {
    background: var(--paper-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat-card {
    background: var(--paper-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    font-weight: 600;
}

.stat-card .stat-value {
    font-family: var(--font-mono);
    font-size: 1.65rem;
    font-weight: 600;
    color: var(--ink);
    margin-top: 4px;
}

.stat-card.positive .stat-value { color: var(--emerald-dark); }
.stat-card.warning .stat-value { color: var(--amber); }

/* Boutons */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 8px 16px;
    transition: all 0.15s ease;
}

.btn-dark {
    background-color: var(--navy-800);
    border-color: var(--navy-800);
}
.btn-dark:hover {
    background-color: var(--navy-900);
    border-color: var(--navy-900);
}

.btn-success, .btn-emerald {
    background-color: var(--emerald);
    border-color: var(--emerald);
    color: #fff;
}
.btn-success:hover, .btn-emerald:hover {
    background-color: var(--emerald-dark);
    border-color: var(--emerald-dark);
    color: #fff;
}

.btn-warning {
    background-color: var(--amber);
    border-color: var(--amber);
    color: #fff;
}
.btn-warning:hover {
    background-color: #a8690f;
    border-color: #a8690f;
    color: #fff;
}

.btn-outline-dark {
    color: var(--navy-800);
    border-color: var(--border);
}
.btn-outline-dark:hover {
    background-color: var(--navy-800);
    border-color: var(--navy-800);
}

/* Formulaires */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: 0.92rem;
    padding: 9px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--emerald);
    box-shadow: 0 0 0 3px var(--emerald-tint);
}
.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ink);
    margin-bottom: 6px;
}

/* Badges de statut */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 5px 10px;
    border-radius: 100px;
}

.badge.text-bg-success { background-color: var(--emerald-tint) !important; color: var(--emerald-dark) !important; }
.badge.text-bg-secondary { background-color: var(--border-soft) !important; color: var(--ink-soft) !important; }
.badge.text-bg-info { background-color: #e4ecfb !important; color: var(--navy-700) !important; }
.badge.text-bg-warning { background-color: var(--amber-tint) !important; color: var(--amber) !important; }
.badge.text-bg-danger { background-color: var(--red-tint) !important; color: var(--red) !important; }

/* Tableaux */
.table-invoice {
    margin-bottom: 0;
}
.table-invoice thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    background: var(--border-soft);
}
.table-invoice td, .table-invoice th {
    vertical-align: middle;
    padding: 13px 16px;
    border-color: var(--border-soft);
}
.table-invoice tbody tr:hover {
    background-color: #fafbfc;
}

/* Cartes tarifs */
.pricing-card {
    padding: 32px;
    transition: transform 0.15s ease;
}
.pricing-card.featured {
    border: 2px solid var(--emerald);
    position: relative;
}

/* Alertes */
.alert {
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.9rem;
}
.alert-warning { background: var(--amber-tint); color: #7a4c10; border-color: #f0d9b0; }
.alert-success { background: var(--emerald-tint); color: var(--emerald-dark); border-color: #bfe6d9; }
.alert-danger { background: var(--red-tint); color: var(--red); border-color: #f0c7bd; }
.alert-info { background: #e4ecfb; color: var(--navy-700); border-color: #cddaf3; }

/* ==========================================================================
   Pages publiques (landing, login, register) — motif "papier réglé"
   ========================================================================== */

.hero {
    padding: 96px 0 88px;
    background:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 39px,
            rgba(255, 255, 255, 0.06) 40px
        ),
        linear-gradient(160deg, var(--navy-900) 0%, var(--navy-800) 60%, var(--navy-700) 100%);
    color: #fff;
    border-radius: 0 0 28px 28px;
}

.hero .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: #8fd6bf;
    font-weight: 700;
    margin-bottom: 14px;
}

.hero h1 {
    color: #fff;
    font-size: 2.75rem;
    line-height: 1.15;
    max-width: 640px;
    margin: 0 auto 20px;
}

.hero p.lead {
    color: #c7d3e6;
    max-width: 560px;
    margin: 0 auto 32px;
    font-size: 1.05rem;
}

.feature-card {
    background: var(--paper-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    height: 100%;
}
.feature-card .feature-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--emerald-tint);
    color: var(--emerald-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 31px,
            rgba(16, 28, 46, 0.035) 32px
        ),
        var(--paper);
    padding: 40px 16px;
}

.auth-card {
    background: var(--paper-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 440px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.2rem;
    margin-bottom: 28px;
}

/* ==========================================================================
   Utilitaires divers
   ========================================================================== */

.divider-label {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink-soft);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 8px 0 18px;
}
.divider-label::before, .divider-label::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--ink-soft);
}
.empty-state svg {
    width: 40px;
    height: 40px;
    color: var(--border);
    margin-bottom: 12px;
}

@media (min-width: 1700px) {
    .main-content {
        max-width: 1600px;
    }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 50;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-area {
        margin-left: 0;
        width: 100%;
    }
    .main-content {
        padding: 72px 16px 40px;
    }
    .stat-card {
        padding: 14px 16px;
    }
    .stat-card .stat-value {
        font-size: 1.35rem;
    }
    .table-invoice td, .table-invoice th {
        padding: 10px 12px;
        font-size: 0.88rem;
    }
}

@media (max-width: 640px) {
    .hero {
        padding: 56px 16px 48px;
        border-radius: 0 0 20px 20px;
    }
    .hero h1 {
        font-size: 1.9rem;
        line-height: 1.2;
    }
    .hero p.lead {
        font-size: 0.95rem;
    }
    .hero .btn {
        display: block;
        width: 100%;
        margin: 8px 0 !important;
    }
    .auth-page {
        padding: 24px 12px;
    }
    .auth-card {
        padding: 28px 22px;
    }
    .pricing-card {
        padding: 24px 20px;
    }
    .card, .stat-card, .feature-card {
        border-radius: 10px;
    }
    .main-content {
        padding: 68px 14px 32px;
    }
    h2 {
        font-size: 1.5rem;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-wrap: wrap;
        gap: 12px;
    }
}
