/* =========================================================
   Système de gestion des commandes — Feuille de style
   ========================================================= */

:root {
    --bg:          #f4f6fb;
    --surface:     #ffffff;
    --border:      #e2e6ef;
    --text:        #1f2733;
    --text-muted:  #6b7686;
    --primary:     #2f6fed;
    --primary-dark:#1f57c4;
    --secondary:   #eef2fb;
    --success:     #16a34a;
    --danger:      #dc2626;
    --radius:      10px;
    --shadow:      0 1px 3px rgba(20, 30, 60, .08), 0 1px 2px rgba(20, 30, 60, .04);
    --shadow-lg:   0 10px 30px rgba(20, 30, 60, .12);

    /* Couleurs de statut */
    --st-preparation: #d97706;
    --st-shipped:     #2563eb;
    --st-delivered:   #16a34a;
    --st-cancelled:   #dc2626;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; text-transform: uppercase; letter-spacing: .04em;
     color: var(--text-muted); margin: 1.5rem 0 .75rem; }

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }

/* ---------- Barre supérieure ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
    max-width: 1100px; margin: 0 auto; padding: .75rem 1.25rem;
    display: flex; align-items: center; gap: 1.5rem;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.main-nav { display: flex; gap: 1rem; flex: 1; }
.main-nav a { color: var(--text-muted); font-weight: 500; }
.main-nav a:hover { color: var(--primary); text-decoration: none; }
.user-box { display: flex; align-items: center; gap: .75rem; }
.user-name { font-weight: 600; font-size: .9rem; }

/* ---------- Conteneur ---------- */
.container { max-width: 1100px; margin: 1.75rem auto; padding: 0 1.25rem; }
.page-head { display: flex; justify-content: space-between; align-items: center;
             margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-block; padding: .55rem 1rem; border-radius: 8px;
    border: 1px solid transparent; font-size: .9rem; font-weight: 600;
    cursor: pointer; text-align: center; transition: background .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { display: block; width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: var(--primary-dark); border-color: var(--border); }
.btn-secondary:hover { background: #e3e9fa; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--secondary); color: var(--text); }

/* ---------- Alertes ---------- */
.alert { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; font-size: .92rem; }
.alert ul { margin: 0; padding-left: 1.25rem; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ---------- Cartes statistiques ---------- */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .9rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow);
    display: flex; flex-direction: column; border-left: 4px solid var(--border);
}
.stat-card.status-preparation { border-left-color: var(--st-preparation); }
.stat-card.status-shipped     { border-left-color: var(--st-shipped); }
.stat-card.status-delivered   { border-left-color: var(--st-delivered); }
.stat-card.status-cancelled   { border-left-color: var(--st-cancelled); }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: .85rem; }

/* ---------- Barre de filtre ---------- */
.filter-bar {
    display: flex; gap: .6rem; margin-bottom: 1.25rem; flex-wrap: wrap;
    background: var(--surface); padding: .8rem; border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.filter-bar input[type="text"] { flex: 1; min-width: 200px; }
.filter-bar input, .filter-bar select {
    padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; font-size: .9rem;
}

/* ---------- Tableau ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: .8rem 1rem; text-align: left; }
.data-table thead th {
    background: #fafbfe; color: var(--text-muted); font-size: .78rem;
    text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border);
}
.data-table tbody tr { border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbff; }
.data-table td.actions { white-space: nowrap; text-align: right; }
.data-table td.actions .btn { margin-left: .3rem; }

/* ---------- Badges de statut ---------- */
.badge {
    display: inline-block; padding: .25rem .6rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600; color: #fff;
}
.badge-lg { font-size: .9rem; padding: .4rem .9rem; }
.status-preparation { background: var(--st-preparation); }
.status-shipped     { background: var(--st-shipped); }
.status-delivered   { background: var(--st-delivered); }
.status-cancelled   { background: var(--st-cancelled); }

/* ---------- État vide ---------- */
.empty-state {
    text-align: center; padding: 3rem 1rem; background: var(--surface);
    border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-muted);
}
.empty-state p { margin-bottom: 1rem; }

/* ---------- Formulaires ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.form-card fieldset { border: none; padding: 0; margin: 0 0 1.5rem; }
.form-card legend { font-weight: 700; font-size: 1.05rem; padding: 0; margin-bottom: 1rem;
                    border-bottom: 1px solid var(--border); width: 100%; padding-bottom: .5rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { margin-bottom: 1rem; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .35rem; }
input[type="text"], input[type="password"], input[type="number"],
input[type="file"], textarea, select {
    width: 100%; padding: .6rem .75rem; border: 1px solid var(--border);
    border-radius: 8px; font-size: .95rem; font-family: inherit; background: #fff;
}
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,111,237,.12);
}
textarea { resize: vertical; }
.field-hint { display: block; color: var(--text-muted); font-size: .8rem; margin-top: .3rem; }
.form-actions { display: flex; gap: .75rem; padding-top: .5rem; }
.total-preview { font-size: 1.05rem; background: var(--secondary); padding: .8rem 1rem;
                 border-radius: 8px; margin: 0; }
.total-preview strong { color: var(--primary-dark); font-size: 1.15rem; }

.current-photo { display: flex; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.current-photo img { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* ---------- Photo : import fichier / caméra ---------- */
.is-hidden { display: none !important; }
.photo-tabs { display: flex; gap: .5rem; margin-bottom: .75rem; }
.photo-tab {
    flex: 1; padding: .55rem .8rem; border: 1px solid var(--border);
    background: var(--surface); border-radius: 8px; cursor: pointer;
    font-weight: 600; font-size: .88rem; color: var(--text-muted);
    transition: background .15s, border-color .15s;
}
.photo-tab:hover { background: var(--secondary); }
.photo-tab.is-active { background: var(--secondary); color: var(--primary-dark); border-color: var(--primary); }
.camera-box {
    position: relative; background: #111; border-radius: 8px; overflow: hidden;
    aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
    margin-bottom: .6rem; min-height: 200px;
}
.camera-box video, .camera-box img { width: 100%; height: 100%; object-fit: contain; }
.camera-placeholder { color: #888; font-size: .9rem; }
.camera-controls { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }

.order-number-tag { font-size: 1.1rem; color: var(--text-muted); margin-top: -.5rem; margin-bottom: 1.25rem; }

/* ---------- Vue détaillée ---------- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
.order-header { display: flex; justify-content: space-between; align-items: flex-start;
                padding-bottom: 1rem; border-bottom: 1px solid var(--border); margin-bottom: .5rem; }
.order-header h2 { margin: .2rem 0 0; }
.detail-list { display: grid; grid-template-columns: 180px 1fr; gap: .5rem 1rem; margin: 0; }
.detail-list dt { font-weight: 600; color: var(--text-muted); }
.detail-list dd { margin: 0; }
.detail-list .total-row { border-top: 1px solid var(--border); padding-top: .6rem; margin-top: .3rem; font-size: 1.1rem; }
.product-photo { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.no-photo { padding: 2rem; text-align: center; color: var(--text-muted);
            background: var(--secondary); border-radius: 8px; }
.status-form { display: flex; flex-direction: column; gap: .5rem; }
.status-btn { color: #fff; opacity: .55; }
.status-btn.is-active { opacity: 1; box-shadow: var(--shadow); }
.status-btn:hover { opacity: 1; }

/* ---------- Page de connexion ---------- */
.login-page {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(135deg, #2f6fed 0%, #1f57c4 100%); padding: 1rem;
}
.login-card {
    background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem; width: 100%; max-width: 380px; text-align: center;
}
.login-logo { font-size: 2.5rem; }
.login-card h1 { font-size: 1.4rem; margin: .5rem 0 .25rem; }
.login-sub { color: var(--text-muted); margin: 0 0 1.5rem; font-size: .92rem; }
.login-card form { text-align: left; }
.login-card label { margin-top: .75rem; }
.login-card .btn-block { margin-top: 1.25rem; }
.login-hint { margin-top: 1.5rem; font-size: .82rem; color: var(--text-muted);
              background: var(--secondary); padding: .7rem; border-radius: 8px; }

/* ---------- Pied de page ---------- */
.footer { text-align: center; color: var(--text-muted); font-size: .85rem;
          padding: 2rem 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .detail-list { grid-template-columns: 1fr; }
    .detail-list dt { margin-top: .5rem; }
    .main-nav { display: none; }
}
