/* ==========================================================================
   GeniPay - Design System
   Feuille de style partagée : landing, documentation, portail marchand.
   Palette actuelle (navy + rouge) modernisée, typographie Inter.
   ========================================================================== */

:root {
    /* ----- Marque (rouge) ----- */
    --primary-red: #dc2626;
    --primary-red-dark: #b91c1c;
    --primary-red-light: #ef4444;
    --dark-red: #7f1d1d;
    --light-red: #fee2e2;
    --accent-red: #dc2626;
    --accent-red-light: #f87171;

    --gradient-red: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-red-dark: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%);
    --gradient-red-light: linear-gradient(135deg, #f87171 0%, #ef4444 100%);

    /* ----- Surfaces (thème sombre navy) ----- */
    --dark-color: #0f172a;
    --darker-color: #0a1120;
    --bg: #0b1220;
    --bg-soft: #0f1a30;
    --card-bg: #131f38;
    --surface-2: #1b294a;
    --border: rgba(148, 163, 184, 0.14);
    --border-strong: rgba(148, 163, 184, 0.26);

    /* ----- Texte ----- */
    --text-color: #e6edf7;
    --text: #e6edf7;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --light-color: #f8fafc;
    --gray: #64748b;

    /* ----- États ----- */
    --green: #22c55e;
    --amber: #f59e0b;
    --blue: #3b82f6;

    /* ----- Rayons ----- */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-full: 999px;

    /* ----- Ombres ----- */
    --shadow-sm: 0 1px 2px rgba(2, 6, 23, 0.4);
    --shadow-md: 0 10px 30px rgba(2, 6, 23, 0.45);
    --shadow-lg: 0 24px 60px rgba(2, 6, 23, 0.55);
    --shadow-red: 0 12px 30px rgba(220, 38, 38, 0.35);
    --shadow-red-light: 0 6px 20px rgba(220, 38, 38, 0.45);

    /* ----- Typographie ----- */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;

    /* ----- Espacement ----- */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-8: 3rem;

    --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent-red-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-red-light); }

h1, h2, h3, h4 { color: var(--light-color); font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }

::selection { background: rgba(220, 38, 38, 0.35); color: #fff; }

:focus-visible { outline: 2px solid var(--primary-red-light); outline-offset: 2px; border-radius: 4px; }

/* Scrollbar moderne (thème sombre) */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: content-box; }

.brand span, .brand-text {
    font-weight: 800;
    letter-spacing: -0.02em;
    background: var(--gradient-red-light);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==========================================================================
   Boutons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.3rem;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition);
}
.btn:hover { transform: translateY(-2px); text-decoration: none; }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--gradient-red); color: #fff; box-shadow: var(--shadow-red); }
.btn-primary:hover { color: #fff; box-shadow: 0 16px 36px rgba(220, 38, 38, 0.45); }

.btn-secondary { background: rgba(148, 163, 184, 0.12); color: #e2e8f0; border-color: var(--border); }
.btn-secondary:hover { background: rgba(148, 163, 184, 0.2); color: #f8fafc; }

.btn-danger { background: rgba(220, 38, 38, 0.14); color: #fca5a5; border-color: rgba(220, 38, 38, 0.4); }
.btn-danger:hover { background: rgba(220, 38, 38, 0.24); color: #fecaca; }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: rgba(148, 163, 184, 0.1); color: #f1f5f9; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.82rem; }
.btn-lg { padding: 0.85rem 1.7rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ==========================================================================
   Cartes & sections
   ========================================================================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem 1.7rem;
    margin-bottom: 1.4rem;
    box-shadow: var(--shadow-sm);
}
.card:hover { border-color: var(--border-strong); }
.card h2, .card h3 { color: #f1f5f9; margin-bottom: 0.9rem; }
.card-hover { transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition); }
.card-hover:hover { transform: translateY(-4px); border-color: rgba(220, 38, 38, 0.4); box-shadow: var(--shadow-md); }

.page-title { font-size: 1.75rem; color: #f8fafc; margin-bottom: 0.35rem; }
.page-sub { color: var(--text-muted); margin-bottom: 1.7rem; }

.grid { display: grid; gap: 1.2rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* Statistiques (KPI) */
.stat {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.3rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), border-color var(--transition);
}
.stat::before {
    content: "";
    position: absolute; inset: 0 auto 0 0;
    width: 3px; background: var(--gradient-red);
    opacity: 0; transition: opacity var(--transition);
}
.stat:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.stat:hover::before { opacity: 1; }
.stat .label { color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat .value { font-size: 1.75rem; font-weight: 800; color: #f8fafc; margin-top: 0.35rem; letter-spacing: -0.02em; }
.stat .value span { font-size: 0.95rem; font-weight: 600; color: var(--text-muted); }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.24rem 0.7rem;
    border-radius: var(--r-full);
    font-size: 0.76rem; font-weight: 600; line-height: 1.4;
}
.badge-active, .badge-success { background: rgba(34, 197, 94, 0.14); color: #4ade80; }
.badge-pending { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-failed { background: rgba(220, 38, 38, 0.15); color: #fca5a5; }
.badge-role, .badge-neutral { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; }

/* ==========================================================================
   Formulaires
   ========================================================================== */
.field { margin-bottom: 1.15rem; }
label { display: block; color: #e2e8f0; font-weight: 500; margin-bottom: 0.4rem; font-size: 0.9rem; }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=tel], textarea, select, .form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--darker-color);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: #f1f5f9;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus, .form-control:focus {
    outline: none;
    border-color: var(--primary-red-light);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}
input::placeholder, textarea::placeholder { color: #475569; }
textarea { resize: vertical; min-height: 90px; }
select { cursor: pointer; }

.helptext { color: var(--text-dim); font-size: 0.82rem; margin-top: 0.25rem; }
.errorlist { list-style: none; color: #fca5a5; font-size: 0.82rem; margin-top: 0.35rem; }

/* ==========================================================================
   Tableaux
   ========================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th, table.data td { text-align: left; padding: 0.75rem 0.95rem; border-bottom: 1px solid var(--border); }
table.data thead th {
    color: #cbd5e1; background: rgba(148, 163, 184, 0.05);
    font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em;
}
table.data tbody tr { transition: background var(--transition); }
table.data tbody tr:hover { background: rgba(148, 163, 184, 0.05); }
table.data td { color: #cbd5e1; }
table.data code { color: #f8b4b4; font-family: var(--font-mono); font-size: 0.85em; }

.empty { text-align: center; padding: 2.8rem 1rem; color: var(--text-muted); }

/* ==========================================================================
   Callouts (encarts)
   ========================================================================== */
.callout { border-radius: var(--r-md); padding: 1rem 1.3rem; margin: 1.2rem 0; border-left: 4px solid; font-size: 0.95rem; }
.callout strong { color: #f1f5f9; }
.callout.info { background: rgba(59, 130, 246, 0.09); border-color: var(--blue); }
.callout.warn { background: rgba(220, 38, 38, 0.09); border-color: var(--primary-red); }
.callout.success { background: rgba(34, 197, 94, 0.09); border-color: var(--green); }

/* ==========================================================================
   Code
   ========================================================================== */
code.inline {
    background: rgba(148, 163, 184, 0.15);
    color: #f8b4b4;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.86em;
}
.code-box {
    background: var(--darker-color);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 1rem 1.15rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    color: #e2e8f0;
    white-space: pre;
}

/* ==========================================================================
   Messages (django.contrib.messages)
   ========================================================================== */
.messages { list-style: none; margin-bottom: 1.4rem; }
.messages li { padding: 0.85rem 1.15rem; border-radius: var(--r-md); margin-bottom: 0.6rem; border-left: 4px solid; font-size: 0.92rem; }
.messages li.success { background: rgba(34, 197, 94, 0.09); border-color: var(--green); color: #bbf7d0; }
.messages li.error { background: rgba(220, 38, 38, 0.09); border-color: var(--primary-red); color: #fecaca; }
.messages li.warning { background: rgba(245, 158, 11, 0.09); border-color: var(--amber); color: #fde68a; }
.messages li.info { background: rgba(59, 130, 246, 0.09); border-color: var(--blue); color: #bfdbfe; }

/* ==========================================================================
   Cartes d'authentification (login / register)
   ========================================================================== */
.auth-wrap {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 2rem;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(220, 38, 38, 0.12), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(220, 38, 38, 0.1), transparent 55%),
        var(--bg);
}
.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 2.6rem;
    width: 100%; max-width: 430px;
    box-shadow: var(--shadow-lg);
}
.auth-card .brand { text-align: center; display: block; margin-bottom: 0.4rem; font-size: 1.6rem; }
.auth-card h1 { font-size: 1.5rem; text-align: center; margin-bottom: 1.6rem; }

/* ==========================================================================
   Navigation contextuelle (fil d'ariane + onglets application)
   ========================================================================== */
.breadcrumb {
    display: flex; align-items: center; flex-wrap: wrap; gap: 0.45rem;
    font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.7rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent-red-light); }
.breadcrumb .sep { color: var(--text-dim); }
.breadcrumb .current { color: #e2e8f0; font-weight: 600; }

.app-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem;
}
.app-header h1 { font-size: 1.6rem; display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }

.tabs {
    display: flex; gap: 0.2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.7rem; overflow-x: auto;
}
.tabs a {
    padding: 0.7rem 1.05rem;
    color: var(--text-muted); font-weight: 600; font-size: 0.92rem;
    border-bottom: 2px solid transparent; white-space: nowrap;
    transition: color var(--transition), border-color var(--transition);
}
.tabs a:hover { color: #f1f5f9; text-decoration: none; }
.tabs a.active { color: var(--accent-red-light); border-bottom-color: var(--primary-red); }
.tabs a i { margin-right: 0.4rem; }

/* ==========================================================================
   Utilitaires
   ========================================================================== */
.muted { color: var(--text-muted); }
.text-center { text-align: center; }
.inline-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
