/* =============================================================================
   main.css — Variables, reset, typographie, composants de base
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Variables CSS (design tokens)
   --------------------------------------------------------------------------- */
:root {
    /* Couleurs */
    --color-primary:      #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-light:#eff6ff;
    --color-success:      #16a34a;
    --color-success-bg:   #f0fdf4;
    --color-warning:      #d97706;
    --color-warning-bg:   #fffbeb;
    --color-danger:       #dc2626;
    --color-danger-bg:    #fef2f2;
    --color-danger-dark:  #b91c1c;

    /* Surfaces */
    --color-bg:           #f8fafc;
    --color-surface:      #ffffff;
    --color-surface-alt:  #f1f5f9;
    --color-border:       #e2e8f0;
    --color-border-light: #f1f5f9;

    /* Textes */
    --color-text:         #0f172a;
    --color-text-muted:   #64748b;
    --color-text-light:   #94a3b8;

    /* Typographie */
    --font-family:        system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono:          'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    --font-size-sm:       0.8125rem;   /* 13px */
    --font-size-base:     0.9375rem;   /* 15px */
    --font-size-lg:       1.125rem;
    --line-height:        1.6;

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

    /* Rayons */
    --radius-sm: 4px;
    --radius:    6px;
    --radius-lg: 10px;

    /* Ombres */
    --shadow-sm:  0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.1);
    --shadow:     0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.07);
    --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.08);

    /* Transitions */
    --transition: 150ms ease;
}

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

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
}

img, svg { display: block; }
button { cursor: pointer; font-family: inherit; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------------
   Typographie
   --------------------------------------------------------------------------- */
h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text);
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; margin-top: var(--space-6); margin-bottom: var(--space-3); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------------------
   Boutons
   --------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.4375rem 0.875rem;
    font-size: var(--font-size-base);
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
    white-space: nowrap;
    user-select: none;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

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

.btn-ghost {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface-alt); }

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

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

.btn-sm {
    padding: 0.25rem 0.625rem;
    font-size: var(--font-size-sm);
}
.btn-lg {
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
}
.btn-block { width: 100%; }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
}
.btn-icon:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

/* ---------------------------------------------------------------------------
   Formulaires
   --------------------------------------------------------------------------- */
.form-group { margin-bottom: var(--space-4); }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-4);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: var(--space-1);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.4375rem 0.75rem;
    font-size: var(--font-size-base);
    font-family: inherit;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ---------------------------------------------------------------------------
   Alertes
   --------------------------------------------------------------------------- */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-sm);
}
.alert-error {
    background: var(--color-danger-bg);
    color: var(--color-danger-dark);
    border: 1px solid #fecaca;
}
.alert-success {
    background: var(--color-success-bg);
    color: #15803d;
    border: 1px solid #bbf7d0;
}
.alert-warning {
    background: var(--color-warning-bg);
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ---------------------------------------------------------------------------
   Notifications flottantes (toasts)
   --------------------------------------------------------------------------- */
.notifications {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: 380px;
    pointer-events: none;
}

.toast {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    background: var(--color-text);
    color: #fff;
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-in 200ms ease forwards;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}
.toast-success { background: #166534; }
.toast-error   { background: #991b1b; }
.toast-warning { background: #92400e; }

@keyframes toast-in {
    from { transform: translateX(2rem); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

/* ---------------------------------------------------------------------------
   Barre de progression
   --------------------------------------------------------------------------- */
.progress-bar {
    height: 6px;
    background: var(--color-border);
    border-radius: 99px;
    overflow: hidden;
    width: 100%;
}
.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 99px;
    transition: width 300ms ease;
    width: 0%;
}
.progress-fill.indeterminate {
    width: 40%;
    animation: indeterminate 1.2s ease infinite;
}
@keyframes indeterminate {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* ---------------------------------------------------------------------------
   Tableau de données
   --------------------------------------------------------------------------- */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-top: var(--space-4);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}
.data-table th, .data-table td {
    padding: 0.5rem var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
}
.data-table th {
    background: var(--color-surface-alt);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}
.data-table tbody tr:hover { background: var(--color-primary-light); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------------------------------------------------------------------------
   Utilitaires
   --------------------------------------------------------------------------- */
.text-muted   { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-danger  { color: var(--color-danger); }
.text-center  { text-align: center; }
.link         { color: var(--color-primary); cursor: pointer; text-decoration: underline; }
.sr-only      { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

[hidden] { display: none !important; }
