/* EPOS Pro - Main styles */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f1f5f9;
    color: #0f172a;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

.nav {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.nav .brand { font-size: 18px; font-weight: 700; color: #2563eb; margin-right: 12px; }
.nav a {
    text-decoration: none; color: #475569; padding: 8px 14px;
    border-radius: 8px; font-size: 14px; font-weight: 500;
    transition: background 0.15s;
}
.nav a:hover { background: #f1f5f9; }
.nav a.active { background: #2563eb; color: white; }

.main { flex: 1; padding: 16px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* Buttons */
.btn {
    padding: 10px 16px; border-radius: 8px; font-weight: 500; font-size: 14px;
    border: none; transition: all 0.15s; min-height: 40px;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-secondary { background: white; border: 1px solid #cbd5e1; color: #0f172a; }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; }
.btn-success { background: #059669; color: white; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-ghost { background: transparent; color: #475569; }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; }

/* Form */
.input {
    width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1;
    border-radius: 8px; font-size: 14px; min-height: 40px;
}
.input:focus { outline: 2px solid #2563eb; outline-offset: -1px; border-color: transparent; }
.label { display: block; font-size: 12px; color: #64748b; margin-bottom: 4px; }

.card {
    background: white; border-radius: 12px; border: 1px solid #e2e8f0;
    padding: 14px;
}

/* Tables grid */
.tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.table-btn {
    padding: 18px 8px; min-height: 100px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; border-radius: 12px; border: 2px solid;
    font-weight: 500; transition: all 0.15s;
}
.table-btn.free { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.table-btn.free:hover { background: #d1fae5; }
.table-btn.active { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.table-btn.active:hover { background: #fde68a; }
.table-btn .name { font-size: 18px; font-weight: 700; }
.table-btn .seats { font-size: 11px; opacity: 0.8; }
.table-btn .total { font-size: 14px; font-weight: 600; margin-top: 4px; }

/* Order layout */
.order-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 16px;
}
@media (max-width: 768px) { .order-layout { grid-template-columns: 1fr; } }

.cat-buttons { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.cat-btn {
    padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
    background: white; border: 1px solid #e2e8f0; color: #475569;
}
.cat-btn.active { background: #0f172a; color: white; border-color: #0f172a; }

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
}
.product-btn {
    padding: 14px 8px; min-height: 80px;
    background: white; border: 1px solid #e2e8f0; border-radius: 10px;
    display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.product-btn:hover { background: #f8fafc; }
.product-btn .pname { font-size: 13px; font-weight: 500; text-align: center; }
.product-btn .price { font-size: 12px; color: #64748b; }
.product-btn .has-options { font-size: 10px; color: #2563eb; }

/* Cart */
.cart {
    display: flex; flex-direction: column; min-height: 460px;
}
.cart-items {
    flex: 1; overflow-y: auto; max-height: 320px;
    margin-bottom: 10px;
}
.cart-item {
    padding: 10px 0; border-bottom: 1px solid #f1f5f9;
    display: flex; justify-content: space-between; gap: 8px;
    cursor: pointer;  /* clickable to edit */
    transition: background 0.1s;
}
.cart-item:hover { background: #f8fafc; }
.cart-item:last-child { border-bottom: none; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 13px; font-weight: 500; }
.cart-item-name .edit-hint { font-size: 10px; color: #2563eb; margin-left: 6px; opacity: 0; transition: opacity 0.1s; }
.cart-item:hover .edit-hint { opacity: 1; }
.cart-item-opts { font-size: 11px; color: #64748b; margin-top: 2px; }
.cart-item-price { font-size: 11px; color: #64748b; }
.qty-controls { display: flex; align-items: center; gap: 4px; }
.qty-btn { width: 28px; height: 28px; padding: 0; background: white; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 14px; }
.qty-num { min-width: 20px; text-align: center; font-size: 13px; }

.totals {
    border-top: 1px solid #e2e8f0;
    padding-top: 10px;
}
.total-row { display: flex; justify-content: space-between; font-size: 13px; color: #64748b; padding: 2px 0; }
.total-row.discount-row { color: #059669; }
.total-row.grand { font-size: 18px; font-weight: 600; color: #0f172a; margin-top: 6px; padding-top: 6px; border-top: 1px solid #e2e8f0; }

.cart-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 12px; }
.cart-actions .full { grid-column: 1 / -1; }
.cart-actions .half { grid-column: span 2; }

/* Modals */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 16px;
}
.modal {
    background: white; border-radius: 14px; padding: 20px;
    max-width: 460px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close { width: 32px; height: 32px; border-radius: 6px; background: transparent; border: none; }
.modal-close:hover { background: #f1f5f9; }

.opt-group { margin-bottom: 16px; }
.opt-group-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.opt-group-name { font-size: 13px; font-weight: 600; }
.opt-group-name .req { color: #dc2626; margin-left: 2px; }
.opt-group-rule { font-size: 11px; color: #64748b; }
.opt-row {
    display: flex; align-items: center; gap: 10px; padding: 8px;
    border-radius: 6px; cursor: pointer; transition: background 0.1s;
}
.opt-row:hover { background: #f8fafc; }
.opt-row.checked { background: #eff6ff; }
.opt-row .opt-label { flex: 1; font-size: 14px; }
.opt-row .opt-price { font-size: 12px; color: #64748b; }

/* Cash modal */
.cash-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 6px; }
.cash-quick .btn { padding: 14px 0; font-size: 16px; font-weight: 600; }
.cash-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cash-total-box { background: #f1f5f9; border-radius: 10px; padding: 14px; margin-bottom: 14px;
    display: flex; justify-content: space-between; align-items: center; }
.cash-total-box .label { font-size: 13px; color: #64748b; }
.cash-total-box .amount { font-size: 24px; font-weight: 700; }
.cash-input { font-size: 20px; text-align: center; padding: 14px; }
.cash-change-box, .cash-short-box {
    border-radius: 10px; padding: 12px; margin: 12px 0; text-align: center;
}
.cash-change-box { background: #d1fae5; color: #065f46; }
.cash-change-box .change-amount { font-size: 26px; font-weight: 700; }
.cash-short-box { background: #fed7aa; color: #9a3412; font-size: 14px; }

/* Discount modal */
.disc-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.disc-tabs .btn { flex: 1; }
.disc-tabs .btn.active { background: #0f172a; color: white; border-color: #0f172a; }
.disc-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.disc-quick .btn { padding: 12px 0; }

/* Print prompt modal */
.print-prompt { text-align: center; padding: 12px 0; }
.print-prompt .icon { font-size: 48px; margin-bottom: 8px; }
.print-prompt .title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.print-prompt .sub { font-size: 13px; color: #64748b; margin-bottom: 16px; }
.print-prompt-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Status badges */
.badge { font-size: 11px; padding: 3px 8px; border-radius: 4px; font-weight: 500; }
.badge-low { background: #fef3c7; color: #78350f; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-gold { background: #fef3c7; color: #78350f; }
.badge-silver { background: #e2e8f0; color: #475569; }
.badge-bronze { background: #ffedd5; color: #9a3412; }

/* KDS */
.kds-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.kds-card { background: white; border: 2px solid #e2e8f0; border-radius: 10px; padding: 14px; }
.kds-card.late { border-color: #fcd34d; background: #fffbeb; }
.kds-card .num { font-weight: 700; }
.kds-card .timer { font-size: 12px; color: #64748b; }
.kds-card .timer.late { color: #92400e; font-weight: 600; }
.kds-card .where { font-size: 11px; color: #64748b; margin-top: 4px; margin-bottom: 10px; }
.kds-item { margin-bottom: 8px; }
.kds-item .iname { font-weight: 600; font-size: 14px; }
.kds-item .iopts { font-size: 11px; color: #64748b; padding-left: 12px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid #e2e8f0; margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 10px 14px; background: transparent; border: none; border-bottom: 2px solid transparent;
    font-size: 14px; color: #64748b; white-space: nowrap; cursor: pointer; }
.tab.active { border-bottom-color: #0f172a; color: #0f172a; font-weight: 600; }

/* Empty states */
.empty { text-align: center; color: #94a3b8; padding: 40px 20px; }

/* Forms in admin */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; align-items: end; margin-bottom: 12px; }
.form-list { background: white; border-radius: 10px; border: 1px solid #e2e8f0; }
.form-list-row { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; }
.form-list-row:last-child { border-bottom: none; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card { background: white; border-radius: 10px; padding: 16px; border: 1px solid #e2e8f0; }
.stat-card .stat-label { font-size: 12px; color: #64748b; }
.stat-card .stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-sub { font-size: 11px; color: #64748b; margin-top: 4px; }
.stat-card .stat-trend.up { color: #059669; }
.stat-card .stat-trend.down { color: #dc2626; }

/* Charts */
.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding: 8px 4px; border-bottom: 1px solid #e2e8f0; }
.chart-bar {
    flex: 1; background: linear-gradient(180deg, #2563eb 0%, #3b82f6 100%);
    border-radius: 4px 4px 0 0; min-height: 2px;
    position: relative; cursor: default;
    transition: opacity 0.1s;
}
.chart-bar:hover { opacity: 0.85; }
.chart-bar .bar-tip {
    position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
    background: #0f172a; color: white; font-size: 10px; padding: 2px 6px; border-radius: 4px;
    white-space: nowrap; opacity: 0; transition: opacity 0.1s; pointer-events: none;
}
.chart-bar:hover .bar-tip { opacity: 1; }
.chart-labels { display: flex; gap: 4px; padding: 4px; font-size: 9px; color: #94a3b8; text-align: center; }
.chart-labels span { flex: 1; }

/* Receipt preview */
.receipt-frame {
    background: #f8f9fa;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 14px;
    min-height: 200px;
    max-height: 700px;
    overflow-y: auto;
}
.receipt-paper {
    background: white;
    padding: 14px 12px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 280px;
    margin: 0 auto;
}
.receipt-paper .rlogo { margin-bottom: 8px; }
.receipt-paper .rlogo.align-left { text-align: left; }
.receipt-paper .rlogo.align-right { text-align: right; }
.receipt-paper .rlogo.align-center { text-align: center; }
.receipt-paper .rlogo img { max-width: 180px; max-height: 80px; }
.receipt-paper .rcompany { font-size: 16px; font-weight: bold; text-align: center; }
.receipt-paper .raddr { text-align: center; font-size: 11px; }
.receipt-paper .rdash { border-top: 1px dashed #cbd5e1; margin: 6px 0; }
.receipt-paper .rsection { margin: 4px 0; }
.receipt-paper .rline { display: flex; justify-content: space-between; }
.receipt-paper .rdiscount { color: #059669; }
.receipt-paper .ropt { font-size: 11px; padding-left: 8px; color: #475569; }
.receipt-paper .rgrand { font-size: 14px; margin-top: 4px; }
.receipt-paper .rfooter { text-align: center; margin-top: 6px; }

/* Cart edit icon */
.cart-edit-icon {
    color: #2563eb;
    font-size: 11px;
    margin-left: 4px;
    opacity: 0.6;
}
.cart-item-info:hover .cart-edit-icon { opacity: 1; }

/* Invalid option group highlight */
.opt-group-invalid {
    border-left: 3px solid #dc2626;
    padding-left: 8px;
}
.opt-group-error {
    color: #dc2626;
    font-size: 11px;
    margin-top: 4px;
    font-weight: 500;
}

/* Cart action grid - 5 buttons */
.cart-actions-extended {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: 10px;
}
.cart-actions-extended .btn { padding: 10px 6px; font-size: 13px; }
.cart-actions-extended .btn-full { grid-column: span 3; }

/* Discount modal */
.discount-modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 12px 0;
}
.discount-modal-body label { font-size: 12px; color: #64748b; }
.discount-quick {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}
.discount-quick .btn { padding: 8px; font-size: 13px; }
.discount-row {
    color: #059669;
}

/* Chart bars (reports) */
.chart-bar-row {
    display: grid;
    grid-template-columns: 60px 1fr 80px;
    gap: 8px;
    align-items: center;
    margin-bottom: 4px;
    font-size: 12px;
}
.chart-bar-bg {
    background: #f1f5f9;
    border-radius: 4px;
    height: 22px;
    overflow: hidden;
    position: relative;
}
.chart-bar-fill {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    padding-left: 6px;
    color: white;
    font-size: 11px;
    font-weight: 500;
}
.chart-bar-empty { background: #f1f5f9; }
.chart-bar-row .chart-label { color: #475569; font-weight: 500; }
.chart-bar-row .chart-value { color: #0f172a; font-weight: 600; text-align: right; }

/* Stat tiles (reports) */
.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.stat-tile {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
}
.stat-tile .label {
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.stat-tile .value {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
}
.stat-tile .delta {
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
}
.stat-tile .delta.up { color: #059669; }
.stat-tile .delta.down { color: #dc2626; }
.stat-tile .delta.neutral { color: #64748b; }

/* Range buttons */
.range-buttons {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}
.range-buttons button {
    background: white;
    border: 1px solid #cbd5e1;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
}
.range-buttons button.active {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

/* Mobile */
@media (max-width: 640px) {
    .nav { padding: 8px; }
    .nav .brand { display: none; }
    .nav a { padding: 6px 10px; font-size: 13px; }
    .main { padding: 12px; }
    .order-layout { grid-template-columns: 1fr; }
    .cart-actions { grid-template-columns: 1fr 1fr; }
    .stat-tiles { grid-template-columns: 1fr 1fr; }
}
