/* ===========================================
   Restaurant System - Customer + Admin
   =========================================== */

:root {
    --primary: #e74c3c;
    --primary-light: #ff6b5b;
    --primary-dark: #c0392b;
    --dark: #1a1a1a;
    --darker: #0f0f0f;
    --gray: #2a2a2a;
    --gray-light: #3a3a3a;
    --light-gray: #b0b0b0;
    --white: #ffffff;
    --green: #25D366;
    --red: #e74c3c;
    --yellow: #f39c12;
    --blue: #3498db;
    --success: #2ecc71;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { font-family: 'Tajawal', sans-serif; background: var(--darker); color: var(--white); 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(--gray); border: 1px solid var(--primary); border-radius: 8px; padding: 10px 16px; color: white; box-shadow: var(--shadow); min-width: 220px; display: flex; align-items: center; gap: 8px; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--red); }
.toast.warning { border-color: var(--yellow); }

/* ===== 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.7); backdrop-filter: blur(4px); }
.modal { position: relative; background: var(--gray); border: 1px solid var(--gray-light); border-radius: 12px; width: 100%; max-width: 500px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
.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(--gray-light); }
.modal-header h3 { color: var(--primary-light); font-size: 1.1rem; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-light); display: flex; gap: 10px; justify-content: flex-start; }

.icon-btn { width: 32px; height: 32px; border-radius: 6px; background: var(--gray-light); color: white; display: inline-flex; align-items: center; justify-content: center; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; color: var(--light-gray); margin-bottom: 5px; font-size: 0.88rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; background: var(--darker); border: 1px solid var(--gray-light);
    border-radius: 8px; color: white; font-size: 0.95rem;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-group textarea { min-height: 80px; resize: vertical; }
.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; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; }
.btn-secondary { background: var(--gray-light); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--red); color: white; }
.btn-warning { background: var(--yellow); color: white; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 6px; }

/* ===============================================
   CUSTOMER-FACING STYLES
   =============================================== */

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

.hero { text-align: center; padding: 60px 20px 30px; }
.hero-icon { font-size: 5rem; margin-bottom: 16px; }
.hero h1 { font-size: 2.5rem; font-weight: 900; color: white; margin-bottom: 8px; }
.hero p { color: var(--light-gray); font-size: 1.1rem; }

.table-pick-btn {
    background: var(--gray);
    border: 2px solid var(--gray-light);
    border-radius: 12px;
    padding: 20px 10px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    cursor: pointer;
}
.table-pick-btn:hover {
    border-color: var(--primary);
    background: rgba(231, 76, 60, 0.1);
    transform: translateY(-2px);
}
.table-pick-btn i { font-size: 1.6rem; color: var(--primary); }
.table-pick-btn span { font-weight: 600; }

.rest-header {
    position: relative;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 30px 20px 24px;
    overflow: hidden;
}
.rest-header-bg {
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.15), transparent 70%);
    pointer-events: none;
}
.rest-header-content { display: flex; align-items: center; gap: 16px; position: relative; }
.rest-logo { font-size: 3.5rem; }
.rest-header h1 { font-size: 1.5rem; font-weight: 900; color: white; }
.rest-header p { color: rgba(255,255,255,0.85); font-size: 0.92rem; margin-top: 2px; }
.table-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0,0,0,0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
}

.container { max-width: 900px; margin: 0 auto; padding: 20px 16px 100px; }

.cat-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 20px;
    scrollbar-width: thin;
}
.cat-tab {
    padding: 8px 16px;
    background: var(--gray);
    border: 1px solid var(--gray-light);
    border-radius: 20px;
    color: var(--light-gray);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: all 0.2s;
    cursor: pointer;
}
.cat-tab.active, .cat-tab:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.cat-section { margin-bottom: 32px; }
.cat-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-light);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray);
}
.cat-title i { color: var(--primary); margin-left: 8px; }

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.menu-item {
    background: var(--gray);
    border: 1px solid var(--gray-light);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}
.menu-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.menu-item-body { flex: 1; }
.menu-item-body h3 { font-size: 1rem; font-weight: 700; color: white; margin-bottom: 4px; }
.menu-item-body p { color: var(--light-gray); font-size: 0.85rem; margin-bottom: 8px; line-height: 1.4; }
.menu-item-price { color: var(--primary-light); font-weight: 800; font-size: 1.05rem; }

.add-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
}
.add-btn:hover { transform: scale(1.1); }
.add-btn i { font-size: 1.2rem; }

/* Cart FAB */
.cart-fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: auto;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 14px 22px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
    z-index: 50;
    cursor: pointer;
}
.cart-fab i { font-size: 1.2rem; }
.cart-badge {
    background: white;
    color: var(--primary);
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    padding: 0 6px;
}

/* Cart Modal */
.cart-items { display: flex; flex-direction: column; gap: 12px; max-height: 50vh; overflow-y: auto; }
.cart-item { background: var(--darker); border-radius: 8px; padding: 12px; display: flex; gap: 10px; }
.cart-item-info { flex: 1; }
.cart-item-info strong { display: block; margin-bottom: 4px; }
.cart-item-price { color: var(--light-gray); font-size: 0.85rem; margin-bottom: 6px; }
.cart-item-notes { width: 100%; background: var(--gray); border: 1px solid var(--gray-light); border-radius: 6px; color: white; padding: 6px 8px; font-size: 0.85rem; resize: vertical; min-height: 30px; }
.cart-item-qty { display: flex; align-items: center; gap: 4px; }
.cart-item-qty button { width: 30px; height: 30px; border-radius: 6px; background: var(--gray-light); color: white; }
.cart-item-qty button:hover { background: var(--primary); }
.cart-item-qty span { min-width: 24px; text-align: center; font-weight: 700; }
.cart-remove { background: var(--red) !important; }
.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-top: 16px;
    border-top: 2px solid var(--primary);
    font-size: 1.2rem;
}
.cart-total strong { color: var(--primary-light); }

/* Order tracking */
.track-steps { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.track-step { display: flex; align-items: center; gap: 12px; opacity: 0.4; }
.track-step.done { opacity: 1; }
.track-step.current .track-dot { background: var(--primary); animation: pulse 1.5s infinite; }
.track-dot {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--gray); color: var(--light-gray);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.track-step.done .track-dot { background: var(--success); color: white; }
.track-label { font-weight: 600; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
}

/* Back button in customer view */
.back-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: white;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.2s;
}
.back-btn:hover { background: rgba(255,255,255,0.3); }

.tracking-page-card {
    background: var(--gray);
    border: 1px solid var(--gray-light);
    border-radius: 14px;
    padding: 24px;
    margin-top: 20px;
}

/* ===============================================
   ADMIN / STAFF STYLES
   =============================================== */

.staff-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--darker), var(--dark));
    padding: 20px;
}

.staff-card {
    background: var(--gray);
    border: 1px solid var(--gray-light);
    border-radius: 16px;
    padding: 40px 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}
.staff-card .logo {
    width: 80px; height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: white;
}
.staff-card h1 { text-align: center; color: white; font-size: 1.5rem; margin-bottom: 4px; }
.staff-card .sub { text-align: center; color: var(--light-gray); margin-bottom: 24px; }
.staff-hint { text-align: center; color: var(--light-gray); font-size: 0.85rem; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--gray-light); }
.staff-hint code { background: var(--darker); color: var(--primary-light); padding: 2px 6px; border-radius: 4px; font-family: monospace; }

.admin-app {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas: "topbar topbar" "sidebar main";
    min-height: 100vh;
}

.admin-topbar {
    grid-area: topbar;
    background: var(--gray);
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.admin-topbar h1 { font-size: 1.05rem; font-weight: 800; color: white; }
.admin-topbar .actions { display: flex; align-items: center; gap: 10px; }
.user-info { color: var(--light-gray); font-size: 0.9rem; }

.admin-sidebar {
    grid-area: sidebar;
    background: var(--dark);
    border-left: 1px solid var(--gray-light);
    padding: 16px 0;
}

.admin-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 24px;
    color: var(--light-gray);
    transition: all 0.2s;
    cursor: pointer;
    border-right: 3px solid transparent;
}
.admin-nav .nav-item:hover { background: rgba(231, 76, 60, 0.08); color: white; }
.admin-nav .nav-item.active { background: rgba(231, 76, 60, 0.15); color: var(--primary-light); border-right-color: var(--primary); }
.admin-nav .nav-item i { width: 18px; text-align: center; }

.admin-main { grid-area: main; padding: 24px; overflow-x: hidden; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 1.4rem; font-weight: 800; color: white; }
.page-title small { display: block; font-size: 0.85rem; color: var(--light-gray); font-weight: 400; margin-top: 2px; }

.filter-chip { padding: 7px 14px; background: var(--gray); border: 1px solid var(--gray-light); border-radius: 18px; color: var(--light-gray); font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.filter-chip.active { background: var(--primary); color: white; border-color: var(--primary); }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--light-gray); }
.mb-2 { margin-bottom: 16px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--gray); border: 1px solid var(--gray-light); border-radius: 12px; padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 50px; height: 50px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-icon.green { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.stat-icon.gold { background: linear-gradient(135deg, #f39c12, #d68910); }
.stat-icon.blue { background: linear-gradient(135deg, var(--blue), #2980b9); }
.stat-info .num { font-size: 1.5rem; font-weight: 900; color: white; }
.stat-info .label { font-size: 0.82rem; color: var(--light-gray); }

/* Card */
.card { background: var(--gray); border: 1px solid var(--gray-light); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--gray-light); }
.card-title { color: var(--primary-light); font-weight: 700; font-size: 1rem; }
.card-title i { margin-left: 6px; }

/* Table */
.table-wrap { background: var(--gray); border: 1px solid var(--gray-light); border-radius: 12px; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--darker); color: var(--primary-light); text-align: right; padding: 12px 14px; font-weight: 700; font-size: 0.85rem; border-bottom: 2px solid var(--gray-light); }
td { padding: 11px 14px; border-bottom: 1px solid var(--gray-light); color: white; font-size: 0.88rem; }
tr:hover td { background: rgba(231, 76, 60, 0.04); }
.actions { display: flex; gap: 6px; }

/* Orders */
.orders-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.order-card { background: var(--gray); border: 1px solid var(--gray-light); border-right: 4px solid var(--gray-light); border-radius: 10px; padding: 16px; }
.order-card.status-new { border-right-color: var(--primary); }
.order-card.status-preparing { border-right-color: var(--yellow); }
.order-card.status-ready { border-right-color: var(--success); }
.order-card.status-served { border-right-color: var(--blue); opacity: 0.7; }
.order-card.status-cancelled { border-right-color: var(--red); opacity: 0.5; }
.order-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.order-num { font-size: 1.1rem; font-weight: 800; color: white; }
.status-badge { padding: 4px 10px; border-radius: 12px; font-size: 0.78rem; font-weight: 700; background: var(--gray-light); color: white; }
.status-badge.new { background: var(--primary); }
.status-badge.preparing { background: var(--yellow); color: #000; }
.status-badge.ready { background: var(--success); }
.status-badge.served { background: var(--blue); }
.status-badge.cancelled { background: var(--red); }
.order-items { padding: 10px 0; border-top: 1px solid var(--gray-light); border-bottom: 1px solid var(--gray-light); margin-bottom: 10px; }
.order-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.9rem; }
.order-note { color: var(--light-gray); font-size: 0.78rem; padding-right: 12px; font-style: italic; }
.order-customer-note { background: rgba(243, 156, 18, 0.1); border-right: 3px solid var(--yellow); padding: 8px 10px; margin-bottom: 10px; font-size: 0.88rem; border-radius: 4px; }
.order-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.order-total { font-size: 1.2rem; font-weight: 900; color: var(--primary-light); }
.order-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Kitchen */
.kitchen-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid var(--primary); }
.kitchen-header h1 { color: var(--primary); font-size: 1.4rem; }
.kitchen-header h1 i { margin-left: 8px; }
.kitchen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.kitchen-card { background: var(--gray); border: 2px solid var(--gray-light); border-radius: 10px; padding: 16px; }
.kitchen-card.status-new { border-color: var(--primary); animation: pulse-border 2s infinite; }
.kitchen-card.status-preparing { border-color: var(--yellow); }
@keyframes pulse-border {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
}
.kitchen-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.kitchen-num { font-size: 1.4rem; font-weight: 900; color: var(--primary-light); }
.kitchen-table { color: var(--light-gray); font-size: 0.85rem; }
.kitchen-time { color: var(--light-gray); font-size: 0.85rem; }
.kitchen-items { margin-bottom: 12px; }
.kitchen-line { display: flex; gap: 8px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--gray-light); font-size: 0.95rem; }
.kitchen-line .qty { color: var(--primary-light); font-weight: 800; min-width: 30px; }
.kitchen-note { display: block; color: var(--yellow); font-size: 0.78rem; margin-top: 2px; }

/* Responsive */
@media (max-width: 768px) {
    .admin-app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
    .admin-sidebar { position: fixed; top: 60px; right: 0; width: 240px; height: calc(100vh - 60px); z-index: 100; transform: translateX(100%); transition: transform 0.3s; }
    .admin-sidebar.open { transform: translateX(0); }
    .menu-toggle-mobile { display: block !important; }
    .form-row { grid-template-columns: 1fr; }
    .orders-grid, .kitchen-grid { grid-template-columns: 1fr; }
    .menu-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .container { padding: 12px 10px 100px; }
    .hero h1 { font-size: 1.8rem; }
    .rest-header h1 { font-size: 1.2rem; }
}
.menu-toggle-mobile { display: none; background: none; color: white; padding: 6px 10px; }
