/* ================================================================
   Dashboard styles — sidebar, panels, cards, mobile-first.
   Loaded after app.css.
================================================================ */

:root{
  --sidebar-w: 260px;
  --dash-bg: #f4f6fa;
  --dash-elev: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --dash-elev-hover: 0 8px 24px -4px rgba(15,23,42,.18);
}

body.dash{ background: var(--dash-bg); }

/* Hide the global header on dashboard pages — we get our own */
body.dash > div#site-header{ display: none; }
body.dash > div#site-footer{ display: none; }

/* ----- Layout shell ----- */
.dash-shell{
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}
@media (min-width: 1024px){
  .dash-shell{
    grid-template-columns: var(--sidebar-w) 1fr;
  }
}

/* ----- Mobile top bar ----- */
.dash-top{
  position: sticky; top: 0; z-index: 30;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem;
  height: 60px;
}
.dash-top .brand{
  display: flex; align-items: center; gap: .5rem;
  font-weight: 800; font-size: 1rem;
}
.dash-top .brand .badge{
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: #fff; display: grid; place-items: center; font-size: .85rem;
}
.dash-top-actions{ display: flex; align-items: center; gap: .25rem; }
@media (min-width: 1024px){
  .dash-top{ display: none; }
}

/* ----- Sidebar ----- */
.dash-side{
  position: fixed; inset: 0 30% 0 0;
  z-index: 60;
  background: #fff; max-width: 280px;
  transform: translateX(-100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.dash-side.open{ transform: translateX(0); }
.dash-side-backdrop{
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15,23,42,.5);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.dash-side-backdrop.open{ opacity: 1; pointer-events: auto; }

@media (min-width: 1024px){
  .dash-side{
    position: sticky; top: 0; transform: none;
    height: 100vh; max-width: none; box-shadow: none;
    border-right: 1px solid var(--line);
  }
  .dash-side-backdrop{ display: none; }
}

.side-head{
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .75rem;
}
.side-head .badge{
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: #fff; display: grid; place-items: center; font-weight: 800;
}
.side-head .title{ font-weight: 800; font-size: .95rem; }
.side-head .subtitle{ font-size: .78rem; color: var(--ink-3); }

.side-user{
  padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: .75rem;
  border-bottom: 1px solid var(--line);
}
.side-user .avatar{
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 1.05rem;
  flex-shrink: 0;
}
.side-user .info{ flex: 1; min-width: 0; }
.side-user .name{
  font-weight: 700; font-size: .92rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-user .email{
  font-size: .78rem; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.side-nav{
  padding: .5rem 0; flex: 1; overflow-y: auto;
}
.side-nav .section-label{
  padding: .85rem 1.25rem .35rem;
  font-size: .68rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-3); font-weight: 700;
}
.side-nav a, .side-nav button.nav-item{
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1.25rem;
  color: var(--ink-2); font-weight: 500; font-size: .92rem;
  cursor: pointer; border: 0; background: transparent; width: 100%;
  text-align: left; border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
.side-nav .nav-item:hover{ background: var(--surface-2); color: var(--ink); }
.side-nav .nav-item.active{
  background: rgba(10,124,58,.08);
  color: var(--brand-dark);
  border-left-color: var(--brand);
  font-weight: 600;
}
.side-nav .nav-item .icon{
  width: 20px; height: 20px; color: currentColor; flex-shrink: 0;
}
.side-nav .nav-item .badge-pill{
  margin-left: auto;
  background: var(--accent); color: #fff;
  font-size: .7rem; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  display: grid; place-items: center;
}

.side-foot{
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--line);
}

/* ----- Main panel ----- */
.dash-main{
  padding: 1rem;
  min-width: 0; /* allow grid items to shrink */
}
@media (min-width: 768px){ .dash-main{ padding: 1.5rem; } }
@media (min-width: 1024px){ .dash-main{ padding: 2rem 2.5rem; } }

.dash-section{
  display: none; /* JS will toggle */
}
.dash-section.active{ display: block; }

.dash-header{
  display: flex; flex-wrap: wrap; gap: 1rem;
  justify-content: space-between; align-items: flex-end;
  margin-bottom: 1.5rem;
}
.dash-header h1{
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  margin: 0 0 .15em;
}
.dash-header p{ margin: 0; color: var(--ink-3); font-size: .92rem; }
.dash-header .actions{ display: flex; gap: .5rem; flex-wrap: wrap; }

/* ----- Stat cards ----- */
.stats{
  display: grid; gap: .85rem;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 1.5rem;
}
@media (min-width: 768px){ .stats{ grid-template-columns: repeat(4, 1fr); } }
.stat{
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex; flex-direction: column; gap: .5rem;
  position: relative; overflow: hidden;
}
.stat .stat-icon{
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  position: absolute; top: .85rem; right: .85rem;
  opacity: .9;
}
.stat .label{
  font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-3); font-weight: 700;
}
.stat .value{
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 1.7rem);
  font-weight: 800; color: var(--ink); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat .delta{ font-size: .8rem; color: var(--ink-3); }
.stat .delta.up{ color: var(--ok); }
.stat .delta.down{ color: var(--err); }

/* ----- Panel cards ----- */
.panel{
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1.25rem; overflow: hidden;
}
.panel-head{
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.panel-head h3{ margin: 0; font-size: 1rem; }
.panel-body{ padding: 1.25rem; }
.panel-foot{
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  display: flex; justify-content: space-between; align-items: center;
  font-size: .85rem;
}

/* ----- Lists / rows ----- */
.list-item{
  display: flex; align-items: center; gap: .85rem;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  transition: background .1s;
}
.list-item:last-child{ border-bottom: 0; }
.list-item:hover{ background: var(--surface-2); }
.list-item .li-icon{
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--surface-3);
}
.list-item .li-body{ flex: 1; min-width: 0; }
.list-item .li-title{
  font-weight: 600; font-size: .92rem; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-item .li-meta{
  font-size: .8rem; color: var(--ink-3); margin: 2px 0 0;
}
.list-item .li-right{ text-align: right; flex-shrink: 0; }
.list-item .li-amt{ font-weight: 700; font-size: .95rem; }
.list-item .li-status{ font-size: .75rem; color: var(--ink-3); }

/* ----- Status pills ----- */
.pill{
  display: inline-flex; align-items: center; gap: .35em;
  padding: .2em .55em; border-radius: 999px;
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em;
}
.pill-ok{ background: rgba(22,163,74,.12); color: #15803d; }
.pill-warn{ background: rgba(245,158,11,.12); color: #b45309; }
.pill-err{ background: rgba(220,38,38,.12); color: #b91c1c; }
.pill-info{ background: rgba(37,99,235,.12); color: #1d4ed8; }
.pill-neutral{ background: var(--surface-3); color: var(--ink-2); }

/* ----- Toggle switch ----- */
.toggle-sw{
  position: relative; width: 44px; height: 24px;
  background: var(--line-strong); border-radius: 12px;
  cursor: pointer; transition: background .15s;
  flex-shrink: 0;
}
.toggle-sw::after{
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; background: #fff; border-radius: 50%;
  transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-sw.on{ background: var(--brand); }
.toggle-sw.on::after{ transform: translateX(20px); }
input.toggle-input{ position: absolute; opacity: 0; pointer-events: none; }

/* ----- Setting rows ----- */
.setting-row{
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.setting-row:last-child{ border-bottom: 0; }
.setting-row .setting-info{ flex: 1; min-width: 0; }
.setting-row .setting-info .label{ font-weight: 600; }
.setting-row .setting-info .desc{ font-size: .82rem; color: var(--ink-3); margin-top: 2px; }
.setting-row .setting-control{ flex-shrink: 0; }

/* ----- Avatar color picker ----- */
.color-grid{
  display: grid; grid-template-columns: repeat(8, 1fr); gap: .5rem;
  max-width: 320px;
}
.color-swatch{
  aspect-ratio: 1; border-radius: 50%;
  cursor: pointer; transition: transform .1s;
  border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.color-swatch:hover{ transform: scale(1.1); }
.color-swatch.active{ box-shadow: 0 0 0 2px var(--brand); }

/* ----- Tabs (panel-internal) ----- */
.subtabs{
  display: flex; gap: 0; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
  margin-bottom: 1rem;
}
.subtabs::-webkit-scrollbar{ display: none; }
.subtab{
  padding: .65rem 1rem; font-size: .88rem; font-weight: 600;
  color: var(--ink-3); border-bottom: 2px solid transparent;
  white-space: nowrap; cursor: pointer; background: transparent; border-top:0; border-left:0; border-right:0;
}
.subtab.active{ color: var(--brand); border-bottom-color: var(--brand); }
.subtab:hover{ color: var(--ink); }

/* ----- Toast ----- */
.toast-stack{
  position: fixed; bottom: 1rem; right: 1rem; z-index: 100;
  display: flex; flex-direction: column; gap: .5rem;
  max-width: calc(100vw - 2rem);
}
.toast{
  background: #0f172a; color: #fff;
  padding: .85rem 1.1rem; border-radius: 10px;
  font-size: .9rem; font-weight: 500;
  display: flex; align-items: center; gap: .6rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  max-width: 360px;
}
.toast-ok{ background: #15803d; }
.toast-err{ background: #b91c1c; }
.toast .x{
  margin-left: auto; opacity: .7; cursor: pointer;
  background: transparent; color: inherit; padding: 0 .25rem;
}
@keyframes toastIn{
  from{ opacity: 0; transform: translateY(8px); }
  to{ opacity: 1; transform: translateY(0); }
}

/* ----- Quick actions grid (overview) ----- */
.quick-grid{
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem;
}
@media (min-width: 600px){ .quick-grid{ grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px){ .quick-grid{ grid-template-columns: repeat(4, 1fr); } }
.quick-card{
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem; cursor: pointer;
  display: flex; flex-direction: column; gap: .5rem;
  transition: transform .12s, border-color .12s, box-shadow .15s;
  text-align: left; width: 100%;
}
.quick-card:hover{
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--dash-elev-hover);
}
.quick-card .qc-icon{
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(10,124,58,.1); color: var(--brand);
}
.quick-card .qc-title{ font-weight: 700; font-size: .92rem; color: var(--ink); }
.quick-card .qc-desc{ font-size: .78rem; color: var(--ink-3); }

/* ----- Modal ----- */
.modal-back{
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,.6); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 1rem;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-back.open{ opacity: 1; pointer-events: auto; }
.modal{
  background: #fff; border-radius: var(--radius-lg);
  width: 100%; max-width: 480px; max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px); transition: transform .2s;
}
.modal-back.open .modal{ transform: translateY(0); }
.modal-head{
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h3{ margin: 0; }
.modal-head .x{
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3);
}
.modal-body{ padding: 1.5rem; }
.modal-foot{
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  display: flex; gap: .5rem; justify-content: flex-end;
  background: var(--surface-2);
}

/* ----- Search input ----- */
.search-box{
  position: relative;
}
.search-box input{
  width: 100%; padding: .7em 1em .7em 2.4em;
  background: var(--surface-2); border: 1.5px solid var(--line);
  border-radius: 10px; font-size: .92rem;
}
.search-box input:focus{
  outline: none; background: #fff; border-color: var(--brand);
}
.search-box svg{
  position: absolute; left: .85em; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--ink-3);
}

/* ----- Empty state ----- */
.empty-soft{
  text-align: center; padding: 2rem 1rem; color: var(--ink-3);
}
.empty-soft svg{
  width: 56px; height: 56px; margin: 0 auto .75rem;
  color: var(--line-strong);
}
.empty-soft h4{ margin: 0 0 .25rem; color: var(--ink-2); }
.empty-soft p{ margin: 0 0 1rem; font-size: .9rem; }

/* ----- Hotel/flight result cards ----- */
.result-card{
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem; margin-bottom: .75rem;
  display: grid; grid-template-columns: 1fr; gap: .75rem;
}
@media (min-width: 600px){
  .result-card{ grid-template-columns: 1fr auto; align-items: center; }
}
.result-card .rc-info h4{ margin: 0 0 .25rem; }
.result-card .rc-info .meta{
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  font-size: .82rem; color: var(--ink-3);
}
.result-card .rc-info .meta span{ white-space: nowrap; }
.result-card .rc-price{
  text-align: right; min-width: 130px;
}
.result-card .rc-price .price{
  font-size: 1.4rem; font-weight: 800; color: var(--brand-dark);
}
.result-card .rc-price .per{ font-size: .8rem; color: var(--ink-3); }
.result-card .rc-price .breakdown{ font-size: .72rem; color: var(--ink-3); margin: 2px 0 .5rem; }

.stars{ color: var(--gold); font-size: .85rem; }

/* Theme: dark mode (toggle adds class to <body>) */
body.dash.theme-dark{ background: #0b1220; color: #e2e8f0; }
body.dash.theme-dark .dash-top,
body.dash.theme-dark .dash-side,
body.dash.theme-dark .panel,
body.dash.theme-dark .stat,
body.dash.theme-dark .quick-card,
body.dash.theme-dark .modal,
body.dash.theme-dark .result-card{
  background: #111a2e;
  border-color: #1f2937;
  color: #e2e8f0;
}
body.dash.theme-dark .panel-foot{ background: #0b1220; }
body.dash.theme-dark .stat .value,
body.dash.theme-dark h1, body.dash.theme-dark h2, body.dash.theme-dark h3, body.dash.theme-dark h4,
body.dash.theme-dark .list-item .li-title{ color: #f1f5f9; }
body.dash.theme-dark .stat .label,
body.dash.theme-dark .list-item .li-meta,
body.dash.theme-dark .quick-card .qc-desc,
body.dash.theme-dark .dash-header p{ color: #94a3b8; }
body.dash.theme-dark .panel-head,
body.dash.theme-dark .list-item,
body.dash.theme-dark .setting-row,
body.dash.theme-dark .side-head,
body.dash.theme-dark .side-user,
body.dash.theme-dark .panel-foot,
body.dash.theme-dark .modal-head,
body.dash.theme-dark .modal-foot{ border-color: #1f2937; }
body.dash.theme-dark .list-item:hover,
body.dash.theme-dark .side-nav .nav-item:hover{ background: #0b1220; }
body.dash.theme-dark .input,
body.dash.theme-dark .select,
body.dash.theme-dark .textarea,
body.dash.theme-dark .search-box input{
  background: #0b1220; border-color: #1f2937; color: #e2e8f0;
}
body.dash.theme-dark .surface-2,
body.dash.theme-dark .panel-foot{ background: #0b1220 !important; }

/* ============================================================
   Mobile-first payment sheet (multi-step modal)
   ============================================================ */
.modal-back.payment-sheet-back .modal,
.modal.payment-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
}
@media (max-width: 600px){
  .modal-back .modal.payment-sheet {
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    margin: 0;
    border-radius: 0;
  }
  .modal-back { padding: 0; align-items: stretch; }
  .modal-back.open .modal.payment-sheet {
    transform: translateY(0);
    animation: slideUp .25s ease;
  }
  @keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
}

/* Payment method picker grid (Step 1) */
.pay-method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .65rem;
}
.pay-method-card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 1rem .75rem;
  cursor: pointer;
  transition: all .15s ease;
  text-align: center;
  display: flex; flex-direction: column; gap: .35rem;
  align-items: center;
  min-height: 110px;
  justify-content: center;
}
.pay-method-card:hover, .pay-method-card:active {
  border-color: var(--brand);
  background: rgba(10,124,58,.04);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(10,124,58,0.1);
}
.pay-method-card .pmc-icon {
  font-size: 2rem;
  line-height: 1;
}
.pay-method-card .pmc-label {
  font-weight: 700;
  font-size: .88rem;
  color: var(--ink);
}
.pay-method-card .pmc-count {
  font-size: .7rem;
  color: var(--ink-3);
}

/* Account row (Step 2 list) */
.acc-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: left;
}
.acc-row:hover, .acc-row:active {
  border-color: var(--brand);
  background: rgba(10,124,58,.03);
}

/* Account detail rows (Step 3) */
.acc-detail-row {
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--line);
}
.acc-detail-row:last-child { border-bottom: 0; }

/* Back button */
.back-btn {
  background: none;
  border: 0;
  color: var(--brand);
  font-size: .85rem;
  font-weight: 600;
  padding: .25rem 0;
  cursor: pointer;
}
.back-btn:hover { text-decoration: underline; }

/* ============================================================
   RTL support (Arabic)
   ============================================================ */
[dir="rtl"] .dash-shell { direction: rtl; }
[dir="rtl"] .nav-item { text-align: right; }
[dir="rtl"] .nav-item .icon { margin-right: 0; margin-left: .65rem; }
[dir="rtl"] .li-right { text-align: left; }
[dir="rtl"] .back-btn::before { content: '→ '; }
[dir="rtl"] .back-btn { content: ''; }
/* Keep numbers and codes LTR */
[dir="rtl"] code,
[dir="rtl"] .tt,
[dir="rtl"] .ref,
[dir="rtl"] [style*="font-family:monospace"] { direction: ltr; unicode-bidi: embed; display: inline-block; }
