:root{
  /* Professional navy + single gold accent palette */
  --blue:#1E3A5F;          /* primary (kept var name for compatibility with inline styles) */
  --blue-dark:#152A46;
  --blue-light:#EAF0F6;
  --accent:#B8892F;        /* single accent color — used sparingly for emphasis */
  --accent-light:#F7EFDD;
  --bg:#F3F5F8;
  --card:#FFFFFF;
  --border:#E4E8EE;
  --text:#151C26;
  --text-secondary:#5B6B7C;
  --text-muted:#93A1AF;
  --danger:#C0392B;
  --danger-bg:#FBEAE8;
  --success:#1E7E5A;
  --success-bg:#E8F5EF;
  --warning:#9A6A00;
  --warning-bg:#FBF1DC;

  --radius-sm:8px;
  --radius:12px;
  --radius-lg:18px;
  --radius-pill:999px;

  --shadow-sm:0 1px 2px rgba(21,28,38,.05), 0 1px 1px rgba(21,28,38,.04);
  --shadow-md:0 4px 12px rgba(21,28,38,.08), 0 1px 3px rgba(21,28,38,.05);
  --shadow-lg:0 12px 28px rgba(21,28,38,.12), 0 2px 6px rgba(21,28,38,.06);

  --fs-xs:11px;
  --fs-sm:12.5px;
  --fs-base:14px;
  --fs-md:15px;
  --fs-lg:18px;
  --fs-xl:22px;
  --fs-2xl:26px;
}
:root[data-theme="dark"]{
  --blue:#3D7FE0;
  --blue-dark:#24456E;
  --blue-light:#1A3450;
  --accent:#BE8C38;
  --accent-light:#3A2F1C;
  --bg:#0B1624;
  --card:#132235;
  --border:#223349;
  --text:#EDF1F5;
  --text-secondary:#A9B8C9;
  --text-muted:#6E7F93;
  --danger:#D85446;
  --danger-bg:#3A1915;
  --success:#34B37E;
  --success-bg:#113326;
  --warning:#D6A53C;
  --warning-bg:#3A2D0F;

  --shadow-sm:0 1px 2px rgba(0,0,0,.35), 0 1px 1px rgba(0,0,0,.25);
  --shadow-md:0 4px 12px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg:0 12px 28px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3);
}
*{box-sizing:border-box;}
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:'IBM Plex Sans Arabic','Tahoma','Segoe UI',sans-serif;
  -webkit-font-smoothing:antialiased;
  display:flex; justify-content:center;
}
#app{
  width:100%; max-width:440px; min-height:100vh;
  background:var(--bg); position:relative; padding-bottom:78px;
}
/* 100vh on iOS/iPadOS Safari measures the viewport with its toolbars
   hidden (the tallest it can ever be), not what's actually visible —
   #app could end up taller than the real screen, which pushed the
   position:fixed bottom:0 .navbar below the visible area until the page
   was scrolled all the way down. 100dvh (dynamic viewport height)
   tracks the real visible viewport as Safari's toolbars show/hide;
   browsers without it (older Safari, most non-WebKit browsers already
   compute 100vh correctly) just keep the line above as a fallback,
   since an unsupported value is ignored rather than applied as 0. */
@supports (min-height: 100dvh){
  #app{ min-height:100dvh; }
}
.screen{ display:none; padding:18px 16px; animation:fadeIn .22s ease; }
.screen.active{ display:block; }
@keyframes fadeIn{ from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:translateY(0);} }

.card{
  background:var(--card); border:1px solid var(--border); border-radius:var(--radius-lg);
  padding:20px; margin-bottom:14px; box-shadow:var(--shadow-sm);
}
.topbar{ display:flex; align-items:center; gap:12px; margin-bottom:18px; }
.topbar .back{
  display:flex; align-items:center; justify-content:center;
  width:34px; height:34px; border-radius:50%; background:var(--card);
  border:1px solid var(--border); color:var(--text-secondary); cursor:pointer;
  box-shadow:var(--shadow-sm); flex-shrink:0;
}
.topbar .back .icon{ width:17px; height:17px; }
.topbar h2{ font-size:var(--fs-lg); margin:0; font-weight:700; letter-spacing:-.01em; }

h1,h2,h3,p{ margin:0; }
label{ font-size:var(--fs-xs); font-weight:600; color:var(--text-secondary); display:block; margin-bottom:6px; letter-spacing:.01em; }
input, select, textarea{
  width:100%; padding:11px 13px; border:1px solid var(--border); border-radius:var(--radius-sm);
  font-size:var(--fs-base); background:var(--card); color:var(--text); margin-bottom:14px; font-family:inherit;
  transition:border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus{
  outline:none; border-color:var(--blue); box-shadow:0 0 0 3px var(--blue-light);
}
input:disabled{ color:var(--text-secondary); background:var(--bg); }
textarea{ resize:vertical; min-height:84px; }
.row2{ display:flex; gap:10px; }
.row2>div{ flex:1; }

button{ font-family:inherit; cursor:pointer; border:none; border-radius:var(--radius-sm); transition:filter .15s ease, transform .05s ease, box-shadow .15s ease; }
button:active{ transform:translateY(1px); }
.btn-primary{
  width:100%; background:var(--blue); color:#fff; padding:13px; font-size:var(--fs-base); font-weight:600;
  box-shadow:var(--shadow-md); display:flex; align-items:center; justify-content:center; gap:8px;
}
.btn-primary:hover{ filter:brightness(1.08); }
.btn-primary:disabled{ opacity:.45; cursor:not-allowed; box-shadow:none; }
.btn-outline{
  width:100%; background:var(--card); border:1.5px solid var(--border); color:var(--text); padding:12px; font-size:var(--fs-base); font-weight:600;
}
.btn-outline:hover{ border-color:var(--blue); color:var(--blue); }
.btn-ghost{ background:transparent; color:var(--blue); font-size:var(--fs-sm); padding:7px 10px; font-weight:600; }
.btn-danger{ background:var(--danger); color:#fff; box-shadow:var(--shadow-md); }

.link{ color:var(--blue); cursor:pointer; font-weight:600; }
.muted{ color:var(--text-muted); font-size:var(--fs-sm); }
.error-text{ color:var(--danger); font-size:var(--fs-sm); margin:-8px 0 12px; font-weight:600; }
.center{ text-align:center; }

.logo-icon{
  width:68px; height:68px; border-radius:var(--radius-lg); background:var(--blue);
  display:flex; align-items:center; justify-content:center; margin:0 auto 16px;
  box-shadow:var(--shadow-md); position:relative; color:#fff; overflow:hidden;
}
.logo-icon .icon{ width:32px; height:32px; }
.logo-icon .app-logo-img{ width:100%; height:100%; display:block; }

.icon{ width:18px; height:18px; flex-shrink:0; stroke-width:2; }
.icon-xs{ width:14px; height:14px; }
.icon-sm{ width:16px; height:16px; }
.icon-lg{ width:24px; height:24px; }
.icon-xl{ width:32px; height:32px; }
.icon-star-filled{ fill:currentColor; color:var(--accent); }
.icon-muted{ color:var(--text-muted); }
.icon-accent{ color:var(--accent); }
.icon-inline{ vertical-align:-3px; margin-left:4px; }
.icon-top-align{ margin-top:2px; }

.toggle-group{ display:flex; gap:8px; margin-bottom:14px; }
.toggle-opt{
  flex:1; text-align:center; padding:10px; border-radius:var(--radius-sm); border:1.5px solid var(--border);
  font-size:var(--fs-sm); font-weight:600; cursor:pointer; background:var(--card); color:var(--text-secondary);
  transition:all .15s ease;
}
.toggle-opt.selected{ border-color:var(--blue); background:var(--blue-light); color:var(--blue); }

.pledge-box, .info-box{
  background:var(--blue-light); border-radius:var(--radius); padding:14px; display:flex; gap:10px; align-items:flex-start; margin-bottom:16px;
}
.pledge-box p{ font-size:var(--fs-xs); line-height:1.85; color:var(--text); }
.pledge-box input{ width:auto; margin:2px 0 0; accent-color:var(--blue); }

.otp-row{ display:flex; gap:10px; justify-content:center; margin-bottom:16px; }
.otp-row input{ width:46px; height:52px; text-align:center; font-size:20px; font-weight:700; margin-bottom:0; padding:0; }

.cat-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:18px; }
/* Home's 3 vehicle-section cards read better as one row than 2+1 */
#screen-home .cat-grid{ grid-template-columns:repeat(3, 1fr); }
#screen-home .cat-card{ padding:16px 6px; }
.cat-card{
  border-radius:var(--radius); padding:18px 10px; text-align:center; cursor:pointer;
  font-size:var(--fs-sm); font-weight:600; border:1.5px solid transparent;
  background:var(--blue-light); color:var(--blue); box-shadow:var(--shadow-sm);
  transition:all .15s ease;
}
.cat-card .icon{ width:24px; height:24px; display:block; margin:0 auto 8px; }
.cat-card.selected{ border-color:var(--blue); }
.cat-card.disabled{ opacity:.5; cursor:not-allowed; background:var(--bg); color:var(--text-secondary); box-shadow:none; }

.cat-strip{ display:flex; gap:8px; overflow-x:auto; padding-bottom:8px; margin-bottom:16px; }
.cat-chip{
  flex:0 0 auto; padding:9px 15px; border-radius:var(--radius-pill); background:var(--card); border:1.5px solid var(--border);
  font-size:var(--fs-sm); font-weight:500; cursor:pointer; white-space:nowrap; transition:all .15s ease;
}
.cat-chip.selected{ border-color:var(--blue); color:var(--blue); background:var(--blue-light); font-weight:700; }

.searchbar{ position:relative; margin-bottom:16px; }
.searchbar input{ margin:0; padding-right:40px; }
.searchbar .icon{ position:absolute; right:14px; top:50%; transform:translateY(-50%); color:var(--text-muted); width:17px; height:17px; }

.listing-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.listing-card{
  background:var(--card); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden;
  cursor:pointer; box-shadow:var(--shadow-sm); transition:box-shadow .15s ease, transform .1s ease;
}
.listing-card:hover{ box-shadow:var(--shadow-md); transform:translateY(-1px); }
.listing-thumb{ height:92px; background:var(--blue-light); color:var(--blue); display:flex; align-items:center; justify-content:center; overflow:hidden; }
.listing-thumb img{ width:100%; height:100%; object-fit:cover; }
.listing-info{ padding:10px; }
.listing-info .title{ font-size:var(--fs-sm); font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.listing-info .price{ font-size:var(--fs-sm); color:var(--blue); font-weight:700; margin-top:4px; }
.listing-info .loc{ display:flex; align-items:center; gap:4px; font-size:var(--fs-xs); color:var(--text-muted); margin-top:4px; }
.listing-info .loc .icon{ width:11px; height:11px; }

.badge{ font-size:var(--fs-xs); font-weight:600; padding:3px 9px; border-radius:var(--radius-pill); display:inline-flex; align-items:center; gap:4px; }
.badge .icon{ width:12px; height:12px; }
.badge-success{ background:var(--success-bg); color:var(--success); }
.badge-danger{ background:var(--danger-bg); color:var(--danger); }
.badge-warning{ background:var(--warning-bg); color:var(--warning); }

.status-dot{ width:9px; height:9px; border-radius:50%; display:inline-block; flex-shrink:0; }
.status-dot-success{ background:var(--success); }
.status-dot-danger{ background:var(--danger); }

.navbar{
  position:fixed; bottom:0; left:50%; transform:translateX(-50%); width:100%; max-width:440px;
  background:var(--card); border-top:1px solid var(--border); display:flex; justify-content:space-around;
  align-items:center; padding:10px 0 12px; z-index:50; box-shadow:0 -2px 12px rgba(0,0,0,.08);
}
.navbar .nav-item{ display:flex; flex-direction:column; align-items:center; gap:4px; color:var(--text-muted); cursor:pointer; text-align:center; }
.navbar .nav-item .icon{ width:21px; height:21px; }
.navbar .nav-item.active{ color:var(--blue); }
.navbar .nav-item span{ font-size:9.5px; font-weight:600; }
.fab{
  background:var(--blue); color:#fff; width:46px; height:46px; border-radius:50%;
  display:flex; align-items:center; justify-content:center; margin-top:-26px; border:3px solid #fff;
  box-shadow:var(--shadow-lg); cursor:pointer;
}
.fab .icon{ width:20px; height:20px; }
.fab-label{ display:none; } /* shown as real text next to the icon only in the ≥1024px sidebar nav */

.pwa-hint{
  position:fixed; top:0; left:50%; transform:translateX(-50%); width:100%; max-width:440px;
  background:var(--blue-dark); color:#fff; display:flex; align-items:center; gap:10px;
  padding:11px 14px; z-index:70; box-shadow:0 2px 10px rgba(0,0,0,.12);
}
.pwa-hint-icon{ flex-shrink:0; display:flex; }
.pwa-hint-icon .icon{ color:#fff; }
.pwa-hint-text{ flex:1; font-size:var(--fs-xs); line-height:1.5; margin:0; color:#fff; }
.pwa-hint-install-btn{
  flex-shrink:0; background:#fff; color:var(--blue-dark); border:none; border-radius:var(--radius-sm);
  padding:7px 12px; font-size:var(--fs-xs); font-weight:700; cursor:pointer; font-family:inherit;
}
.pwa-hint-close{ flex-shrink:0; cursor:pointer; display:flex; opacity:.85; }
.pwa-hint-close .icon{ color:#fff; width:16px; height:16px; }

.avatar{
  width:40px; height:40px; border-radius:50%; background:var(--blue-light); color:var(--blue);
  display:flex; align-items:center; justify-content:center; font-size:var(--fs-sm); font-weight:700; flex-shrink:0;
}
.settings-row{ display:flex; align-items:center; gap:12px; padding:13px 0; border-bottom:1px solid var(--border); cursor:pointer; }
.settings-row:last-child{ border-bottom:none; }
.settings-row .icon{ width:18px; height:18px; color:var(--text-secondary); flex-shrink:0; }
.settings-row span{ flex:1; font-size:var(--fs-base); font-weight:500; }
.settings-row .chev{ color:var(--text-muted); width:16px; height:16px; }
/* .settings-row span{flex:1} outweighs .status-dot's own flex-shrink:0 by
   specificity (class+element beats class alone), stretching the dot into
   an oval when the two are combined (admin users list) — pre-existing,
   just not triggered until this combination was used. */
.settings-row .status-dot{ flex:none; }

.toast{
  position:fixed; bottom:96px; left:50%; transform:translateX(-50%); background:var(--blue-dark); color:#fff;
  padding:11px 22px; border-radius:var(--radius-pill); font-size:var(--fs-sm); font-weight:500; z-index:100; opacity:0; transition:opacity .3s;
  pointer-events:none; white-space:nowrap; box-shadow:var(--shadow-lg);
}
.toast.show{ opacity:1; }

.upload-drop{
  border:1.5px dashed var(--border); border-radius:var(--radius); padding:22px 16px; text-align:center; margin-bottom:14px;
  color:var(--text-secondary); font-size:var(--fs-sm); font-weight:500; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; gap:8px; transition:all .15s ease;
}
.upload-drop:hover{ border-color:var(--blue); background:var(--blue-light); color:var(--blue); }
.upload-drop .icon{ width:26px; height:26px; }
.upload-drop small{ display:block; font-size:var(--fs-xs); color:var(--text-muted); font-weight:400; margin-top:2px; }
.thumb-strip{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.thumb-strip .thumb{ width:62px; height:62px; border-radius:var(--radius-sm); overflow:hidden; position:relative; background:var(--blue-light); box-shadow:var(--shadow-sm); }
.thumb-strip .thumb img{ width:100%; height:100%; object-fit:cover; }
.thumb-strip .thumb .rm{
  position:absolute; top:3px; left:3px; background:rgba(21,28,38,.65); color:#fff; border-radius:50%;
  width:18px; height:18px; display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.thumb-strip .thumb .rm .icon{ width:11px; height:11px; }

.spinner-wrap{ display:flex; flex-direction:column; align-items:center; gap:10px; padding:32px 0; color:var(--text-muted); font-size:var(--fs-sm); grid-column:1/-1; }
.spinner{ width:24px; height:24px; border-radius:50%; border:2.5px solid var(--border); border-top-color:var(--blue); animation:spin .7s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

/* Report reason picker (Section 10) — same radio-card language as the OTP method choice screen */
.reason-row{
  display:flex; justify-content:space-between; align-items:center; background:var(--bg);
  border-radius:var(--radius); padding:14px; margin-bottom:9px; border:2px solid var(--border);
  cursor:pointer; font-size:var(--fs-base); font-weight:500; transition:all .15s ease;
}
.reason-row.selected{ border-color:var(--blue); background:var(--blue-light); color:var(--blue); font-weight:600; }
.reason-radio{ width:18px; height:18px; border-radius:50%; border:2px solid var(--border); flex-shrink:0; }
.reason-row.selected .reason-radio{ border-color:var(--blue); background:var(--blue); }

/* Per-card actions on "إعلاناتي" (My Listings): bump / restore — Section 8 & 15 */
.card-action-btn{ width:100%; border:1px solid var(--border); margin-top:6px; padding:7px; font-size:var(--fs-xs); }
.card-action-btn:disabled{ opacity:.5; cursor:not-allowed; }

/* In-app messaging: conversation list rows + chat bubbles */
.convo-row{
  display:flex; align-items:center; gap:12px; background:var(--card); border:1px solid var(--border);
  border-radius:var(--radius); padding:13px; margin-bottom:10px; cursor:pointer; box-shadow:var(--shadow-sm);
  transition:box-shadow .15s ease;
}
.convo-row:hover{ box-shadow:var(--shadow-md); }

.msg-bubble{
  max-width:78%; padding:10px 13px; border-radius:var(--radius); font-size:var(--fs-base); line-height:1.6;
  position:relative; word-break:break-word; white-space:pre-wrap;
}
.msg-theirs{ align-self:flex-start; background:var(--card); border:1px solid var(--border); border-bottom-left-radius:4px; }
.msg-mine{ align-self:flex-end; background:var(--blue); color:#fff; border-bottom-right-radius:4px; }
.msg-time{ display:block; font-size:9.5px; margin-top:4px; opacity:.65; text-align:left; }
.chat-input-bar{
  position:fixed; bottom:0; left:50%; transform:translateX(-50%); width:100%; max-width:440px;
  background:var(--card); border-top:1px solid var(--border); padding:10px 16px; display:flex; gap:8px; z-index:60;
}

/* Segmented tab switcher — vehicle-section screens ("قطع غيار" | "[نوع] كاملة"),
   one tap to swap content in place, no intermediate choice screen or back-nav. */
.tab-bar{
  display:flex; background:var(--bg); border-radius:var(--radius-pill); padding:4px;
  margin-bottom:16px; gap:4px;
}
.tab-btn{
  flex:1; text-align:center; padding:10px 8px; border-radius:var(--radius-pill);
  font-size:var(--fs-sm); font-weight:600; color:var(--text-secondary); cursor:pointer;
  transition:all .15s ease; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.tab-btn.active{ background:var(--card); color:var(--blue); box-shadow:var(--shadow-sm); }

/* =====================================================================
   RESPONSIVE: tablet (≥768px) and laptop/desktop (≥1024px, ≥1440px).
   Nothing above this point is touched by these rules — mobile (<768px)
   keeps the exact layout it always had. Works in portrait and landscape
   (these are plain width breakpoints, not orientation-specific), and in
   standalone/installed PWA mode exactly as in a regular browser tab,
   since display:standalone doesn't change viewport/CSS behavior at all.
   ===================================================================== */

/* ---------- Tablet: iPad portrait and up ---------- */
@media (min-width: 768px){
  :root{
    --fs-xs:12px; --fs-sm:13.5px; --fs-base:15px; --fs-md:16.5px; --fs-lg:20px; --fs-xl:25px; --fs-2xl:29px;
  }
  #app{ max-width:720px; }
  .screen{ padding:24px 28px; }
  .card{ padding:24px; }
  .btn-primary, .btn-outline{ padding:14px; }
  input, select, textarea{ padding:13px 15px; }
  .listing-grid{ grid-template-columns:repeat(3, 1fr); gap:14px; }
  .listing-thumb{ height:130px; }
  /* #screen-home .cat-grid (the 3 vehicle-section cards) stays 3-wide
     regardless, via its own higher-specificity ID rule above. */
  .cat-grid{ grid-template-columns:repeat(3, 1fr); }
  .navbar, .pwa-hint, .chat-input-bar{ max-width:720px; }
}

/* ---------- Laptop / desktop: ≥1024px ---------- */
@media (min-width: 1024px){
  #app{
    max-width:1140px; display:flex; flex-direction:row; padding-bottom:0; min-height:100vh;
  }
  .screen{ flex:1; min-width:0; padding:32px 40px; }
  .listing-grid{ grid-template-columns:repeat(4, 1fr); }
  .listing-thumb{ height:148px; }
  .cat-grid{ grid-template-columns:repeat(4, 1fr); }

  /* Bottom tab bar becomes a sticky vertical rail. order:-1 puts it first
     among #app's flex children despite coming later in the DOM (it's
     after every .screen there) — in this RTL page that places it on the
     right (the "start" edge), with the active screen's content to its
     left, without reordering any markup. */
  .navbar{
    position:sticky; top:0; order:-1; align-self:flex-start;
    bottom:auto; left:auto; transform:none; max-width:none;
    flex-direction:column; justify-content:flex-start; align-items:stretch;
    width:220px; flex-shrink:0; height:100vh; gap:4px; padding:24px 16px;
    box-shadow:none; border-top:none; border-left:1px solid var(--border);
  }
  .navbar .nav-item{
    flex-direction:row; justify-content:flex-start; gap:12px; padding:11px 14px;
    border-radius:var(--radius-sm); text-align:start; transition:background .15s ease;
  }
  .navbar .nav-item:hover{ background:var(--blue-light); }
  .navbar .nav-item.active{ background:var(--blue-light); }
  .navbar .nav-item .icon{ width:19px; height:19px; }
  .navbar .nav-item span{ font-size:var(--fs-sm); }
  .fab{
    order:-1; margin-top:0; margin-bottom:10px; width:auto; height:auto; border:none;
    border-radius:var(--radius-sm); flex-direction:row; justify-content:flex-start;
    gap:12px; padding:12px 14px;
  }
  .fab-label{ display:inline; font-size:var(--fs-sm); font-weight:600; }

  .pwa-hint{ max-width:1140px; }
  .chat-input-bar{ position:sticky; bottom:0; left:auto; transform:none; max-width:none; }

  /* Listing detail: media on one side, everything else on the other.
     Grid (not flex) because .detail-info-col appears twice in the markup
     (its exact original positions either side of the media block, kept
     that way so mobile's DOM/visual order is untouched) — grid-column
     placement stacks both fragments in column 1 regardless of how many
     there are, while the single media fragment spans every row of column 2. */
  #detail-body{
    display:grid; grid-template-columns:1fr 42%; gap:28px; align-items:start; padding:28px;
  }
  .detail-info-col{ grid-column:1; }
  .detail-media-col{ grid-column:2; grid-row:1 / -1; position:sticky; top:20px; }
}

@media (min-width: 1440px){
  .listing-grid{ grid-template-columns:repeat(5, 1fr); }
  #app{ max-width:1320px; }
}
