/* ═══════════════════════════════════════════════════════════════
   Interface RIFFI — CSS thème clair (bleu marine + or)
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Palette Riffi */
    --accent:         #2c5680;    /* Bleu marine clair */
    --accent-hover:   #1e3d5c;    /* Bleu foncé (hover) */
    --accent-light:   #e8eff5;    /* Bleu très clair (backgrounds subtils) */
    --gold:           #c9a961;    /* Or */
    --gold-dark:      #8a6d1a;    /* Or foncé (texte sur or clair) */
    --gold-light:     #fefaf0;    /* Or très clair (pastilles prix) */
    --gold-border:    #e8dbb0;    /* Or clair pour bordures */

    /* Admin (mode violet retiré, on garde tout en bleu Riffi pour cohérence) */
    --admin-accent:   #2c5680;
    --admin-hover:    #1e3d5c;
    --admin-light:    #e8eff5;

    /* Texte */
    --text:           #1f2328;
    --text-secondary: #6b7280;
    --border:         #e5e0ce;    /* Bordure crème */
    --border-light:   #f0ebda;
    --surface:        #ffffff;
    --surface-alt:    #fdfcf8;    /* Crème très clair */
    --bg:             #fdfcf8;    /* Fond crème principal */

    /* États */
    --ok:             #067a4a;
    --ok-bg:          #dcf5e5;
    --err:            #cf222e;
    --err-bg:         #fdf0f0;
    --warn-bg:        #fefaf0;

    --radius:         8px;
    --radius-sm:      6px;
    --shadow:         0 1px 3px rgba(44,86,128,0.04), 0 1px 2px rgba(44,86,128,0.06);
    --shadow-md:      0 4px 12px rgba(44,86,128,0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

/* La section admin partage la palette Riffi (bleu + or) */

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
    background: var(--surface);
    border-bottom: 2px solid var(--gold);
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1200px; margin: 0 auto;
    padding: 12px 24px;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 36px; width: auto; border-radius: 4px; }
.brand-name { font-size: 16px; font-weight: 600; color: var(--accent); }
.topbar-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar-link {
    color: var(--text); text-decoration: none;
    padding: 6px 12px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500;
}
.topbar-link:hover { background: var(--surface-alt); color: var(--accent); }
.topbar-user { font-size: 13px; color: var(--text-secondary); padding: 0 8px; }
.topbar-logout {
    color: var(--err); text-decoration: none;
    padding: 6px 12px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500;
    border: 1px solid transparent;
}
.topbar-logout:hover { border-color: var(--err); background: var(--err-bg); }

/* ─── Container principal ────────────────────────────────────── */
.container {
    max-width: 1200px; margin: 0 auto;
    padding: 24px;
}

/* ─── Page title ─────────────────────────────────────────────── */
.page-title-bar { margin-bottom: 20px; }
.page-title-bar h2 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
.page-sub { margin: 0; font-size: 13px; color: var(--text-secondary); }

/* ─── Card ───────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.card-title {
    margin: 0 0 16px; font-size: 15px; font-weight: 600;
    color: var(--accent);
    padding-bottom: 12px; border-bottom: 1px solid var(--border-light);
}
.info-card {
    background: var(--accent-light);
    border-color: transparent;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ─── Auth (login) ───────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--bg) 100%);
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px 32px;
    max-width: 420px; width: 100%;
    box-shadow: var(--shadow-md);
    text-align: center;
}
.auth-logo { max-width: 120px; height: auto; margin-bottom: 16px; }
.auth-title { margin: 0 0 8px; font-size: 22px; font-weight: 600; color: var(--accent); }
.auth-subtitle { margin: 0 0 24px; color: var(--text-secondary); font-size: 14px; }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.auth-contact {
    margin-top: 24px; padding-top: 20px;
    border-top: 1px solid var(--border-light);
    text-align: left; font-size: 12px; color: var(--text-secondary);
}
.auth-contact-title { font-weight: 600; margin-bottom: 6px; color: var(--text); }
.auth-contact > div { margin: 3px 0; }

/* ─── Inputs & forms ────────────────────────────────────────── */
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=url], input[type=tel], textarea, select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
textarea { resize: vertical; min-height: 60px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.form-grid label small { font-weight: 400; color: var(--text-secondary); }
.form-actions {
    grid-column: 1 / -1;
    display: flex; gap: 10px; align-items: center;
    padding-top: 8px;
}

/* ─── Boutons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13px; font-weight: 500;
    cursor: pointer; text-decoration: none;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-alt); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--surface); }
.btn-danger { color: var(--err); border-color: var(--border); }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); }
.btn-block { width: 100%; padding: 12px; font-size: 14px; }
.btn-sm { padding: 5px 9px; font-size: 12px; }

.inline-form { display: inline; }

/* ─── Alerts / flash ────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid transparent;
}
.alert-ok  { background: var(--ok-bg);  color: var(--ok);  border-color: #a5d6a7; }
.alert-err { background: var(--err-bg); color: var(--err); border-color: #f5c2c2; }

/* ─── Search bar ─────────────────────────────────────────────── */
.search-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    box-shadow: var(--shadow);
}
.search-bar input[type=text] { flex: 1; min-width: 200px; }

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: -8px -4px; padding: 8px 4px; }
.data-table, .products {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table thead th, .products thead th {
    text-align: left;
    padding: 10px 12px;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}
.data-table tbody td, .products tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
}
.data-table tbody tr:hover, .products tbody tr:hover { background: var(--surface-alt); }
.data-table tbody tr:last-child td, .products tbody tr:last-child td { border-bottom: none; }

.code-cell { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; color: var(--text-secondary); }
.price-cell { text-align: right; font-weight: 600; color: var(--accent); white-space: nowrap; }
.unite-cell { color: var(--text-secondary); font-size: 12px; }
.col-code   { width: 130px; }
.col-unite  { width: 90px; }
.col-price  { width: 140px; text-align: right; }
.text-right { text-align: right; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-left: 4px; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.badge-ok  { background: var(--ok-bg);  color: var(--ok); }
.badge-off { background: #f4f4f5;       color: var(--text-secondary); }

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.footnote {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 20px;
}

/* ─── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .container { padding: 16px 12px; }
    .topbar-inner { padding: 10px 16px; }
    .brand-name { font-size: 14px; }
    .topbar-user { display: none; }
    .products thead { display: none; }
    .products tbody tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
    .products tbody td { display: block; padding: 3px 0; border: none; }
    .products .price-cell { text-align: left; font-size: 16px; margin-top: 4px; }
    .products .code-cell::before  { content: "Code : "; color: var(--text-secondary); }
    .products .unite-cell::before { content: "Unité : "; }
    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions .btn { width: 100%; }
}
