/* ==========================================
   QR-FOOD — единая дизайн-система
   ========================================== */

:root {
    --primary: #e8590c;
    --primary-dark: #c74a09;
    --primary-light: #fff3ec;
    --success: #2b8a3e;
    --success-light: #ebfbee;
    --danger: #c92a2a;
    --danger-light: #fff5f5;
    --warning: #e8a300;
    --warning-light: #fff9e6;

    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --text-muted: #a3a3a3;

    --surface-0: #f7f6f4;
    --surface-1: #ffffff;
    --border: #e7e5e2;
    --border-strong: #d5d2cd;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--surface-0);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.container-narrow {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.nav-links a:hover { color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform .05s ease, background .15s ease;
    font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface-1); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-0); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.card-hover { transition: box-shadow .15s ease, border-color .15s ease; }
.card-hover:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
input[type="text"], input[type="tel"], input[type="password"],
input[type="number"], input[type="email"], textarea, select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    background: var(--surface-1);
    color: var(--text-primary);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { resize: vertical; min-height: 90px; }

/* ---------- Alerts / badges ---------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); }
.alert-info { background: var(--primary-light); color: var(--primary-dark); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-new { background: var(--primary-light); color: var(--primary-dark); }
.badge-pending_payment { background: #eee; color: var(--text-secondary); }
.badge-paid { background: #e7f0ff; color: #1c5cc9; }
.badge-accepted { background: #e7f0ff; color: #1c5cc9; }
.badge-cooking { background: var(--warning-light); color: #997000; }
.badge-ready { background: var(--success-light); color: var(--success); }
.badge-served { background: #eee; color: var(--text-secondary); }
.badge-completed { background: var(--success-light); color: var(--success); }
.badge-cancelled { background: var(--danger-light); color: var(--danger); }

/* ---------- Auth pages ---------- */
.auth-wrap {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 22px; margin: 0 0 4px; }
.auth-card .subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-secondary); }
.auth-switch a { color: var(--primary); font-weight: 600; }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

/* ---------- Restaurant list card ---------- */
.restaurant-card { display: flex; flex-direction: column; gap: 8px; }
.restaurant-card .r-logo {
    width: 100%; height: 120px; border-radius: var(--radius-sm);
    background: var(--surface-0); object-fit: cover;
}
.restaurant-card h3 { margin: 0; font-size: 16px; }
.restaurant-card .r-city { font-size: 13px; color: var(--text-muted); }

/* ---------- Dashboard layout ---------- */
.dash-layout { display: flex; min-height: calc(100vh - 64px); }
.dash-sidebar {
    width: 220px;
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    flex-shrink: 0;
}
.dash-sidebar a {
    display: block;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
    cursor: pointer;
}
.dash-sidebar a.active, .dash-sidebar a:hover { background: var(--primary-light); color: var(--primary-dark); }
.dash-main { flex: 1; padding: 28px; min-width: 0; }
.dash-main h1 { font-size: 22px; margin: 0 0 20px; }

.stat-card { text-align: left; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ---------- Menu item / order rows ---------- */
.item-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-row img {
    width: 56px; height: 56px; border-radius: var(--radius-sm);
    object-fit: cover; background: var(--surface-0); flex-shrink: 0;
}
.item-row .item-info { flex: 1; min-width: 0; }
.item-row .item-name { font-weight: 600; font-size: 15px; }
.item-row .item-price { color: var(--primary); font-weight: 600; font-size: 14px; }

/* ---------- Menu grid (square photo cards, restaurant dashboard) ---------- */
.menu-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.menu-photo-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.menu-photo-card .photo-box {
    width: 100%; aspect-ratio: 1 / 1; background: var(--surface-0);
    overflow: hidden; position: relative;
}
.menu-photo-card .photo-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.menu-photo-card .photo-box.unavailable img { opacity: .35; }
.menu-photo-card .photo-box .unavailable-tag {
    position: absolute; top: 8px; left: 8px; background: var(--danger); color: #fff;
    font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
}
.menu-photo-card .card-body { padding: 12px; }
.menu-photo-card .card-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.menu-photo-card .card-price { color: var(--primary); font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.menu-photo-card .card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Archive accordion ---------- */
.archive-row { border-bottom: 1px solid var(--border); }
.archive-row:last-child { border-bottom: none; }
.archive-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 0; cursor: pointer;
}
.archive-head .chevron { transition: transform .15s ease; }
.archive-head.open .chevron { transform: rotate(180deg); }
.archive-details { display: none; padding: 0 0 14px; font-size: 14px; color: var(--text-secondary); }
.archive-details.open { display: block; }

.order-card { margin-bottom: 14px; }
.order-card .order-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.order-card .order-items { font-size: 14px; color: var(--text-secondary); margin-bottom: 10px; }
.order-card .order-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Public menu (QR) page ---------- */
.menu-hero { padding: 24px 0; }
.category-tabs {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px;
    margin-bottom: 16px; -webkit-overflow-scrolling: touch;
}
.category-tabs button {
    white-space: nowrap; padding: 8px 16px; border-radius: 999px;
    border: 1px solid var(--border-strong); background: var(--surface-1);
    font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit;
}
.category-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.qty-control { display: flex; align-items: center; gap: 10px; }
.qty-control button {
    width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border-strong);
    background: var(--surface-1); font-size: 16px; cursor: pointer; line-height: 1;
}
.cart-bar {
    position: fixed; bottom: 16px; left: 16px; right: 16px; max-width: 480px; margin: 0 auto;
    background: var(--primary); color: #fff; border-radius: var(--radius);
    padding: 14px 20px; display: flex; justify-content: space-between; align-items: center;
    box-shadow: var(--shadow-md); cursor: pointer; z-index: 60;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center; z-index: 100;
    padding: 20px;
}
.modal-box {
    background: var(--surface-1); border-radius: var(--radius);
    padding: 24px; width: 100%; max-width: 460px; max-height: 85vh; overflow-y: auto;
}
.modal-box h2 { margin-top: 0; font-size: 18px; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.muted { color: var(--text-secondary); font-size: 14px; }
.flex { display: flex; } .flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }

@media (max-width: 720px) {
    .dash-layout { flex-direction: column; }
    .dash-sidebar { width: 100%; display: flex; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .dash-sidebar a { white-space: nowrap; }
    .dash-main { padding: 16px; }
    .nav-links { gap: 12px; }
}
