/* ===========================================
   MyResto Pro - Modern Restaurant System
   Design: Clean, white/blue, professional
   =========================================== */

:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { font-family: 'IBM Plex Sans Arabic', sans-serif; background: var(--bg); color: var(--text); direction: rtl; min-height: 100vh; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea, button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 20px; left: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; color: var(--text); box-shadow: var(--shadow); min-width: 220px; display: flex; align-items: center; gap: 8px; transition: opacity 0.3s; }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.warning { border-color: var(--warning); color: var(--warning); }

/* ===== Modal ===== */
.modal-container { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); }
.modal { position: relative; background: var(--card); border-radius: 16px; width: 100%; max-width: 500px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal.modal-lg { max-width: 800px; }
.modal.modal-sm { max-width: 400px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { color: var(--text); font-size: 1.1rem; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-start; }
.icon-btn { width: 32px; height: 32px; border-radius: 6px; background: var(--bg); color: var(--text); display: inline-flex; align-items: center; justify-content: center; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; color: var(--text-muted); margin-bottom: 5px; font-size: 0.88rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 0.95rem;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 0.92rem; transition: all 0.2s; cursor: pointer; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 6px; }

/* ===============================================
   LANDING PAGE
   =============================================== */

.landing-body { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 50%, #bfdbfe 100%); }
.landing { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.landing-hero { max-width: 800px; text-align: center; }
.landing-logo { width: 100px; height: 100px; border-radius: 24px; background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; display: flex; align-items: center; justify-content: center; font-size: 3rem; font-weight: 900; margin: 0 auto 24px; box-shadow: 0 12px 40px rgba(37,99,235,0.3); }
.landing h1 { font-size: 3rem; font-weight: 900; color: var(--text); margin-bottom: 8px; }
.landing-tagline { font-size: 1.2rem; color: var(--primary); font-weight: 600; margin-bottom: 8px; }
.landing-sub { color: var(--text-muted); font-size: 1rem; margin-bottom: 32px; }
.landing-actions { display: flex; flex-direction: column; gap: 12px; max-width: 400px; margin: 0 auto 48px; }
.landing-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.feature-card { background: white; padding: 24px 16px; border-radius: var(--radius); border: 1px solid var(--border); transition: all 0.2s; }
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.feature-card i { font-size: 2rem; color: var(--primary); margin-bottom: 8px; }
.feature-card h3 { font-size: 0.95rem; margin-bottom: 4px; }
.feature-card p { color: var(--text-muted); font-size: 0.82rem; }

.error-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.error-screen i { font-size: 4rem; color: var(--warning); margin-bottom: 16px; }
.mt-2 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.mb-2 { margin-bottom: 16px; }

/* ===============================================
   CUSTOMER (QR ORDERING)
   =============================================== */

.customer-body { background: var(--bg); }
.customer-shell { min-height: 100vh; max-width: 600px; margin: 0 auto; background: var(--bg); padding-bottom: 100px; }
.customer-header { background: white; padding: 20px; box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; }
.customer-header h1 { font-size: 1.2rem; margin-bottom: 6px; }
.table-badge { display: inline-flex; align-items: center; gap: 8px; background: var(--primary); color: white; padding: 6px 12px; border-radius: 20px; font-size: 0.88rem; font-weight: 600; }
.table-badge .capacity { background: rgba(255,255,255,0.25); padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; }
.cart-fab { background: var(--primary); color: white; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; position: relative; box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.cart-count { position: absolute; top: -4px; right: -4px; background: var(--danger); color: white; min-width: 22px; height: 22px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; padding: 0 6px; }
.customer-nav { display: flex; background: white; border-bottom: 1px solid var(--border); padding: 0 12px; position: sticky; top: 80px; z-index: 9; }
.customer-nav a { flex: 1; padding: 14px 8px; text-align: center; color: var(--text-muted); font-weight: 600; border-bottom: 3px solid transparent; transition: all 0.2s; }
.customer-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
.customer-content { padding: 16px; }

.menu-page { }
.menu-categories { display: flex; gap: 8px; overflow-x: auto; padding: 4px; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
.cat-pill { padding: 8px 16px; background: white; border: 1px solid var(--border); border-radius: 20px; color: var(--text); font-weight: 600; white-space: nowrap; font-size: 0.9rem; }
.cat-pill.active { background: var(--primary); color: white; border-color: var(--primary); }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

.item-card { background: white; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; transition: all 0.2s; }
.item-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.item-image { width: 100%; aspect-ratio: 4/3; background: var(--bg); overflow: hidden; }
.item-image img { width: 100%; height: 100%; object-fit: cover; }
.item-image-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 3rem; color: var(--text-muted); }
.item-info { padding: 12px; }
.item-info h3 { font-size: 0.95rem; margin-bottom: 4px; }
.item-desc { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 8px; line-height: 1.3; min-height: 20px; }
.item-footer { display: flex; justify-content: space-between; align-items: center; }
.item-price { color: var(--primary); font-weight: 800; font-size: 1rem; }
.btn-add { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; }
.btn-add:hover { background: var(--primary-dark); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 4rem; color: var(--border); margin-bottom: 16px; }
.empty-state h2, .empty-state h3 { color: var(--text); margin-bottom: 10px; }

.page-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 16px; color: var(--text); }

/* Cart */
.cart-page { }
.cart-items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.cart-item-row { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cart-item-info { flex: 1; }
.cart-item-info h3 { font-size: 0.95rem; margin-bottom: 4px; }
.cart-item-actions { display: flex; align-items: center; gap: 6px; }
.qty-btn { width: 32px; height: 32px; border-radius: 8px; background: var(--bg); color: var(--text); font-weight: 800; }
.qty-btn:hover { background: var(--primary); color: white; }
.qty-value { min-width: 28px; text-align: center; font-weight: 700; }
.remove-btn { width: 32px; height: 32px; border-radius: 8px; background: rgba(239,68,68,0.1); color: var(--danger); margin-right: 4px; }
.cart-summary { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 16px; position: sticky; bottom: 0; }
.summary-row { display: flex; justify-content: space-between; font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.summary-total { color: var(--primary); font-size: 1.3rem; }

/* Orders */
.orders-page { }
.order-card { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; border-right: 4px solid var(--border); }
.order-card.status-pending { border-right-color: var(--primary); }
.order-card.status-preparing { border-right-color: var(--warning); }
.order-card.status-ready { border-right-color: var(--success); }
.order-card.status-served { border-right-color: var(--text-muted); }
.order-card.status-cancelled { border-right-color: var(--danger); }
.order-card-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.order-num { font-weight: 800; font-size: 1.05rem; }
.status-badge { padding: 4px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; }
.status-badge.pending { background: var(--primary); color: white; }
.status-badge.preparing { background: var(--warning); color: white; }
.status-badge.ready { background: var(--success); color: white; }
.status-badge.served { background: var(--text-muted); color: white; }
.status-badge.cancelled { background: var(--danger); color: white; }
.order-card-items { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.order-line { display: flex; justify-content: space-between; font-size: 0.9rem; }
.order-card-foot { padding-top: 4px; font-size: 1rem; }

/* Waiter */
.call-waiter-page { }
.waiter-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.waiter-btn { background: white; border: 2px solid var(--border); border-radius: 12px; padding: 24px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; transition: all 0.2s; }
.waiter-btn:hover { border-color: var(--primary); background: var(--primary); color: white; }
.waiter-btn i { font-size: 2rem; }
.waiter-btn span { font-weight: 600; }

/* ===============================================
   KITCHEN DISPLAY SYSTEM
   =============================================== */

.kitchen-body { background: #0f172a; color: #f1f5f9; }
.kds-shell { min-height: 100vh; padding: 20px; }
.kds-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding: 20px; background: #1e293b; border-radius: 12px; }
.kds-header h1 { font-size: 1.4rem; color: white; }
.kds-header h1 i { color: var(--warning); margin-left: 8px; }
.kds-header small { color: #94a3b8; font-family: monospace; font-size: 0.95rem; }
.kds-controls { display: flex; gap: 12px; align-items: center; }
.kds-controls select { background: #334155; color: white; border: 1px solid #475569; }

.kds-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.kds-stat { background: #1e293b; padding: 16px; border-radius: 12px; text-align: center; border-top: 3px solid var(--primary); }
.kds-stat.preparing { border-top-color: var(--warning); }
.kds-stat.ready { border-top-color: var(--success); }
.kds-stat.done { border-top-color: #94a3b8; }
.kds-stat .num { font-size: 2.2rem; font-weight: 900; color: white; }
.kds-stat .label { color: #94a3b8; font-size: 0.85rem; margin-top: 4px; }

.kds-section { margin-bottom: 32px; }
.kds-section-title { color: white; font-size: 1.1rem; margin-bottom: 12px; padding: 8px 0; border-bottom: 1px solid #334155; }
.kds-section-title i { color: var(--warning); margin-left: 6px; }

.kds-empty { text-align: center; padding: 60px 20px; color: #64748b; }
.kds-empty i { font-size: 4rem; margin-bottom: 12px; color: #334155; }
.kds-empty h3 { color: #94a3b8; margin-bottom: 6px; }

.kds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.kds-card { background: #1e293b; border-radius: 12px; padding: 16px; border-left: 6px solid #475569; }
.kds-card.status-new { border-left-color: var(--primary); animation: kds-pulse 2s infinite; }
.kds-card.status-preparing { border-left-color: var(--warning); }
.kds-card.status-ready { border-left-color: var(--success); background: rgba(16,185,129,0.1); }
.kds-card.status-served { opacity: 0.6; border-left-color: #94a3b8; }
@keyframes kds-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(37,99,235,0); }
}
.kds-card-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #334155; }
.kds-order-num { font-size: 1.4rem; font-weight: 900; color: white; }
.kds-table { color: #cbd5e1; font-size: 0.9rem; margin-top: 2px; }
.kds-time { color: #94a3b8; font-size: 0.85rem; font-family: monospace; }
.kds-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.kds-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #0f172a; border-radius: 6px; }
.kds-qty { background: var(--primary); color: white; padding: 2px 8px; border-radius: 4px; font-weight: 800; min-width: 28px; text-align: center; }
.kds-item-name { color: #f1f5f9; font-size: 0.95rem; font-weight: 500; }
.kds-actions { display: flex; gap: 8px; }
.kds-action-btn { flex: 1; padding: 12px; border-radius: 8px; font-weight: 700; color: white; transition: all 0.2s; }
.kds-action-btn:hover { transform: translateY(-1px); }
.kds-action-btn.preparing { background: var(--warning); }
.kds-action-btn.ready { background: var(--success); }
.kds-action-btn.served { background: var(--primary); }

/* ===============================================
   ADMIN
   =============================================== */

.admin-body { background: var(--bg); }
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.admin-sidebar { background: var(--text); color: white; padding: 24px 16px; }
.admin-logo { width: 60px; height: 60px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), var(--primary-light)); display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 900; margin: 0 auto 12px; }
.admin-sidebar h2 { font-size: 1.1rem; text-align: center; margin-bottom: 4px; }
.admin-sidebar small { display: block; text-align: center; color: #94a3b8; font-size: 0.8rem; margin-bottom: 20px; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: #cbd5e1; border-radius: 8px; transition: all 0.2s; }
.admin-nav a:hover { background: rgba(255,255,255,0.08); color: white; }
.admin-nav a.active { background: var(--primary); color: white; }
.admin-nav a i { width: 18px; text-align: center; }
.admin-main { padding: 24px; overflow-y: auto; }

.admin-page-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 16px; }

.card { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card h3 { margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--bg); color: var(--text-muted); text-align: right; padding: 12px 14px; font-weight: 700; font-size: 0.85rem; border-bottom: 2px solid var(--border); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 0.88rem; }

.dashboard-order-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.dashboard-order-row:last-child { border-bottom: none; }

.admin-item-card { background: var(--bg); padding: 12px; border-radius: 8px; }
.admin-item-card h3 { font-size: 0.95rem; margin-bottom: 4px; }

/* Mobile */
@media (max-width: 768px) {
    .admin-shell { grid-template-columns: 1fr; }
    .kds-stats { grid-template-columns: 1fr 1fr; }
    .menu-grid { grid-template-columns: 1fr 1fr; }
    .kds-grid { grid-template-columns: 1fr; }
    .waiter-options { grid-template-columns: 1fr; }
    .landing h1 { font-size: 2rem; }
}

/* ===========================================
   PIN Authentication Modal
   =========================================== */

.pin-modal-backdrop {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(15,23,42,0.85); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    transition: opacity 0.2s;
}
.pin-modal {
    background: white; border-radius: 24px; padding: 32px 28px;
    max-width: 380px; width: 100%; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: pinModalIn 0.3s ease;
}
@keyframes pinModalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.pin-modal.shake { animation: pinShake 0.4s; }
@keyframes pinShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}
.pin-modal h2 { font-size: 1.4rem; margin-bottom: 4px; color: var(--text); }
.pin-modal > p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; }
.pin-icon {
    width: 72px; height: 72px; border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 2rem; margin: 0 auto 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.pin-display {
    display: flex; justify-content: center; gap: 12px;
    margin-bottom: 24px; direction: ltr;
}
.pin-dot {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--border);
    transition: all 0.15s;
}
.pin-dot.filled {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.1);
}
.pin-pad {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 8px; max-width: 280px; margin: 0 auto;
}
.pin-key {
    aspect-ratio: 1.4/1; background: var(--bg);
    border: 1px solid var(--border); border-radius: 12px;
    font-size: 1.4rem; font-weight: 700; color: var(--text);
    cursor: pointer; transition: all 0.1s;
    display: flex; align-items: center; justify-content: center;
    user-select: none;
}
.pin-key:hover { background: white; border-color: var(--primary); }
.pin-key:active { transform: scale(0.95); background: var(--primary); color: white; }
.pin-key-clear { background: #fef2f2; color: var(--danger); }
.pin-key-empty { background: transparent; border: none; cursor: default; }
.pin-key-clear:hover { background: var(--danger); color: white; }
.pin-error {
    color: var(--danger); font-size: 0.9rem; font-weight: 600;
    min-height: 24px; margin: 14px 0 4px;
}
.pin-hint {
    display: block; color: var(--text-muted); font-size: 0.78rem;
    padding-top: 12px; border-top: 1px solid var(--border);
}
.pin-hint strong { color: var(--text); font-family: monospace; }
