:root {
    --color-bg: #f4f5f7;
    --color-primary: #b5292b;   /* rouge laqué, cohérent identité Saigon CaPhe */
    --color-primary-dark: #8f1f21;
    --color-text: #1f2328;
    --color-libre: #2e9e5b;
    --color-occupee: #e8a33d;
    --color-addition: #d9483d;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ---------- Login ---------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.login-box {
    background: #fff;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-box h1 { margin: 0 0 0.25rem; font-size: 2rem; }
.login-box .subtitle { color: #666; margin-bottom: 1.5rem; }

.login-box form { text-align: left; }
.login-box label { display: block; font-weight: 600; margin: 0.75rem 0 0.25rem; font-size: 0.9rem; }
.login-box input {
    width: 100%;
    padding: 0.85rem;
    font-size: 1.1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.restaurant-choice {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn-restaurant {
    padding: 1.25rem;
    font-size: 1.1rem;
    border-radius: var(--radius);
    border: 2px solid var(--color-primary);
    background: #fff;
    color: var(--color-primary);
    font-weight: 700;
}

/* ---------- Boutons génériques ---------- */
.btn {
    display: inline-block;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:active { background: var(--color-primary-dark); }
.btn-block { width: 100%; margin-top: 1.5rem; }
.btn-small { padding: 0.5rem 1rem; font-size: 0.9rem; background: #eee; color: var(--color-text); border-radius: 6px; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.95rem; }
.alert-error { background: #fdeaea; color: var(--color-addition); border: 1px solid #f3c1bd; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 1rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.topbar-left strong { font-size: 1.2rem; margin-right: 1rem; }
.link-switch { color: var(--color-primary); font-size: 0.9rem; text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 1rem; font-size: 0.95rem; }

/* ---------- Plan de salle ---------- */
.plan-salle { padding: 1.5rem; }
.salle-block { margin-bottom: 2rem; }
.salle-block h2 { margin-bottom: 0.75rem; font-size: 1.3rem; }

.tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.table-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 1.25rem 0.5rem;
    border: none;
    border-radius: var(--radius);
    min-height: 110px;
    font-size: 1rem;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.table-numero { font-size: 1.15rem; }
.table-capacite, .table-statut { font-size: 0.85rem; font-weight: 400; opacity: 0.9; }

.table-libre   { background: var(--color-libre); }
.table-occupee { background: var(--color-occupee); }
.table-addition_demandee { background: var(--color-addition); }

.empty-state { color: #888; font-style: italic; }

/* ---------- Prise de commande ---------- */
.commande-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    height: calc(100vh - 62px);
}

.menu-panel { overflow-y: auto; padding: 1rem; border-right: 1px solid #e3e3e3; }

.categorie-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e3e3e3;
}
.tab-btn {
    flex: 0 0 auto;
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    border: 1px solid #ddd;
    background: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
}
.tab-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.plats-groupe.hidden { display: none; }
.plats-list { display: flex; flex-direction: column; gap: 0.6rem; }

.plat-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.15rem 1rem;
    text-align: left;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
}
.plat-nom { font-weight: 700; grid-column: 1; }
.plat-prix { font-weight: 700; grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--color-primary); }
.plat-desc { grid-column: 1; font-size: 0.85rem; color: #777; }

/* ---------- Panier ---------- */
.panier-panel {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: #fff;
}
.panier-panel h2 { margin-top: 0; }

.panier-liste {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.panier-ligne {
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    background: #fafafa;
}
.panier-ligne.ligne-envoyee { background: #f1f7f2; border-color: #cfe6d4; }

.panier-ligne-header { display: flex; justify-content: space-between; align-items: center; }
.panier-ligne-nom { font-weight: 700; font-size: 0.95rem; }
.btn-remove { background: none; border: none; font-size: 1.3rem; color: #999; line-height: 1; cursor: pointer; }

.panier-ligne-qte { display: flex; align-items: center; gap: 0.6rem; margin: 0.4rem 0; }
.btn-qte {
    width: 30px; height: 30px; border-radius: 50%;
    border: 1px solid #ccc; background: #fff; font-size: 1.1rem; line-height: 1;
}
.qte-value { font-weight: 700; min-width: 1.2rem; text-align: center; }
.panier-ligne-prix { margin-left: auto; font-weight: 600; color: var(--color-primary); }

.panier-ligne-notes {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.envoi-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip {
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
}
.chip.active.chip-envoi_1 { background: #2e6b9e; color: #fff; border-color: #2e6b9e; }
.chip.active.chip-envoi_2 { background: #b5292b; color: #fff; border-color: #b5292b; }
.chip.active.chip-envoi_3 { background: #8a4fae; color: #fff; border-color: #8a4fae; }
.chip.active.chip-bar     { background: #2e9e5b; color: #fff; border-color: #2e9e5b; }

.panier-total {
    font-size: 1.2rem;
    font-weight: 700;
    text-align: right;
    padding: 0.75rem 0;
    border-top: 1px solid #eee;
    margin-top: 0.5rem;
}

/* ---------- Panneau des envois (commande.php) ---------- */
.envois-panel { margin-top: 1.25rem; border-top: 1px solid #eee; padding-top: 1rem; }
.envois-panel h3 { margin: 0 0 0.75rem; font-size: 1rem; }

.envoi-statut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.btn-appeler {
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-weight: 700;
    font-size: 0.9rem;
}
.btn-appeler:disabled { opacity: 0.6; }

.badge-statut {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}
.badge-appelee { background: #fdf1de; color: #b5732e; }
.badge-prete   { background: #e4f5e9; color: #1f7d43; }
.badge-servie  { background: #eee; color: #888; }

/* ---------- Notifications "prêt à servir" (plan de salle) ---------- */
.notif-zone {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 1.5rem;
}
.notif-zone:empty { display: none; }

.notif-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #e4f5e9;
    border: 1px solid #b6ddc1;
    color: #1f7d43;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-weight: 600;
    animation: notif-pop 0.25s ease-out;
}
.notif-btn { background: #1f7d43; color: #fff; }

@keyframes notif-pop {
    from { transform: translateY(-6px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ---------- Écran cuisine ---------- */
.kitchen-board {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.envoi-card {
    background: #fff;
    border-radius: var(--radius);
    border-left: 8px solid #ccc;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 1rem 1.1rem;
}
.envoi-card.chip-envoi_1 { border-left-color: #2e6b9e; }
.envoi-card.chip-envoi_2 { border-left-color: #b5292b; }
.envoi-card.chip-envoi_3 { border-left-color: #8a4fae; }
.envoi-card.chip-bar     { border-left-color: #2e9e5b; }

.envoi-card-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; }
.envoi-card-table { font-size: 1.15rem; font-weight: 800; }
.envoi-card-label { font-size: 0.85rem; font-weight: 700; color: #666; text-transform: uppercase; }

.envoi-card-lignes { list-style: none; margin: 0 0 1rem; padding: 0; font-size: 1rem; }
.envoi-card-lignes li { padding: 0.25rem 0; border-bottom: 1px dashed #eee; }
.envoi-card-lignes li:last-child { border-bottom: none; }

/* ---------- Boutons addition (commande.php) ---------- */
.addition-actions { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.btn-outline {
    background: #fff;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}

/* ---------- Écran addition ---------- */
.addition-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    height: calc(100vh - 62px);
}
.addition-detail, .addition-paiement { padding: 1.5rem; overflow-y: auto; }
.addition-detail { border-right: 1px solid #e3e3e3; }
.addition-paiement { background: #fafafa; display: flex; flex-direction: column; }

.addition-lignes { list-style: none; margin: 0 0 1rem; padding: 0; }
.addition-lignes li {
    display: grid;
    grid-template-columns: 2.5rem 1fr auto;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    font-size: 1rem;
}
.ligne-qte { color: #888; font-weight: 600; }
.ligne-montant { font-weight: 700; }

.addition-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.4rem;
    font-weight: 800;
    padding: 1rem 0;
    border-top: 2px solid var(--color-text);
}

.split-tool { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #eee; }
.split-tool label { display: block; font-weight: 600; margin-bottom: 0.4rem; font-size: 0.9rem; }
.split-tool input {
    width: 120px;
    padding: 0.5rem;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
}
.split-result { font-weight: 700; color: var(--color-primary); margin-top: 0.5rem; }

.paiements-liste { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.paiement-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 0.75rem;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
}

.restant-row {
    font-size: 1.15rem;
    font-weight: 700;
    text-align: right;
    padding: 0.75rem 0;
    border-top: 1px solid #eee;
    margin-bottom: 1rem;
}

.paiement-form label { display: block; font-weight: 600; margin: 0.5rem 0 0.3rem; font-size: 0.9rem; }
.paiement-form input {
    width: 100%;
    padding: 0.7rem;
    font-size: 1.1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}
.mode-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.chip-mode.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.btn-cloturer {
    margin-top: auto;
    background: #1f7d43;
    color: #fff;
}
.btn-cloturer:disabled { background: #ccc; color: #888; cursor: not-allowed; }

/* ---------- Bouton annulation de ligne (manager) ---------- */
.btn-annuler-ligne {
    margin-top: 0.5rem;
    background: #fdeaea;
    color: var(--color-addition);
    border: 1px solid #f3c1bd;
    font-size: 0.8rem;
    padding: 0.4rem 0.7rem;
}

/* ---------- Tableau de bord manager ---------- */
.dashboard-layout { padding: 1.5rem; max-width: 1100px; margin: 0 auto; }

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.kpi-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.kpi-label { font-size: 0.85rem; color: #777; font-weight: 600; text-transform: uppercase; }
.kpi-value { font-size: 1.8rem; font-weight: 800; color: var(--color-primary); }

.dashboard-section { margin-bottom: 2rem; }
.dashboard-section h2 { font-size: 1.15rem; margin-bottom: 0.75rem; }

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.dashboard-table th, .dashboard-table td {
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.95rem;
}
.dashboard-table th { background: #fafafa; font-weight: 700; color: #555; font-size: 0.85rem; text-transform: uppercase; }
.text-restant { color: var(--color-addition); font-weight: 700; }
.text-ok { color: #1f7d43; font-weight: 700; }

/* ---------- PWA : bandeau hors-ligne & file d'attente ---------- */
.offline-banner {
    display: none;
    position: sticky;
    top: 0;
    z-index: 50;
    background: #3a3f47;
    color: #fff;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}
.offline-banner.visible { display: block; }

.offline-queue-indicator {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: #b5732e;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.6rem 1rem;
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 60;
}
