/* ===================================================================
   مطبعة المجد — shared theme
   Light is the default; [data-theme="dark"] swaps the token values and
   nothing else. Every surface, border and fill below reads from a token,
   so a theme is defined in exactly one place.
   =================================================================== */

:root,
:root[data-theme="light"] {
    --bg: #f5f7fb;
    --bg-glow-1: rgba(79, 70, 229, .07);
    --bg-glow-2: rgba(13, 148, 136, .06);
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --header-bg: rgba(255, 255, 255, .85);
    --line: rgba(15, 23, 42, .11);
    --line-strong: rgba(15, 23, 42, .2);
    --fill-1: rgba(15, 23, 42, .04);
    --fill-2: rgba(15, 23, 42, .08);
    --text: #0f172a;
    --muted: #64748b;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);

    --brand: #4f46e5;
    --brand-ink: #ffffff;
    --brand-soft: rgba(79, 70, 229, .1);
    --brand-soft-text: #4338ca;

    --amber: #b45309;
    --amber-soft: rgba(180, 83, 9, .1);
    --amber-line: rgba(180, 83, 9, .28);
    --emerald: #047857;
    --emerald-soft: rgba(4, 120, 87, .1);
    --emerald-line: rgba(4, 120, 87, .28);
    --rose: #e11d48;
    --rose-soft: rgba(225, 29, 72, .09);
    --rose-line: rgba(225, 29, 72, .28);

    /* delivery urgency */
    --rush: #dc2626;
    --rush-soft: rgba(220, 38, 38, .1);
    --rush-line: rgba(220, 38, 38, .45);
    --rush-glow: rgba(220, 38, 38, .38);
    --urgent: #a16207;
    --urgent-soft: rgba(202, 138, 4, .13);
    --urgent-line: rgba(202, 138, 4, .5);
    --urgent-glow: rgba(202, 138, 4, .34);
}

:root[data-theme="dark"] {
    --bg: #0b1220;
    --bg-glow-1: rgba(99, 102, 241, .1);
    --bg-glow-2: rgba(45, 212, 191, .06);
    --surface: #131c2e;
    --surface-2: #1a2439;
    --header-bg: rgba(11, 18, 32, .85);
    --line: rgba(148, 163, 184, .16);
    --line-strong: rgba(148, 163, 184, .28);
    --fill-1: rgba(255, 255, 255, .05);
    --fill-2: rgba(255, 255, 255, .09);
    --text: #e6edf7;
    --muted: #93a4bd;
    --shadow: none;

    --brand: #6366f1;
    --brand-ink: #ffffff;
    --brand-soft: rgba(99, 102, 241, .16);
    --brand-soft-text: #c7d2fe;

    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, .12);
    --amber-line: rgba(251, 191, 36, .3);
    --emerald: #34d399;
    --emerald-soft: rgba(52, 211, 153, .12);
    --emerald-line: rgba(52, 211, 153, .3);
    --rose: #fb7185;
    --rose-soft: rgba(251, 113, 133, .12);
    --rose-line: rgba(251, 113, 133, .32);

    /* delivery urgency */
    --rush: #f87171;
    --rush-soft: rgba(248, 113, 113, .14);
    --rush-line: rgba(248, 113, 113, .5);
    --rush-glow: rgba(248, 113, 113, .45);
    --urgent: #facc15;
    --urgent-soft: rgba(250, 204, 21, .14);
    --urgent-line: rgba(250, 204, 21, .5);
    --urgent-glow: rgba(250, 204, 21, .38);
}

body {
    background:
        radial-gradient(1200px 600px at 85% -10%, var(--bg-glow-1), transparent 60%),
        radial-gradient(900px 500px at 0% 0%, var(--bg-glow-2), transparent 55%),
        var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, "Noto Naskh Arabic", sans-serif;
}

/* Elements carrying a category accent resolve --cat for the active theme. */
.has-cat { --cat: var(--cat-light); --cat-rgb: var(--cat-light-rgb); }
:root[data-theme="dark"] .has-cat { --cat: var(--cat-dark); --cat-rgb: var(--cat-dark-rgb); }

/* ---- surfaces ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}
.inset {
    background: var(--fill-1);
    border: 1px solid var(--line);
    border-radius: 12px;
}

/* ---- order card ---- */
.order-card {
    position: relative;
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-inline-start: 4px solid var(--cat, var(--muted));
    border-radius: 16px;
    padding: 1rem;
    box-shadow: var(--shadow);
    transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.order-card:hover {
    transform: translateY(-2px);
    background: var(--surface-2);
    border-color: var(--line-strong);
    border-inline-start-color: var(--cat, var(--muted));
}
.order-card.is-done { opacity: .62; }
.order-card.is-done:hover { opacity: 1; }

/* ---- badges & chips ---- */
.badge {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    font-size: .78rem; font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge::before {
    content: ""; width: .45rem; height: .45rem; border-radius: 999px;
    background: currentColor;
}
.badge-working { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.badge-done { color: var(--emerald); background: var(--emerald-soft); border-color: var(--emerald-line); }
.badge-idle { color: var(--muted); background: var(--fill-2); border-color: var(--line); }

.chip {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .3rem .6rem;
    border-radius: 10px;
    font-size: .8rem;
    background: var(--fill-1);
    border: 1px solid var(--line);
    color: var(--text);
}
.chip .chip-label { color: var(--muted); }

.cat-pill {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    font-size: .78rem; font-weight: 600;
    color: var(--cat);
    background: rgba(var(--cat-rgb), .11);
    border: 1px solid rgba(var(--cat-rgb), .3);
}

/* ---- delivery urgency badge ----------------------------------------
   Only فوري and مستعجل glow. عادي stays a plain chip on purpose: if every
   card glowed, the glow would stop meaning anything. */
.delivery {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .3rem .65rem;
    border-radius: 10px;
    font-size: .8rem; font-weight: 700;
    background: var(--fill-1);
    border: 1px solid var(--line);
    color: var(--text);
}
.delivery .delivery-label { color: var(--muted); font-weight: 500; }

.delivery-immediate,
.delivery-urgent { position: relative; }
.delivery-immediate::before,
.delivery-urgent::before {
    content: ""; width: .45rem; height: .45rem; border-radius: 999px;
    background: currentColor; flex: none;
}

.delivery-immediate {
    color: var(--rush);
    background: var(--rush-soft);
    border-color: var(--rush-line);
    animation: glow-rush 1.7s ease-in-out infinite;
}
.delivery-immediate .delivery-label { color: var(--rush); opacity: .75; }

.delivery-urgent {
    color: var(--urgent);
    background: var(--urgent-soft);
    border-color: var(--urgent-line);
    animation: glow-urgent 2.4s ease-in-out infinite;
}
.delivery-urgent .delivery-label { color: var(--urgent); opacity: .8; }

@keyframes glow-rush {
    0%, 100% { box-shadow: 0 0 5px 0 var(--rush-glow); }
    50%      { box-shadow: 0 0 15px 4px var(--rush-glow); }
}
@keyframes glow-urgent {
    0%, 100% { box-shadow: 0 0 4px 0 var(--urgent-glow); }
    50%      { box-shadow: 0 0 12px 3px var(--urgent-glow); }
}

@media (prefers-reduced-motion: reduce) {
    .delivery-immediate { animation: none; box-shadow: 0 0 10px 1px var(--rush-glow); }
    .delivery-urgent { animation: none; box-shadow: 0 0 8px 1px var(--urgent-glow); }
}

/* ---- progress ---- */
.progress { height: 6px; border-radius: 999px; background: var(--fill-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--cat, var(--brand)); }

/* ---- buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem .95rem;
    border-radius: 11px;
    font-weight: 600; font-size: .9rem;
    border: 1px solid var(--line);
    background: var(--fill-1);
    color: var(--text);
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--fill-2); border-color: var(--line-strong); }
.btn-primary { background: var(--brand); border-color: transparent; color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); border-color: transparent; }
.btn-go { background: var(--emerald-soft); border-color: var(--emerald-line); color: var(--emerald); }
.btn-go:hover { background: var(--emerald-soft); filter: brightness(.97); }
.btn-warn { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber); }
.btn-warn:hover { background: var(--amber-soft); filter: brightness(.97); }
.btn-danger { background: var(--rose-soft); border-color: var(--rose-line); color: var(--rose); }
.btn-danger:hover { background: var(--rose-soft); filter: brightness(.97); }
.btn-lg { padding: .75rem 1.1rem; font-size: 1rem; border-radius: 12px; }
.btn-icon { padding: .55rem .7rem; }

/* segmented control for the order filters */
.segment {
    display: inline-flex; padding: 3px; gap: 3px;
    background: var(--fill-1); border: 1px solid var(--line); border-radius: 12px;
}
.segment a { padding: .45rem .85rem; border-radius: 9px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.segment a:hover { color: var(--text); }
.segment a.is-active {
    background: var(--brand-soft);
    color: var(--brand-soft-text);
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .3);
}

/* ---- form fields ---- */
.field {
    width: 100%;
    padding: .55rem .7rem;
    border-radius: 11px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    color: var(--text);
    outline: none;
}
.field::placeholder { color: var(--muted); opacity: .8; }
.field:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field option { background: var(--surface); color: var(--text); }
.label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .3rem; }

/* ---- notes ---- */
.note {
    border-radius: 12px;
    padding: .55rem .7rem;
    font-size: .85rem;
    background: var(--amber-soft);
    border: 1px solid var(--amber-line);
    color: var(--amber);
}
.note-general {
    background: var(--brand-soft);
    border-color: rgba(79, 70, 229, .28);
    color: var(--brand-soft-text);
}
.alert { border-radius: 12px; padding: .55rem .7rem; font-size: .88rem;
         background: var(--rose-soft); border: 1px solid var(--rose-line); color: var(--rose); }

.muted { color: var(--muted); }
.dot { width: .6rem; height: .6rem; border-radius: 999px; flex: none; }
summary::-webkit-details-marker { display: none; }

/* ---- theme toggle: show the theme you would switch TO ---- */
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---- print ---- */
.print-only { display: none; }
@media print {
    body { background: #fff !important; color: #000; }
    .no-print { display: none !important; }
    .print-only { display: block; }
    .print-receipt { width: 80mm; margin: 0 auto; }
    a { color: #000; text-decoration: none; }
}
