/* ==================== VARIABLES ==================== */
:root {
    --pri: #4f46e5;
    --pri-h: #4338ca;
    --pri-l: #eef2ff;
    --bg: #f5f6fa;
    --bg2: #ffffff;
    --bg3: #eef0f5;
    --text: #1a1a2e;
    --text2: #555770;
    --border: #e2e5ed;
    --shadow: 0 2px 12px rgba(0,0,0,.08);
    --shadow-h: 0 8px 24px rgba(79,70,229,.15);
    --radius: 12px;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

[data-theme="dark"] {
    --bg: #0f0f1a;
    --bg2: #1a1a2e;
    --bg3: #252540;
    --text: #e8e8f0;
    --text2: #9999b8;
    --border: #2d2d4e;
    --shadow: 0 2px 12px rgba(0,0,0,.4);
    --shadow-h: 0 8px 24px rgba(99,102,241,.25);
    --pri-l: #1e1b4b;
}

/* ==================== RESET ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    transition: background .3s, color .3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
ul { list-style: none; }

/* ==================== NAVBAR ==================== */
.navbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow);
}
.nav-container {
    max-width: 1200px; margin: 0 auto;
    padding: 12px 20px;
    display: flex; align-items: center; gap: 16px;
}
.nav-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-text { font-size: 1.2rem; font-weight: 800; color: var(--pri); }
.nav-search { flex: 1; max-width: 400px; }
.search-wrap { display: flex; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; transition: border-color .2s; }
.search-wrap:focus-within { border-color: var(--pri); }
.search-wrap input {
    flex: 1; padding: 9px 14px; border: none; outline: none;
    background: var(--bg3); color: var(--text); font-family: inherit; font-size: .9rem;
}
.search-wrap button {
    background: var(--pri); color: #fff; border: none;
    padding: 0 14px; cursor: pointer; transition: background .2s;
}
.search-wrap button:hover { background: var(--pri-h); }
.nav-actions { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.nav-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px; border: none;
    background: var(--bg3); color: var(--text);
    cursor: pointer; font-size: .9rem; font-weight: 600;
    font-family: inherit; transition: all .2s; position: relative;
}
.nav-btn:hover { background: var(--border); }
.cart-btn { background: var(--pri); color: #fff; }
.cart-btn:hover { background: var(--pri-h); }
.cart-badge {
    position: absolute; top: -6px; right: -6px;
    background: #ef4444; color: #fff; border-radius: 50%;
    width: 18px; height: 18px; font-size: .7rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.login-btn { background: transparent; border: 1.5px solid var(--pri); color: var(--pri); }
.login-btn:hover { background: var(--pri-l); }
.theme-btn { padding: 8px 10px; }
.nav-user { position: relative; }
.user-dropdown {
    display: none; position: absolute; top: calc(100% + 6px); left: 0;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-h);
    min-width: 160px; z-index: 200; overflow: hidden;
}
.user-dropdown.show { display: block; }
.user-dropdown a {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px; font-size: .88rem; color: var(--text);
    transition: background .15s;
}
.user-dropdown a:hover { background: var(--bg3); }
.logout-link { color: var(--danger) !important; }
.d-none-mobile { display: none; }
@media(min-width:640px) { .d-none-mobile { display: inline; } }

/* ==================== MAIN ==================== */
.main-content { flex: 1; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.page-section { padding: 40px 0; }

/* ==================== HERO ==================== */
.hero {
    background: linear-gradient(135deg, var(--pri) 0%, #7c3aed 100%);
    padding: 60px 20px; text-align: center; color: #fff;
    position: relative; overflow: hidden;
}
.hero::before {
    content: ''; position: absolute; inset: 0;
    background: url('') center/cover; opacity: .12;
}
.hero-content { position: relative; z-index: 1; max-width: 600px; margin: 0 auto; }
.hero h1 { font-size: clamp(1.8rem,5vw,2.8rem); font-weight: 800; margin-bottom: 12px; }
.hero p  { font-size: 1rem; opacity: .85; margin-bottom: 24px; }
.hero-btns { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ==================== CATEGORIES BAR ==================== */
.cats-bar {
    background: var(--bg2); border-bottom: 1px solid var(--border);
    padding: 14px 20px; display: flex; gap: 10px;
    overflow-x: auto; scrollbar-width: none;
}
.cats-bar::-webkit-scrollbar { display: none; }
.cat-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 18px; border-radius: 24px; white-space: nowrap;
    font-size: .86rem; font-weight: 600; cursor: pointer;
    border: 1.5px solid var(--border); background: var(--bg3); color: var(--text2);
    transition: all .2s;
}
.cat-pill:hover, .cat-pill.active {
    background: var(--pri); color: #fff; border-color: var(--pri);
}

/* ==================== PRODUCTS GRID ==================== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px; padding: 24px 20px;
    max-width: 1200px; margin: 0 auto;
}
.product-card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    transition: all .25s; box-shadow: var(--shadow);
    display: flex; flex-direction: column; position: relative;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-h); }
.product-card img { width: 100%; height: 180px; object-fit: cover; }
.product-img-placeholder {
    width: 100%; height: 180px; background: var(--bg3);
    display: flex; align-items: center; justify-content: center;
    font-size: 2.5rem; color: var(--text2);
}
.product-badge {
    position: absolute; top: 10px; right: 10px;
    background: var(--pri); color: #fff;
    font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px;
}
.product-body { padding: 14px; flex: 1; display: flex; flex-direction: column; }
.product-name { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.product-desc { font-size: .82rem; color: var(--text2); flex: 1; line-height: 1.5; margin-bottom: 14px; }
.product-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.product-price { font-size: 1rem; font-weight: 700; color: var(--pri); }
.product-price-old { font-size: .78rem; color: var(--text2); text-decoration: line-through; }

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: 8px; border: none;
    font-family: inherit; font-size: .9rem; font-weight: 700;
    cursor: pointer; transition: all .2s; white-space: nowrap;
}
.btn-pri { background: var(--pri); color: #fff; }
.btn-pri:hover { background: var(--pri-h); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--pri); border: 1.5px solid var(--pri); }
.btn-outline:hover { background: var(--pri-l); }
.btn-ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }
.btn-light { background: rgba(255,255,255,.15); color: #fff; border: 1.5px solid rgba(255,255,255,.5); }
.btn-light:hover { background: rgba(255,255,255,.25); }

/* ==================== FORMS ==================== */
.form-card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow);
}
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; font-size: .88rem; font-weight: 700;
    color: var(--text); margin-bottom: 7px;
}
.form-control {
    width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
    border-radius: 8px; background: var(--bg3); color: var(--text);
    font-family: inherit; font-size: .9rem; outline: none; transition: border-color .2s;
}
.form-control:focus { border-color: var(--pri); }
.form-control.error { border-color: var(--danger); }
.error-msg { color: var(--danger); font-size: .8rem; margin-top: 4px; display: block; }
.form-divider { text-align: center; margin: 16px 0; color: var(--text2); font-size: .88rem; position: relative; }
.form-divider::before { content:''; position:absolute; top:50%; right:0; width:42%; height:1px; background:var(--border); }
.form-divider::after  { content:''; position:absolute; top:50%; left:0; width:42%; height:1px; background:var(--border); }

/* ==================== CART ==================== */
.cart-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 0; border-bottom: 1px solid var(--border);
}
.cart-item img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.cart-item-img-placeholder {
    width: 64px; height: 64px; border-radius: 8px;
    background: var(--bg3); display: flex; align-items: center;
    justify-content: center; color: var(--text2); font-size: 1.4rem; flex-shrink: 0;
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 700; font-size: .95rem; color: var(--text); margin-bottom: 4px; }
.cart-item-price { font-size: .85rem; color: var(--text2); }
.cart-item-note { font-size: .75rem; color: var(--text2); margin-top: 3px; font-style: italic; }
.qty-ctrl { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.qty-btn {
    width: 30px; height: 30px; border-radius: 8px;
    border: 1.5px solid var(--border); background: var(--bg3); color: var(--text);
    cursor: pointer; font-size: 1rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.qty-btn:hover { background: var(--pri); color: #fff; border-color: var(--pri); }
.qty-num { font-weight: 700; font-size: 1rem; min-width: 28px; text-align: center; color: var(--text); }
.cart-total-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 0; border-top: 2px solid var(--border); margin-top: 8px;
    font-size: 1.1rem; font-weight: 700;
}
.cart-total-amount { color: var(--pri); font-size: 1.3rem; }

/* ==================== ORDER TYPE ==================== */
.order-types { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.order-type-card {
    border: 2px solid var(--border); border-radius: 10px;
    padding: 14px 10px; text-align: center; cursor: pointer; transition: all .2s;
    background: var(--bg3);
}
.order-type-card:hover { border-color: var(--pri); }
.order-type-card.selected { border-color: var(--pri); background: var(--pri-l); }
.order-type-card.selected .ot-icon { color: var(--pri); }
.order-type-card.selected .ot-label { color: var(--pri); font-weight: 700; }
.ot-icon { font-size: 1.4rem; display: block; margin-bottom: 6px; color: var(--text2); transition: color .2s; }
.ot-label { font-size: .82rem; font-weight: 600; color: var(--text); display: block; }
.ot-sub { font-size: .72rem; color: var(--text2); margin-top: 2px; }

/* ==================== STATUS TIMELINE ==================== */
.timeline { display: flex; justify-content: space-between; margin: 24px 0; position: relative; }
.timeline::before { content:''; position:absolute; top:18px; right:8%; left:8%; height:3px; background:var(--border); z-index:0; }
.tl-step { text-align: center; flex: 1; position: relative; z-index: 1; }
.tl-icon {
    width: 38px; height: 38px; border-radius: 50%; margin: 0 auto;
    background: var(--bg3); border: 3px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem; color: var(--text2); transition: all .3s;
}
.tl-step.done .tl-icon   { background: var(--success); border-color: var(--success); color: #fff; }
.tl-step.active .tl-icon { background: var(--pri); border-color: var(--pri); color: #fff; box-shadow: 0 0 0 4px var(--pri-l); }
.tl-label { font-size: .72rem; margin-top: 6px; color: var(--text2); }
.tl-step.done .tl-label, .tl-step.active .tl-label { color: var(--text); font-weight: 700; }

/* ==================== ALERTS ==================== */
.alert { padding: 14px 16px; border-radius: 8px; display: flex; align-items: flex-start; gap: 10px; font-size: .9rem; margin-bottom: 16px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }
[data-theme="dark"] .alert-success { background: #022c22; color: #34d399; border-color: #065f46; }
[data-theme="dark"] .alert-danger  { background: #450a0a; color: #f87171; border-color: #991b1b; }
[data-theme="dark"] .alert-info    { background: #1e3a5f; color: #93c5fd; border-color: #1d4ed8; }

/* ==================== STATUS BADGES ==================== */
.status-badge { display:inline-flex; align-items:center; gap:5px; padding:4px 12px; border-radius:20px; font-size:.8rem; font-weight:700; }
.status-pending   { background:#fff3cd; color:#856404; }
.status-preparing { background:#cff4fc; color:#055160; }
.status-ready     { background:#d1e7dd; color:#0a3622; }
.status-completed { background:#cfe2ff; color:#084298; }
.status-cancelled { background:#f8d7da; color:#842029; }
[data-theme="dark"] .status-pending   { background:#3d2e00; color:#fbbf24; }
[data-theme="dark"] .status-preparing { background:#082f49; color:#38bdf8; }
[data-theme="dark"] .status-ready     { background:#052e16; color:#34d399; }
[data-theme="dark"] .status-completed { background:#1e1b4b; color:#818cf8; }
[data-theme="dark"] .status-cancelled { background:#450a0a; color:#f87171; }

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 300; opacity: 0; pointer-events: none; transition: opacity .3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%,-60%);
    width: 90%; max-width: 480px; background: var(--bg2);
    border-radius: 16px; z-index: 301; opacity: 0; pointer-events: none;
    transition: all .3s; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal.open { opacity: 1; pointer-events: all; transform: translate(-50%,-50%); }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ==================== TOAST ==================== */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
    background: var(--text); color: var(--bg2);
    padding: 12px 24px; border-radius: 10px; font-weight: 600; font-size: .9rem;
    z-index: 500; opacity: 0; transition: all .3s; white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: var(--success); color: #fff; }
.toast.danger  { background: var(--danger);  color: #fff; }

/* ==================== PAGE TITLES ==================== */
.page-header { padding: 28px 20px 0; max-width: 1200px; margin: 0 auto; }
.page-header h1 { font-size: 1.5rem; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.page-header p  { color: var(--text2); font-size: .9rem; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text2); margin-bottom: 8px; }
.breadcrumb a { color: var(--pri); }

/* ==================== TABLE ==================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--bg3); color: var(--text2); font-size: .82rem; padding: 10px 14px; text-align: right; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); font-size: .9rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ==================== EMPTY STATE ==================== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text2); }
.empty-state i { font-size: 3rem; margin-bottom: 14px; display: block; opacity: .5; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }
.empty-state p  { font-size: .9rem; margin-bottom: 20px; }

/* ==================== FOOTER ==================== */
.footer { background: var(--bg2); border-top: 1px solid var(--border); padding: 48px 20px 20px; margin-top: auto; }
.footer-container { max-width: 1200px; margin: 0 auto; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 32px; margin-bottom: 32px; }
.footer-brand { font-size: 1.2rem; font-weight: 800; color: var(--pri); margin-bottom: 10px; }
.footer-col h4 { font-size: .95rem; font-weight: 700; color: var(--text); margin-bottom: 14px; }
.footer-col p, .footer-col li { font-size: .88rem; color: var(--text2); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.footer-col a { color: var(--text2); transition: color .2s; }
.footer-col a:hover { color: var(--pri); }
.social-links { display: flex; gap: 10px; margin-top: 14px; }
.social-links a {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg3); color: var(--text2); font-size: 1rem; transition: all .2s;
}
.social-links a:hover { transform: translateY(-2px); }
.social-wa:hover { background: #25d366; color: #fff !important; }
.social-ig:hover { background: #e4405f; color: #fff !important; }
.social-fb:hover { background: #1877f2; color: #fff !important; }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 20px; text-align: center; font-size: .82rem; color: var(--text2); }

/* ==================== RESPONSIVE ==================== */
@media(max-width:768px) {
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(155px,1fr)); gap: 12px; padding: 14px 12px; }
    .nav-search { display: none; }
    .order-types { grid-template-columns: 1fr 1fr 1fr; }
    .cats-bar { padding: 10px 12px; }
}
@media(max-width:480px) {
    .hero { padding: 40px 16px; }
    .order-types { grid-template-columns: 1fr 1fr; }
}
