/* ============================================
   Fast Star Delivery - Styles
   ============================================ */
:root {
    --primary: #E8511A;
    --primary-dark: #C9420F;
    --primary-soft: #FDECE4;
    --accent: #FF8A00;
    --gold: #FFD700;
    --success: #10B981;
    --success-soft: #E7F8F1;
    --info: #3B82F6;
    --info-soft: #E8F0FE;
    --warning: #F59E0B;
    --warning-soft: #FFF6E0;
    --danger: #EF4444;
    --danger-soft: #FDECEC;
    --purple: #8B5CF6;
    --navy: #1E293B;

    --bg: #F5F7FB;
    --card: #FFFFFF;
    --text: #111827;
    --muted: #6B7280;
    --border: #E3E8EF;
    --input: #FFFFFF;
    --shadow: 0 4px 18px rgba(17, 24, 39, .06);
    --radius: 20px;
    --radius-sm: 12px;
    --nav-h: 76px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0B1120; --card: #151E2E; --text: #F1F5F9; --muted: #94A3B8; --border: #253247; --input: #0F172A;
        --primary-soft: #3A1F14; --success-soft: #0F2E25; --info-soft: #14233F; --warning-soft: #33280F; --danger-soft: #3A1717;
        --shadow: 0 4px 18px rgba(0, 0, 0, .35);
    }
}
:root[data-theme="dark"] {
    --bg: #0B1120; --card: #151E2E; --text: #F1F5F9; --muted: #94A3B8; --border: #253247; --input: #0F172A;
    --primary-soft: #3A1F14; --success-soft: #0F2E25; --info-soft: #14233F; --warning-soft: #33280F; --danger-soft: #3A1717;
    --shadow: 0 4px 18px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.bold { font-weight: 700; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-info { color: var(--info); }
.text-warning { color: var(--warning); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.nowrap { white-space: nowrap; }

/* ---------- Layout ---------- */
.app {
    max-width: 760px;
    margin: 0 auto;
    padding: 16px 16px calc(var(--nav-h) + 32px);
}
.app.wide { max-width: 1180px; }

@media (min-width: 1100px) {
    body.has-sidenav .app { max-width: 1180px; padding-inline-start: 250px; }
}

/* ---------- Header card ---------- */
.page-header {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.page-header .title-block { min-width: 0; }
.page-header h1 { font-size: 24px; font-weight: 800; }
.page-header .subtitle { color: var(--muted); font-size: 15px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.header-actions::-webkit-scrollbar { display: none; }
.icon-btn {
    width: 46px; height: 46px; min-width: 46px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 17px; font-weight: 800; cursor: pointer;
    font-family: inherit;
    position: relative;
    transition: transform .12s ease, opacity .12s;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.dark { background: var(--navy); color: #fff; border-color: var(--navy); }
.icon-btn.blue { background: var(--info); color: #fff; border-color: var(--info); }
.icon-btn.amber { background: var(--warning); color: #fff; border-color: var(--warning); }
.icon-btn.red { background: var(--danger); color: #fff; border-color: var(--danger); }
.icon-btn .dot {
    position: absolute; top: -3px; inset-inline-end: -3px;
    background: var(--danger); color: #fff; border-radius: 10px;
    font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px;
    display: flex; align-items: center; justify-content: center;
}
@media (max-width: 520px) {
    .page-header { padding: 14px 14px; }
    .page-header h1 { font-size: 20px; }
    .icon-btn { width: 40px; height: 40px; min-width: 40px; font-size: 15px; }
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 736px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 8px 30px rgba(17, 24, 39, .12);
    display: flex;
    justify-content: space-around;
    padding: 8px 6px;
    z-index: 50;
    overflow-x: auto;
    scrollbar-width: none;
}
.bottom-nav::-webkit-scrollbar { display: none; }
.bottom-nav a {
    flex: 1 0 auto;
    min-width: 64px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    padding: 8px 6px;
    color: var(--muted);
    font-size: 12px; font-weight: 600;
    border-radius: 18px;
    position: relative;
    white-space: nowrap;
}
.bottom-nav a i { font-size: 20px; color: var(--muted); }
.bottom-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.bottom-nav a.active i { color: var(--primary); }
.bottom-nav .nav-badge {
    position: absolute; top: 2px; inset-inline-end: 12px;
    background: var(--danger); color: #fff; font-size: 10px; min-width: 17px; height: 17px;
    border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.bottom-nav.many a { min-width: 58px; font-size: 10.5px; }
.bottom-nav.many a i { font-size: 18px; }

@media (min-width: 1100px) {
    body.has-sidenav .bottom-nav {
        top: 16px; bottom: 16px; left: auto; right: auto;
        inset-inline-start: 16px;
        transform: none; width: 214px; max-width: none;
        flex-direction: column; justify-content: flex-start; gap: 4px; padding: 14px 10px;
    }
    body.has-sidenav .bottom-nav a {
        flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px;
        font-size: 14px; padding: 11px 14px;
    }
    body.has-sidenav .bottom-nav a i { width: 22px; text-align: center; }
    body.has-sidenav .bottom-nav .nav-badge { position: static; margin-inline-start: auto; }
    body.has-sidenav .bottom-nav .brand {
        display: flex; align-items: center; gap: 8px; padding: 6px 12px 16px; font-weight: 900; color: var(--primary); font-size: 18px;
    }
}
.bottom-nav .brand { display: none; }

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.card-title {
    font-size: 19px; font-weight: 800; margin-bottom: 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-title .actions { display: flex; gap: 8px; }
.card.compact { padding: 14px 16px; }
.section-title { font-weight: 800; font-size: 16px; margin: 20px 4px 10px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 700px) { .grid-4 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; } }

.stat {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px 16px;
    text-align: start;
    background: var(--card);
}
.stat i { font-size: 20px; color: var(--primary); }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 10px; direction: ltr; unicode-bidi: plaintext; }
.stat .label { color: var(--muted); font-size: 14px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 0; border-radius: 16px;
    padding: 12px 20px;
    font-family: inherit; font-size: 15px; font-weight: 700;
    cursor: pointer;
    background: var(--primary); color: #fff;
    transition: transform .1s, opacity .15s, filter .15s;
    text-align: center;
    min-height: 46px;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn.loading { opacity: .55; pointer-events: none; }
.btn-block { width: 100%; }
.btn-lg { min-height: 58px; font-size: 18px; border-radius: 20px; padding: 14px 26px; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 13px; border-radius: 12px; }
.btn-success { background: var(--success); }
.btn-info { background: var(--info); }
.btn-warning { background: var(--warning); }
.btn-danger { background: var(--danger); }
.btn-dark { background: var(--navy); }
.btn-purple { background: var(--purple); }
.btn-light { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-soft-success { background: var(--success-soft); color: var(--success); }
.btn-soft-info { background: var(--info-soft); color: var(--info); }
.btn-soft-warning { background: var(--warning-soft); color: #B45309; }
.btn-soft-danger { background: var(--danger-soft); color: var(--danger); }
.btn-shadow { box-shadow: 0 8px 20px rgba(16, 185, 129, .3); }
.pill { border-radius: 999px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.btn-row.three { grid-template-columns: 1fr 1fr 1fr; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.input, select.input, textarea.input {
    width: 100%;
    min-height: 50px;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--input);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232, 81, 26, .12); }
.input-icon { position: relative; }
.input-icon i { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: 16px; color: var(--primary); }
.input-icon .input { padding-inline-end: 44px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; } }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; padding: 5px; }
.segmented label { cursor: pointer; }
.segmented input { display: none; }
.segmented span {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    padding: 10px 6px; border-radius: 12px; font-weight: 700; font-size: 14px; color: var(--muted);
}
.segmented span i { font-size: 20px; }
.segmented input:checked + span { background: var(--primary); color: #fff; box-shadow: 0 6px 14px rgba(232, 81, 26, .3); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 999px;
    background: var(--bg); border: 1px solid var(--border);
    font-size: 13px; font-weight: 700; cursor: pointer; color: var(--text);
    user-select: none; font-family: inherit;
}
.chip.active, .chip:has(input:checked) { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip input { display: none; }
.chip.green { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip.orange { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.chip.gray { opacity: .75; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 14px; border-radius: 12px;
    font-size: 13px; font-weight: 700; white-space: nowrap;
}
.badge-pending { background: var(--warning-soft); color: #B45309; }
.badge-picked_up { background: var(--info-soft); color: var(--info); }
.badge-delivered { background: var(--success-soft); color: var(--success); }
.badge-cancelled { background: var(--danger-soft); color: var(--danger); }
.badge-awaiting { background: var(--primary-soft); color: var(--primary); }
.badge-unassigned { background: var(--danger-soft); color: var(--danger); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warning { background: var(--warning-soft); color: #B45309; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Orders ---------- */
.order-card { position: relative; }
.order-card .order-num { font-size: 22px; font-weight: 800; direction: ltr; unicode-bidi: plaintext; }
.order-card .rest-name { color: var(--primary); font-weight: 800; font-size: 18px; }
.order-card .line { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 16px; }
.order-card .line i { width: 18px; text-align: center; color: var(--muted); }
.fee-box {
    background: var(--success-soft); color: var(--success);
    border-radius: 14px; padding: 12px 16px; margin-top: 14px;
    display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px;
}
.fee-box i { font-size: 20px; }
.notice {
    border-radius: 14px; padding: 10px 14px; margin-top: 12px; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; gap: 8px;
}
.notice-warning { background: var(--warning-soft); color: #B45309; }
.notice-success { background: var(--success-soft); color: var(--success); }
.notice-danger { background: var(--danger-soft); color: var(--danger); }
.notice-info { background: var(--info-soft); color: var(--info); }
.notice-muted { background: var(--bg); color: var(--muted); }
.countdown { font-family: ui-monospace, 'SF Mono', Consolas, monospace; direction: ltr; unicode-bidi: isolate; font-weight: 800; }
.order-card.awaiting { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232, 81, 26, .15), var(--shadow); animation: pulse-border 1.6s infinite; }
@keyframes pulse-border { 50% { box-shadow: 0 0 0 6px rgba(232, 81, 26, .08), var(--shadow); } }

.driver-chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 2px; scrollbar-width: thin; }
.driver-chips .chip { flex: 0 0 auto; }

/* ---------- Shift card ---------- */
.shift-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.shift-card h2 { font-size: 22px; font-weight: 800; }
.shift-card .state { font-size: 22px; font-weight: 800; }
.queue-badge { font-size: 28px; font-weight: 900; direction: ltr; }

/* ---------- Lists ---------- */
.list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; }
.avatar { border-radius: 50%; object-fit: cover; flex: 0 0 auto; background: var(--bg); }
.avatar-initial {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary); color: #fff; font-weight: 800; font-size: 18px;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--muted); }
.status-dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: start; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 700; font-size: 13px; }

/* ---------- Notifications ---------- */
.notif { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.notif .n-title { font-size: 18px; font-weight: 800; }
.notif .n-msg { margin-top: 6px; white-space: pre-line; font-size: 15px; }
.notif .n-time { color: var(--muted); font-size: 13px; margin-top: 6px; }
.card.read { opacity: .7; }

/* ---------- Modal ---------- */
.modal {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(15, 23, 42, .6);
    display: none; align-items: flex-end; justify-content: center;
    padding: 0;
}
.modal.open { display: flex; animation: fade .15s ease; }
.modal-box {
    background: var(--card); color: var(--text);
    width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
    border-radius: 24px 24px 0 0;
    padding: 22px 20px 26px;
    animation: slide-up .2s ease;
}
.modal-box.wide { max-width: 900px; }
@media (min-width: 640px) {
    .modal { align-items: center; padding: 20px; }
    .modal-box { border-radius: 24px; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.modal-head h3 { font-size: 20px; font-weight: 800; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(30px); opacity: 0; } }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: calc(100% - 32px); max-width: 460px; pointer-events: none; }
.toast {
    background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-weight: 700; font-size: 14px;
    animation: slide-down .2s ease; pointer-events: auto; white-space: pre-line;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slide-down { from { transform: translateY(-20px); opacity: 0; } }

/* ---------- Maps ---------- */
.map { height: 460px; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); z-index: 1; }
.map.sm { height: 240px; }
.map.lg { height: calc(100vh - 290px); min-height: 420px; }
.leaflet-container { font-family: inherit; }
.driver-marker {
    display: flex; flex-direction: column; align-items: center;
}
.driver-marker .pin {
    width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--primary);
    background: #fff center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, .25);
}
.driver-marker.offline .pin { border-color: #9CA3AF; filter: grayscale(1); }
.driver-marker .name {
    background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 8px; margin-top: 2px; white-space: nowrap;
}

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.login-hero {
    background: linear-gradient(160deg, #FF9A1F, #FF7A00 60%, #F26A00);
    padding: 40px 20px 70px; text-align: center; color: #fff;
}
.login-logo {
    width: 150px; height: 150px; margin: 0 auto; border-radius: 12px; background: #000;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 14px 30px rgba(0, 0, 0, .25);
}
.login-logo .star { font-size: 54px; color: var(--accent); line-height: 1; }
.login-logo .word { color: var(--gold); font-weight: 900; letter-spacing: 2px; font-size: 18px; margin-top: 8px; font-family: 'Barlow', 'Cairo', sans-serif; }
.login-hero h1 { font-size: 28px; font-weight: 900; margin-top: 18px; }
.login-hero p { opacity: .9; margin: 2px 0 0; }
.login-sheet {
    flex: 1; background: var(--bg); margin-top: -40px; border-radius: 32px 32px 0 0;
    padding: 24px 20px 30px; width: 100%; max-width: 520px; align-self: center;
}
.login-footer { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty i { font-size: 36px; opacity: .5; display: block; margin-bottom: 8px; }
.search-results { max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 14px; margin-top: 6px; background: var(--card); }
.search-results .opt { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.search-results .opt:hover, .search-results .opt.focus { background: var(--primary-soft); }
.search-results .opt:last-child { border-bottom: 0; }
.img-drop {
    border: 2px dashed var(--border); border-radius: 16px; padding: 16px; text-align: center; cursor: pointer; color: var(--muted);
    display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 90px;
}
.img-drop img { max-height: 90px; border-radius: 12px; }
.zone-group-title { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--primary); margin: 18px 4px 8px; }
.sound-banner {
    position: fixed; bottom: calc(var(--nav-h) + 24px); left: 50%; transform: translateX(-50%);
    background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 14px; z-index: 60; font-weight: 700; cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-size: 14px; white-space: nowrap;
}
.bar { height: 10px; border-radius: 6px; background: var(--primary); }
.bar-track { background: var(--bg); border-radius: 6px; overflow: hidden; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media print { .bottom-nav, .header-actions, .no-print { display: none !important; } .app { padding: 0; } }
.btn-row .btn { white-space: nowrap; font-size: 14px; padding-inline: 12px; }
