/* ═══════════════════════════════════════════════════════════════
   Portal screens: Book · Patient dashboard · Driver · Admin · Profile
   Uses the design tokens from main.css only.
   ═══════════════════════════════════════════════════════════════ */

/* Layout helpers */
.stack      { display: flex; flex-direction: column; gap: 16px; }
.row        { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between{ display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid-2     { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3     { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.muted      { color: var(--t2); }
.faint      { color: var(--t3); }
.mono       { font-family: var(--fm); }
.small      { font-size: .8rem; }
.tiny       { font-size: .72rem; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.err-text   { color: var(--re); }
.ok-text    { color: var(--gr); }

/* Visible keyboard focus everywhere (WCAG 2.4.7) */
.portal :focus-visible, .modal-box :focus-visible, .btn:focus-visible, .filter-btn:focus-visible, .sidebar-link:focus-visible, .svc-opt:focus-visible {
  outline: 2px solid var(--tl); outline-offset: 2px;
}

/* Service picker */
.svc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 560px) { .svc-grid { grid-template-columns: 1fr; } }
.svc-opt { text-align: left; font-family: var(--fn); color: var(--t1); background: var(--gl); border: 1.5px solid var(--bd); border-radius: 14px; padding: 16px; cursor: pointer; transition: var(--tr); display: flex; flex-direction: column; gap: 6px; }
.svc-opt:hover { border-color: var(--bd2); }
.svc-opt[aria-checked="true"] { border-color: var(--tl); background: var(--tl3); }
.svc-opt .svc-icon { font-size: 1.6rem; }
.svc-opt .svc-name { font-weight: 800; }
.svc-opt .svc-desc { font-size: .78rem; color: var(--t2); line-height: 1.5; }
.svc-opt .svc-price { font-size: .78rem; color: var(--tl); font-weight: 700; }

/* Notices */
.notice { border-radius: 12px; padding: 12px 14px; font-size: .82rem; line-height: 1.6; border: 1px solid var(--bd); background: var(--gl2); color: var(--t2); }
.notice.warn { background: var(--am3); border-color: rgba(245,158,11,.25); color: var(--am); }
.notice.err  { background: var(--re3); border-color: rgba(239,68,68,.25); color: var(--re); }
.notice.ok   { background: var(--gr3); border-color: rgba(34,197,94,.25); color: var(--gr); }

/* Definition list used in detail modals */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: .86rem; }
.kv dt { color: var(--t3); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding-top: 2px; }
.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; } .kv dt { padding-top: 8px; } }

/* Star rating */
.stars { display: inline-flex; gap: 4px; }
.star-btn { background: none; border: none; font-size: 1.7rem; line-height: 1; cursor: pointer; color: var(--t4); padding: 2px; }
.star-btn[aria-pressed="true"], .star-btn.on { color: var(--am); }

/* Notification list */
.notif { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--bd); }
.notif:last-child { border-bottom: none; }
.notif.unread .notif-title::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--tl); margin-right: 8px; }
.notif-title { font-weight: 700; font-size: .88rem; }
.notif-msg   { font-size: .82rem; color: var(--t2); margin-top: 2px; }
.notif-time  { font-size: .7rem; color: var(--t3); margin-top: 4px; }
.bell { position: relative; }
.bell-count { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; border-radius: 100px; background: var(--re); color: #fff; font-size: .62rem; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* Driver status switch */
.status-switch { display: inline-flex; background: var(--bg0); border: 1px solid var(--bd); border-radius: 12px; padding: 4px; gap: 4px; }
.status-opt { border: none; background: transparent; color: var(--t2); font-family: var(--fn); font-weight: 700; font-size: .8rem; padding: 9px 14px; border-radius: 9px; cursor: pointer; }
.status-opt[aria-pressed="true"] { background: var(--tl3); color: var(--tl); }
.status-opt.off[aria-pressed="true"] { background: var(--gl2); color: var(--t1); }
.trip-next { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.addr { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; padding: 6px 0; }
.addr .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--tl); }
.addr .dot.to { background: var(--am); }
.addr a { color: var(--tl); font-size: .75rem; font-weight: 700; margin-left: 8px; }

/* Admin */
.admin-main h2.section-title { font-weight: 900; font-size: 1.5rem; letter-spacing: -.02em; margin-bottom: 4px; }
.admin-main .section-sub { color: var(--t2); font-size: .85rem; margin-bottom: 24px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--bd); font-size: .8rem; color: var(--t2); }
.mini-bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 10px; }
.mini-bars .bar { flex: 1; background: linear-gradient(180deg, var(--tl), var(--tl2)); border-radius: 6px 6px 0 0; min-height: 3px; position: relative; }
.mini-bars .bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: .66rem; color: var(--t2); }
.mini-labels { display: flex; gap: 8px; font-size: .65rem; color: var(--t3); }
.mini-labels span { flex: 1; text-align: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 100px; background: var(--gl2); border: 1px solid var(--bd); }
.pill.ok  { color: var(--gr); background: var(--gr3); border-color: rgba(34,197,94,.25); }
.pill.bad { color: var(--re); background: var(--re3); border-color: rgba(239,68,68,.25); }
.pill.warn{ color: var(--am); background: var(--am3); border-color: rgba(245,158,11,.25); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--bd); }
.switch-row:last-child { border-bottom: none; }
.kv-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--bd); font-size: .86rem; }
.kv-list > div:last-child { border-bottom: none; }
.kv-list span:first-child { color: var(--t2); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) { .portal *, .modal-box { animation: none !important; transition: none !important; } }

/* Light mode contrast for pills */
.light-mode .notice, .light-mode .svc-opt { color: #1b2a41; }

/* Nav: bell + user chip sit side by side */
#nav-auth-area { display: flex; align-items: center; gap: 10px; position: relative; }
.pill input[type="checkbox"] { accent-color: var(--tl); width: 16px; height: 16px; }

/* Danger text that meets 4.5:1 on its tinted background (dark) and on white (light) */
.pill.bad, .notice.err, .err-text { color: #ff8f8f; }
body.light-mode .pill.bad, body.light-mode .notice.err, body.light-mode .err-text { color: #b91c1c; }
body.light-mode .pill.ok, body.light-mode .ok-text, body.light-mode .notice.ok { color: #15803d; }
body.light-mode .pill.warn, body.light-mode .notice.warn { color: #92400e; }

/* The animated background canvas is position:fixed; z-index:0 and used to paint OVER plain (non-positioned) text,
   dimming headings. Lifting the whole app above it fixes every page. */
#main-content { position: relative; z-index: 1; }

/* Tables: keep short columns on one line, let action buttons wrap instead of overflowing */
.data-table td.nw, .data-table td.td-mono { white-space: nowrap; }
.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; min-width: 150px; }

/* ── Phones: keep every top-bar control on screen ─────────────── */
@media (max-width: 640px) {
  #main-nav .nav-inner { padding: 0 12px; gap: 8px; }
  .nav-right { gap: 6px; min-width: 0; }
  .nav-text, .user-name, .user-role, .user-chip > span[aria-hidden], .socket-status { display: none; }
  .user-chip { padding: 3px; }
  .nav-select { padding: 4px 2px; max-width: 64px; font-size: .68rem; }
  #nav-auth-area { gap: 6px; }
  #nav-auth-area .btn-primary { display: none; }   /* "Book Ride" is in the menu */
  .theme-btn { width: 32px; height: 32px; }
}
.grid-3 > .form-group { justify-content: flex-end; }

/* ---- Right-to-left (Arabic) ---- */
[dir=rtl] .svc-opt { text-align: right; }
[dir=rtl] .notif.unread .notif-title::before { margin-right: 0; margin-left: 8px; }
[dir=rtl] .bell-count { right: auto; left: -4px; }
[dir=rtl] .addr a { margin-left: 0; margin-right: 8px; }
[dir=rtl] .route-sketch svg { direction: ltr; }
