/* =========================================================
   ZantexZone Design System
   Shared, mobile-first component styles that sit on top of
   the Tailwind CDN utility classes already used across the app.
   Keep this framework-free and dependency-free (plain CSS vars).
========================================================= */

:root {
  --zx-orange: #d9942a;
  --zx-orange-dark: #b9791b;
  --zx-teal: #16a596;
  --zx-ink: #0f172a;      /* slate-900 */
  --zx-body: #334155;     /* slate-700 */
  --zx-muted: #64748b;    /* slate-500 */
  --zx-border: #e2e8f0;   /* slate-200 */
  --zx-bg: #f4f6f9;
  --zx-success: #16a34a;
  --zx-success-bg: #f0fdf4;
  --zx-error: #dc2626;
  --zx-error-bg: #fef2f2;
  --zx-warn: #d97706;
  --zx-warn-bg: #fffbeb;
  --zx-radius: 14px;
  --zx-radius-sm: 8px;
  --zx-tap: 44px; /* minimum comfortable touch target */
}

html, body { background: var(--zx-bg); color: var(--zx-body); }

/* ---------- Buttons (touch-friendly, min 44px tall) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--zx-tap);
  padding: .6rem 1.1rem;
  border-radius: var(--zx-radius-sm);
  font-weight: 600;
  font-size: .925rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--zx-ink); color: #fff; }
.btn-primary:hover { background: #1e293b; }
.btn-accent { background: var(--zx-orange); color: #fff; }
.btn-accent:hover { background: var(--zx-orange-dark); }
.btn-outline { background: #fff; color: var(--zx-ink); border-color: var(--zx-border); }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background: var(--zx-error-bg); color: var(--zx-error); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: .4rem .75rem; font-size: .825rem; }

/* ---------- Form controls ---------- */
.field-label { display: block; font-size: .8rem; font-weight: 600; color: var(--zx-muted); margin-bottom: .3rem; }
.input, select.input, textarea.input {
  width: 100%;
  min-height: var(--zx-tap);
  padding: .55rem .8rem;
  border: 1px solid var(--zx-border);
  border-radius: var(--zx-radius-sm);
  font-size: 1rem;
  background: #fff;
  color: var(--zx-ink);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none; border-color: var(--zx-orange);
  box-shadow: 0 0 0 3px rgba(217,148,42,.18);
}

/* ---------- Searchable selects ---------- */
.zx-select { position: relative; width: 100%; }
.zx-select-input { padding-right: 2.5rem; }
.zx-select-menu { position: absolute; left: 0; right: 0; top: calc(100% + .25rem); z-index: 60; max-height: min(18rem, 48vh); overflow-y: auto; background: #fff; border: 1px solid var(--zx-border); border-radius: var(--zx-radius-sm); box-shadow: 0 12px 28px rgba(15,23,42,.16); }
.zx-select-option { display: block; width: 100%; min-height: var(--zx-tap); padding: .65rem .8rem; text-align: left; background: #fff; border: 0; border-bottom: 1px solid #f1f5f9; color: var(--zx-ink); cursor: pointer; }
.zx-select-option:hover, .zx-select-option:focus { background: #fff7ed; color: #9a3412; outline: 0; }
.zx-select-empty { padding: .8rem; color: var(--zx-muted); font-size: .875rem; }

/* ---------- Notification bell ---------- */
.zx-notification-wrap { position: relative; }
.zx-notification-bell { position: relative; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 1px solid var(--zx-border); border-radius: 50%; background: #fff; font-size: 1.1rem; cursor: pointer; }
.zx-notification-bell:hover { background: #fff7ed; }
.zx-notification-count { position: absolute; top: -.2rem; right: -.2rem; min-width: 1.1rem; height: 1.1rem; padding: 0 .25rem; border-radius: 999px; background: var(--zx-error); color: #fff; font-size: .65rem; line-height: 1.1rem; text-align: center; }
.zx-notification-panel { position: absolute; top: calc(100% + .6rem); right: 0; z-index: 70; width: min(22rem, calc(100vw - 2rem)); max-height: 26rem; overflow-y: auto; background: #fff; border: 1px solid var(--zx-border); border-radius: var(--zx-radius); box-shadow: 0 16px 40px rgba(15,23,42,.2); }
.zx-notification-heading { padding: .85rem 1rem; font-weight: 700; color: var(--zx-ink); border-bottom: 1px solid var(--zx-border); }
.zx-notification-item { display: block; padding: .75rem 1rem; color: var(--zx-body); text-decoration: none; border-bottom: 1px solid #f1f5f9; }
.zx-notification-item:hover, .zx-notification-item.is-unread { background: #fff7ed; }
.zx-notification-item strong, .zx-notification-item span, .zx-notification-item small { display: block; }
.zx-notification-item strong { color: var(--zx-ink); font-size: .85rem; }
.zx-notification-item span { margin-top: .2rem; font-size: .8rem; }
.zx-notification-item small { margin-top: .35rem; color: var(--zx-muted); font-size: .7rem; }
.zx-notification-empty { padding: 1rem; color: var(--zx-muted); font-size: .85rem; text-align: center; }

/* ---------- Mobile form ergonomics ---------- */
form { max-width: 100%; }
input, select, textarea, button { max-width: 100%; }
input[type="number"], input[type="date"], input[type="time"] { min-height: var(--zx-tap); }
@media (max-width: 640px) {
  form .grid, form .flex { min-width: 0; }
  form button, form input[type="submit"] { min-height: 46px; }
  .zx-notification-panel { position: fixed; top: 4.2rem; right: .75rem; }
}

/* ---------- Visual refinement layer ---------- */
body {
  background: #eef2f6;
  background-image: radial-gradient(circle at 12% 0%, rgba(217,148,42,.08), transparent 28rem), linear-gradient(135deg, #f8fafc 0%, #eef2f6 62%, #e7edf2 100%);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .22; background-image: linear-gradient(rgba(15,23,42,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(15,23,42,.035) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(to bottom, black, transparent 70%); }
.bg-white { background: rgba(255,255,255,.94) !important; }
.card, .dashboard-shortcut { box-shadow: 0 10px 30px rgba(15,23,42,.06); }
.card:hover, .dashboard-shortcut:hover { box-shadow: 0 14px 34px rgba(15,23,42,.1); }
.dashboard-shell { position: relative; }
.dashboard-hero { padding: 1.25rem 1.35rem; border: 1px solid rgba(255,255,255,.8); border-radius: 1.2rem; background: linear-gradient(120deg, #fffaf1, #ffffff 54%, #eaf8f5); box-shadow: 0 10px 30px rgba(15,23,42,.06); }
.dashboard-actions { padding: .8rem; border: 1px solid rgba(255,255,255,.9); border-radius: 1rem; background: rgba(255,255,255,.62); }
.dashboard-shortcuts { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.dashboard-shortcut { position: relative; overflow: hidden; }
.dashboard-shortcut::after { content: "→"; position: absolute; right: .85rem; bottom: .75rem; color: var(--zx-orange-dark); font-size: 1.1rem; transition: transform .15s ease; }
.dashboard-shortcut:hover::after { transform: translateX(4px); }
.dashboard-shortcut-icon { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: .75rem; background: #fff3df; }
.btn { box-shadow: 0 4px 10px rgba(15,23,42,.08); }
.btn-primary, .btn-accent { box-shadow: 0 7px 16px rgba(15,23,42,.16); }
.zx-table tr { transition: background .15s ease; }
.zx-table tbody tr:hover { background: #fffaf3; }

/* The native select remains in the form for submission/accessibility, while the
   visible search control and menu handle the richer interaction. */
.zx-select { display: block; min-width: 0; }
.zx-select-input { display: block !important; position: relative; z-index: 1; }
.zx-select-menu[hidden] { display: none !important; }
.zx-select-menu:not([hidden]) { display: block !important; }
.zx-select-option { display: flex !important; align-items: center; min-height: 2.9rem; line-height: 1.25; white-space: normal; }
.zx-select-option::before { content: ""; flex: 0 0 .45rem; width: .45rem; height: .45rem; margin-right: .65rem; border-radius: 50%; background: var(--zx-orange); }
.zx-select-option:first-child::before { background: var(--zx-teal); }
.zx-select-empty { display: block !important; }

@media (max-width: 767px) {
  .dashboard-shortcuts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-hero { padding: 1rem; }
  .dashboard-title { font-size: 1.45rem; }
}

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--zx-border);
  border-radius: var(--zx-radius);
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.card-pad { padding: 1.1rem; }
.card-title { font-weight: 700; font-size: 1rem; color: var(--zx-ink); margin-bottom: .75rem; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-success { background: var(--zx-success-bg); color: var(--zx-success); }
.badge-error { background: var(--zx-error-bg); color: var(--zx-error); }
.badge-warn { background: var(--zx-warn-bg); color: var(--zx-warn); }
.badge-muted { background: #f1f5f9; color: var(--zx-muted); }

/* ---------- Alerts / flash messages ---------- */
.alert { padding: .8rem 1rem; border-radius: var(--zx-radius-sm); border: 1px solid transparent; font-size: .9rem; margin-bottom: .9rem; }
.alert-success { background: var(--zx-success-bg); color: var(--zx-success); border-color: #bbf7d0; }
.alert-error { background: var(--zx-error-bg); color: var(--zx-error); border-color: #fecaca; }
.alert-muted { background: #f8fafc; color: var(--zx-body); border-color: var(--zx-border); }

/* ---------- Responsive tables: cards on mobile, table on desktop ---------- */
.zx-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.zx-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--zx-muted); padding: .6rem .5rem; border-bottom: 1px solid var(--zx-border); }
.zx-table td { padding: .65rem .5rem; border-bottom: 1px solid var(--zx-border); }

@media (max-width: 640px) {
  .zx-table--stack thead { display: none; }
  .zx-table--stack, .zx-table--stack tbody, .zx-table--stack tr, .zx-table--stack td { display: block; width: 100%; }
  .zx-table--stack tr { border: 1px solid var(--zx-border); border-radius: var(--zx-radius-sm); margin-bottom: .6rem; padding: .4rem .6rem; }
  .zx-table--stack td { border-bottom: none; padding: .3rem 0; display: flex; justify-content: space-between; gap: .75rem; }
  .zx-table--stack td::before { content: attr(data-label); font-weight: 600; color: var(--zx-muted); font-size: .75rem; }
}

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--zx-muted); }
.empty-state .icon { font-size: 2rem; margin-bottom: .5rem; }

/* ---------- Mobile bottom navigation (staff quick actions) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid var(--zx-border);
  box-shadow: 0 -2px 8px rgba(15,23,42,.06);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: .5rem 0; min-height: var(--zx-tap);
  font-size: .68rem; font-weight: 600; color: var(--zx-muted); text-decoration: none;
  background: none; border: none; font-family: inherit; cursor: pointer;
}
.bottom-nav a.active, .bottom-nav button.active { color: var(--zx-orange); }
.bottom-nav .bn-icon { font-size: 1.15rem; line-height: 1; }
@media (min-width: 768px) { .bottom-nav { display: none; } }

/* Add breathing room so page content isn't hidden behind the bottom nav on mobile */
.has-bottom-nav { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
@media (min-width: 768px) { .has-bottom-nav { padding-bottom: 0; } }

/* ---------- Sidebar nav link (staff/admin) ---------- */
.nav {
  display: flex; align-items: center; gap: .7rem;
  min-height: 2.7rem; padding: .55rem .7rem; border-radius: .65rem;
  color: #cbd5e1;
}
.nav:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav.active { background: var(--zx-orange); color: #fff; }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: #475569 transparent; }
.sidebar-section-label { margin: 1.25rem .7rem .35rem; color: #94a3b8; font-size: .66rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.nav-icon { display: inline-grid; place-items: center; width: 1.25rem; color: #94a3b8; font-size: 1rem; line-height: 1; }
.nav:hover .nav-icon, .nav.active .nav-icon { color: currentColor; }
.sidebar-kicker { margin-top: .15rem; color: #94a3b8; font-size: .68rem; }
.sidebar-close { width: 2rem; height: 2rem; color: #cbd5e1; background: transparent; border: 0; font-size: 1.5rem; line-height: 1; }

/* ---------- Workspace search ---------- */
.global-search { position: relative; flex: 1 1 24rem; max-width: 30rem; margin: 0 1rem; }
.global-search-icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--zx-muted); font-size: 1.2rem; pointer-events: none; }
.global-search-input { width: 100%; min-height: 2.6rem; padding: .55rem 4.5rem .55rem 2.2rem; border: 1px solid var(--zx-border); border-radius: 999px; background: #f8fafc; color: var(--zx-ink); font-size: .9rem; }
.global-search-input:focus { outline: none; border-color: var(--zx-orange); background: #fff; box-shadow: 0 0 0 3px rgba(217,148,42,.15); }
.global-search kbd { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); padding: .15rem .35rem; border: 1px solid var(--zx-border); border-radius: .3rem; background: #fff; color: var(--zx-muted); font-size: .65rem; }
.global-search-results { position: absolute; left: 0; right: 0; top: calc(100% + .45rem); z-index: 80; max-height: 24rem; overflow-y: auto; padding: .35rem; border: 1px solid var(--zx-border); border-radius: var(--zx-radius); background: #fff; box-shadow: 0 16px 40px rgba(15,23,42,.18); }
.global-search-result { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .65rem .7rem; border-radius: .55rem; color: var(--zx-body); text-decoration: none; font-size: .85rem; }
.global-search-result:hover, .global-search-result:focus { background: #fff7ed; color: #9a3412; outline: 0; }
.global-search-result small { display: block; margin-left: auto; color: var(--zx-muted); font-size: .7rem; }
.global-search-empty { padding: 1rem; color: var(--zx-muted); text-align: center; font-size: .85rem; }
@media (max-width: 767px) {
  .global-search { order: 3; flex-basis: 100%; max-width: none; margin: .65rem 0 0; }
  .global-search-results { position: fixed; top: 7.2rem; left: .75rem; right: .75rem; max-height: 55vh; }
  header:has(.global-search) { flex-wrap: wrap; }
}

/* ---------- Filterable record lists ---------- */
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; }
.list-filter { max-width: 22rem; }
.record-list-empty { display: none; padding: 1.5rem; color: var(--zx-muted); text-align: center; }
@media (max-width: 640px) {
  .list-toolbar { align-items: stretch; flex-direction: column; }
  .list-filter { max-width: none; }
}

/* ---------- Dashboard ---------- */
.dashboard-shell { max-width: 90rem; margin: 0 auto; }
.dashboard-hero { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding: .25rem 0; }
.dashboard-eyebrow { margin: 0 0 .25rem; color: var(--zx-orange-dark); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.dashboard-title { margin: 0; color: var(--zx-ink); font-size: clamp(1.35rem, 4vw, 2rem); line-height: 1.15; font-weight: 800; }
.dashboard-subtitle { margin: .35rem 0 0; color: var(--zx-muted); font-size: .9rem; }
.dashboard-date { color: var(--zx-muted); font-size: .8rem; white-space: nowrap; }
.dashboard-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.25rem; }
.dashboard-actions .btn { flex: 0 1 auto; }
.dashboard-shortcuts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.dashboard-shortcut { display: flex; flex-direction: column; gap: .4rem; min-height: 6.25rem; padding: .9rem; border: 1px solid var(--zx-border); border-radius: var(--zx-radius); background: #fff; color: var(--zx-ink); text-decoration: none; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.dashboard-shortcut:hover { border-color: #fdba74; background: #fffaf3; transform: translateY(-1px); }
.dashboard-shortcut-icon { color: var(--zx-orange-dark); font-size: 1.25rem; font-weight: 800; }
.dashboard-shortcut strong { font-size: .9rem; }
.dashboard-shortcut small { color: var(--zx-muted); font-size: .75rem; }
.dashboard-alert-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem .8rem; border: 1px solid var(--zx-border); border-radius: var(--zx-radius-sm); color: var(--zx-body); text-decoration: none; }
.dashboard-alert-row:hover { background: #fff7ed; border-color: #fed7aa; }
.dashboard-alert-row span, .dashboard-alert-row small { display: block; }
.dashboard-alert-row small { color: var(--zx-muted); font-size: .75rem; margin-top: .15rem; }
.dashboard-alert-row b { color: var(--zx-warn); white-space: nowrap; }
.dashboard-alert-list { display: grid; gap: .5rem; }
@media (max-width: 640px) {
  .dashboard-hero { align-items: start; flex-direction: column; }
  .dashboard-date { order: -1; }
  .dashboard-actions { display: grid; grid-template-columns: 1fr; }
  .dashboard-actions .btn { width: 100%; }
  .dashboard-shortcuts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .dashboard-shortcut { min-height: 5.75rem; }
}

/* ---------- Final visual overrides ---------- */
.topbar { min-height: 4.25rem; background: rgba(255,255,255,.92) !important; backdrop-filter: blur(16px); box-shadow: 0 1px 0 rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.04); }
#sidebar { background: linear-gradient(180deg, #101b31 0%, #0f172a 58%, #111827 100%) !important; box-shadow: 12px 0 30px rgba(15,23,42,.12); }
.sidebar-nav .nav { margin-bottom: .15rem; }
main form input:not([type="hidden"]):not([type="submit"]), main form select, main form textarea {
  min-height: 2.8rem;
  border: 1px solid #dbe3ec;
  border-radius: .7rem;
  background: rgba(255,255,255,.96);
  color: var(--zx-ink);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
main form input:not([type="hidden"]):not([type="submit"]):focus, main form select:focus, main form textarea:focus {
  outline: none;
  border-color: var(--zx-orange);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(217,148,42,.14);
}
main form label { color: #475569; font-weight: 650; }
main form button:not(.zx-select-option) { min-height: 2.8rem; border-radius: .7rem; font-weight: 700; }
.dashboard-shortcuts { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.dashboard-kpi, .dashboard-panel { border: 1px solid rgba(255,255,255,.9); box-shadow: 0 10px 30px rgba(15,23,42,.055); }
.dashboard-kpi { position: relative; overflow: hidden; }
.dashboard-kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: .28rem; background: var(--zx-orange); }
.dashboard-kpi:nth-child(2)::before { background: var(--zx-teal); }
.dashboard-kpi:nth-child(3)::before { background: #64748b; }
.dashboard-panel h3 { color: var(--zx-ink); font-size: 1rem; }
.zx-select-menu[hidden] { display: none !important; }
.zx-select-menu:not([hidden]) { display: block !important; }
.zx-select-option { display: flex !important; align-items: center; min-height: 2.9rem; line-height: 1.25; white-space: normal; }
.zx-select-option::before { content: ""; flex: 0 0 .45rem; width: .45rem; height: .45rem; margin-right: .65rem; border-radius: 50%; background: var(--zx-orange); }
.zx-select-option:first-child::before { background: var(--zx-teal); }
@media (max-width: 767px) {
  .dashboard-shortcuts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { min-height: 4rem; }
}
