/* ============================================================
   Chav Matters POS - Design tokens & core styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --ink:        #221B16;
    --cream:      #FBF7F0;
    --paper:      #FFFFFF;
    --chili:      #C1440E;
    --chili-dark: #9E3609;
    --mustard:    #D9A441;
    --success:    #3F7D5C;
    --success-bg: #E8F3ED;
    --danger:     #B23A32;
    --danger-bg:  #FBEAE8;
    --amber:      #D9A441;
    --amber-bg:   #FBF1DD;
    --line:       #E7DFD3;
    --muted:      #8A7F70;
    --radius:     10px;
    --sidebar-w:  240px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--cream);
    color: var(--ink);
    margin: 0;
    -webkit-tap-highlight-color: transparent;
}

.brand-font {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 700;
}

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

/* ---------------- Layout shell ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--ink);
    color: #EFE7DA;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    transform: translateX(0);
    transition: transform .25s ease;
    z-index: 1050;
}
.sidebar .brand {
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand-title { font-size: 22px; color: #fff; }
.sidebar .brand-sub { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--mustard); }

.sidebar nav { padding: 10px 10px; flex: 1; overflow-y: auto; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px; margin-bottom: 2px;
    border-radius: 8px; color: #C9BFAE; font-size: 14.5px; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--chili); color: #fff; }
.sidebar nav a i { width: 18px; text-align: center; font-size: 15px; }

.sidebar-footer { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1040;
}

.main-content { margin-left: var(--sidebar-w); flex: 1; min-width: 0; width: 100%; }

.topbar {
    background: var(--paper); border-bottom: 1px solid var(--line);
    padding: 14px 22px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 900;
}
.topbar .page-title { font-size: 19px; font-weight: 700; }
.hamburger-btn { display: none; background: none; border: none; font-size: 22px; color: var(--ink); }

.content-area { padding: 22px; }

/* ---------------- Cards ---------------- */
.card-panel {
    background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px;
}

.stat-card {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
}
.stat-card .stat-label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; font-family: 'Fraunces', serif; }
.stat-card.accent-chili .stat-value { color: var(--chili); }
.stat-card.accent-success .stat-value { color: var(--success); }
.stat-card.accent-amber .stat-value { color: var(--chili-dark); }

/* ---------------- Buttons ---------------- */
.btn-chili { background: var(--chili); border-color: var(--chili); color: #fff; }
.btn-chili:hover { background: var(--chili-dark); border-color: var(--chili-dark); color: #fff; }
.btn-outline-chili { border: 1px solid var(--chili); color: var(--chili); background: transparent; }
.btn-outline-chili:hover { background: var(--chili); color: #fff; }

.btn, .form-control, .form-select { border-radius: 8px; }

/* ---------------- Badges / status ---------------- */
.badge-status { padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-free      { background: var(--success-bg); color: var(--success); }
.badge-occupied  { background: var(--danger-bg); color: var(--danger); }
.badge-billing   { background: var(--amber-bg); color: var(--chili-dark); }
.badge-reserved  { background: #EAE6F5; color: #5B4B9C; }

/* ---------------- Table cards (POS floor view) ---------------- */
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.table-card {
    background: var(--paper); border: 2px solid var(--line); border-radius: 12px;
    padding: 16px 12px; text-align: center; cursor: pointer; transition: all .15s ease;
    position: relative;
}
.table-card:active { transform: scale(.97); }
.table-card .t-no { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 700; }
.table-card .t-cap { font-size: 12px; color: var(--muted); }
.table-card.free { border-color: var(--success); }
.table-card.occupied { border-color: var(--danger); background: var(--danger-bg); }
.table-card.billing { border-color: var(--chili-dark); background: var(--amber-bg); }
.table-card .dot { width: 9px; height: 9px; border-radius: 50%; position: absolute; top: 10px; right: 10px; }
.table-card.free .dot { background: var(--success); }
.table-card.occupied .dot { background: var(--danger); }
.table-card.billing .dot { background: var(--chili-dark); }

/* ---------------- POS order screen ---------------- */
.pos-shell { display: flex; height: 100vh; overflow: hidden; }
.pos-menu-col { flex: 1; overflow-y: auto; padding: 16px; }
.pos-cart-col {
    width: 380px; flex-shrink: 0; background: var(--paper); border-left: 1px solid var(--line);
    display: flex; flex-direction: column; height: 100vh;
}
.pos-cat-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; }
.pos-cat-tabs .cat-pill {
    padding: 8px 16px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line);
    white-space: nowrap; font-size: 13.5px; font-weight: 600; cursor: pointer; flex-shrink: 0;
}
.pos-cat-tabs .cat-pill.active { background: var(--chili); border-color: var(--chili); color: #fff; }

.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.menu-item-card {
    background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
    cursor: pointer; transition: border-color .15s ease;
}
.menu-item-card:hover { border-color: var(--chili); }
.menu-item-card .food-dot { width: 11px; height: 11px; border: 1.5px solid var(--success); display: inline-block; }
.menu-item-card .food-dot.non-veg { border-color: var(--danger); }
.menu-item-card .food-dot::after { content:''; display:block; width:5px; height:5px; border-radius:50%; background: var(--success); margin: 2px; }
.menu-item-card .food-dot.non-veg::after { background: var(--danger); }
.menu-item-card .mi-name { font-size: 13.5px; font-weight: 600; margin: 6px 0 2px; line-height: 1.25; }
.menu-item-card .mi-price { font-size: 13px; color: var(--chili-dark); font-weight: 700; }

.cart-items { flex: 1; overflow-y: auto; padding: 14px; }
.cart-line { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.cart-line .cl-name { font-size: 13.5px; font-weight: 600; }
.cart-line .cl-meta { font-size: 11.5px; color: var(--muted); }
.qty-ctrl { display: flex; align-items: center; gap: 8px; }
.qty-ctrl button { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: var(--cream); font-weight: 700; }

.pos-cart-footer { padding: 14px; border-top: 1px solid var(--line); background: var(--cream); }
.summary-row { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 6px; }
.summary-row.total { font-size: 17px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }

/* ---------------- Tables (data) ---------------- */
.table thead th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 2px solid var(--line); }
.table td { vertical-align: middle; font-size: 14px; }

/* ---------------- Toast / confirm modal ---------------- */
#toastHost { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.cm-toast {
    min-width: 240px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 8px;
    font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.2); display: flex; align-items: center; gap: 10px;
    animation: slideIn .2s ease;
}
.cm-toast.success { border-left: 4px solid var(--success); }
.cm-toast.error { border-left: 4px solid var(--danger); }
.cm-toast.info { border-left: 4px solid var(--mustard); }
@keyframes slideIn { from { transform: translateX(30px); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* ---------------- Responsive ---------------- */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .main-content { margin-left: 0; }
    .hamburger-btn { display: block; }
    .pos-shell { flex-direction: column; height: auto; }
    .pos-cart-col { width: 100%; height: auto; border-left: none; border-top: 1px solid var(--line); }
}

@media (max-width: 576px) {
    .content-area { padding: 14px; }
    .table-grid, .item-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* Tablet landscape tweak for POS screen (most common device on the floor) */
@media (min-width: 768px) and (max-width: 1024px) {
    .pos-cart-col { width: 320px; }
}
