/* HROS — feuille de style unique, pensée écran tactile (cibles larges, contrastes forts). */
:root {
    --bg: #f2f4f7;
    --surface: #ffffff;
    --text: #1a2233;
    --muted: #64748b;
    --border: #dde3ec;
    --primary: #1d6ef5;
    --primary-dark: #1554c0;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.45;
}
[x-cloak] { display: none !important; }

/* ---------- Navigation ---------- */
.topnav {
    display: flex; align-items: center; gap: 20px;
    background: #101828; color: #fff;
    padding: 0 16px; height: 54px;
    position: sticky; top: 0; z-index: 100;
}
.topnav .brand { color: #fff; font-weight: 800; font-size: 20px; text-decoration: none; letter-spacing: 1px; }
.nav-links { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-links a {
    color: #cbd5e1; text-decoration: none; padding: 8px 12px;
    border-radius: 8px; white-space: nowrap; font-weight: 500;
}
.nav-links a:hover { background: #1f2937; color: #fff; }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #cbd5e1; }

.container { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }

/* ---------- Composants ---------- */
h1 { font-size: 26px; margin: 8px 0 16px; }
h2 { font-size: 19px; margin: 0 0 12px; }

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px; margin-bottom: 18px;
}

.btn {
    display: inline-block; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); border-radius: 8px; padding: 10px 16px;
    font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: background .12s, transform .05s; touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 15px 22px; font-size: 18px; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
input, select, textarea {
    display: block; width: 100%; margin-top: 4px;
    padding: 10px 12px; font-size: 16px;
    border: 1px solid var(--border); border-radius: 8px; background: #fff;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; align-items: end; }

.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.badge-free { background: #dcfce7; color: #15803d; }
.badge-occupied { background: #fee2e2; color: #b91c1c; }
.badge-to_clean { background: #fef3c7; color: #b45309; }
.badge-reserved { background: #dbeafe; color: #1d4ed8; }
.badge-pending { background: #e2e8f0; color: #475569; }
.badge-preparing { background: #fef3c7; color: #b45309; }
.badge-ready { background: #dcfce7; color: #15803d; }
.badge-served { background: #dbeafe; color: #1d4ed8; }
.badge-voided, .badge-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-open { background: #dbeafe; color: #1d4ed8; }
.badge-paid { background: #dcfce7; color: #15803d; }

.muted { color: var(--muted); }
.text-right { text-align: right; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Login ---------- */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: #101828; }
.login-wrap { width: min(420px, 94vw); }
.login-logo { color: #fff; text-align: center; letter-spacing: 6px; font-size: 34px; margin-bottom: 20px; }
.pin-users { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.pin-user { padding: 12px 16px; border-radius: 8px; border: 1px solid var(--border); background: #f8fafc; font-size: 15px; font-weight: 600; cursor: pointer; }
.pin-user.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pin-display { text-align: center; font-size: 30px; letter-spacing: 8px; min-height: 44px; }
.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pin-key { font-size: 20px; padding: 14px 0; }

/* ---------- Plan de salle ---------- */
.floor-canvas {
    position: relative; min-height: 460px; border-radius: var(--radius);
    background: repeating-linear-gradient(0deg, transparent, transparent 34px, #e8edf4 35px),
                repeating-linear-gradient(90deg, transparent, transparent 34px, #e8edf4 35px), #f8fafc;
    border: 1px solid var(--border); overflow: hidden;
}
.floor-table {
    position: absolute; width: 110px; height: 96px;
    border-radius: 12px; border: 2px solid var(--border); background: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    cursor: grab; user-select: none; box-shadow: var(--shadow); font-weight: 700;
}
.floor-table small { font-weight: 500; color: var(--muted); }
.floor-table.status-free { border-color: var(--success); }
.floor-table.status-occupied { border-color: var(--danger); background: #fff5f5; }
.floor-table.status-to_clean { border-color: var(--warning); background: #fffbeb; }
.floor-table.status-reserved { border-color: var(--primary); background: #eff6ff; }

/* ---------- POS / prise de commande ---------- */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .pos-layout { grid-template-columns: 1fr; } }
.pos-categories { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pos-product {
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 10px; text-align: center; cursor: pointer; box-shadow: var(--shadow);
    font-weight: 600; min-height: 84px; display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.pos-product:active { transform: scale(.97); }
.pos-product .price { color: var(--primary); font-size: 14px; }
.pos-product.unavailable { opacity: .4; pointer-events: none; }
.pos-ticket { position: sticky; top: 70px; }
.ticket-line { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.ticket-total { font-size: 22px; font-weight: 800; display: flex; justify-content: space-between; padding-top: 10px; }

/* ---------- KDS ---------- */
.kds-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.kds-ticket { background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.kds-ticket.urgent { border: 2px solid var(--danger); }
.kds-ticket.late .kds-head { background: var(--danger); color: #fff; }
.kds-head { display: flex; justify-content: space-between; padding: 10px 12px; background: #101828; color: #fff; font-weight: 700; }
.kds-items { padding: 6px 12px; }
.kds-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.kds-item:last-child { border-bottom: none; }
.kds-actions { display: flex; gap: 8px; padding: 10px 12px; background: #f8fafc; }
.kds-actions .btn { flex: 1; }

/* ---------- Dashboard ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .kpi-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.kpi .kpi-value { font-size: 28px; font-weight: 800; margin-top: 4px; }

/* ---------- Divers ---------- */
.error-page { text-align: center; padding: 80px 20px; }
.error-page h1 { font-size: 64px; margin: 0; color: var(--muted); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.55); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 96vw); max-height: 90vh; overflow-y: auto; padding: 20px; }

@media print {
    .topnav, .no-print { display: none !important; }
    body { background: #fff; }
    .container { max-width: none; padding: 0; }
}
