/* Shared layout for auth pages, user dashboard, and admin panel.
   Uses the same design tokens as assets/css/style.css (include that first). */

.app-body { background: var(--muted); min-height: 100vh; }

/* ---- Auth pages (signup/login) ---- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border); border-radius: 1rem; padding: 2rem; box-shadow: 0 15px 40px oklch(0.35 0.02 265 / .08); }
.auth-card h1 { font-size: 1.5rem; margin: .75rem 0 .25rem; }
.auth-card .sub { color: var(--muted-foreground); font-size: .85rem; margin-bottom: 1.5rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .78rem; font-weight: 700; margin-bottom: .35rem; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: .6rem; padding: .65rem .8rem;
  font-family: inherit; font-size: .85rem; background: var(--background); color: var(--foreground);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px oklch(0.69 0.2 45 / .12); }
.field-hint { font-size: .72rem; color: var(--muted-foreground); margin-top: .3rem; }
.auth-foot { margin-top: 1.25rem; text-align: center; font-size: .82rem; color: var(--muted-foreground); }
.auth-foot a { color: var(--primary); font-weight: 700; }
.alert { border-radius: .6rem; padding: .7rem .9rem; font-size: .82rem; margin-bottom: 1rem; }
.alert-error { background: oklch(0.95 0.05 25); color: oklch(0.4 0.15 25); }
.alert-success { background: oklch(0.94 0.04 150); color: oklch(0.35 0.1 150); }

/* ---- App shell (dashboard + admin) ---- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { width: 240px; flex: 0 0 240px; background: var(--card); border-right: 1px solid var(--border); padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: .25rem; }
.app-sidebar .brand-mark { padding: 0 .5rem 1.5rem; }
.app-sidebar a { display: flex; align-items: center; gap: .6rem; padding: .65rem .75rem; border-radius: .6rem; font-size: .85rem; font-weight: 600; color: var(--muted-foreground); }
.app-sidebar a:hover { background: var(--accent); color: var(--foreground); }
.app-sidebar a.active { background: var(--primary); color: var(--primary-foreground); }
.app-sidebar .logout { margin-top: auto; color: var(--destructive, oklch(0.6 0.2 25)); }
.app-main { flex: 1; min-width: 0; padding: 2rem; }
.app-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.app-topbar h1 { font-size: 1.4rem; margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: .9rem; padding: 1.1rem; }
.stat-card span { display: block; font-size: .72rem; color: var(--muted-foreground); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat-card strong { display: block; margin-top: .4rem; font-size: 1.4rem; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: .9rem; padding: 1.4rem; margin-bottom: 1.5rem; }
.panel h2 { font-size: 1.05rem; margin: 0 0 1rem; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.data-table th, table.data-table td { text-align: left; padding: .65rem .5rem; border-bottom: 1px solid var(--border); }
table.data-table th { color: var(--muted-foreground); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; }
.pill { display: inline-block; border-radius: 999px; padding: .2rem .6rem; font-size: .68rem; font-weight: 700; }
.pill-pending { background: oklch(0.95 0.05 80); color: oklch(0.45 0.12 80); }
.pill-processing { background: var(--accent); color: var(--primary); }
.pill-completed, .pill-active, .pill-successful { background: oklch(0.94 0.04 150); color: var(--success); }
.pill-cancelled, .pill-suspended, .pill-failed { background: oklch(0.95 0.05 25); color: oklch(0.5 0.15 25); }
.service-select-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.mini-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: .2rem; }
.mini-toggle a { padding: .4rem .9rem; border-radius: 999px; font-size: .75rem; font-weight: 700; color: var(--muted-foreground); }
.mini-toggle a.active { background: var(--primary); color: var(--primary-foreground); }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .app-sidebar { width: 100%; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .app-sidebar .logout { margin-top: 0; margin-left: auto; }
  .app-main { padding: 1.25rem; }
}

/* =====================================================================
   USER DASHBOARD — app-style shell (matches the mobile reference design)
   Used only by /dashboard/*.php. Admin keeps the desktop sidebar above.
   ===================================================================== */
.tmh-app { background: var(--muted); }
.mobile-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--background); position: relative; padding-bottom: 5.5rem; }

/* ---- Home header: greeting + currency pill + notification bell ---- */
.app-topbar-mobile { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.1rem .5rem; gap: .75rem; }
.greeting { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.greeting-avatar { flex: 0 0 auto; display: grid; place-items: center; width: 2.7rem; height: 2.7rem; border-radius: .9rem; background: var(--accent); color: var(--primary); font-weight: 800; font-size: 1.1rem; }
.greeting-text { min-width: 0; }
.greeting-text small { display: block; color: var(--muted-foreground); font-size: .72rem; }
.greeting-text strong { display: block; font-size: 1.05rem; }
.topbar-actions { display: flex; align-items: center; gap: .55rem; flex: 0 0 auto; }
.currency-pill { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; padding: .4rem .7rem; background: var(--card); border: 1px solid var(--border); font-size: .75rem; font-weight: 700; }
.bell-btn { position: relative; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--card); border: 1px solid var(--border); color: var(--foreground); }
.bell-dot { position: absolute; top: -.15rem; right: -.15rem; min-width: 1.05rem; height: 1.05rem; border-radius: 50%; background: var(--primary); color: #fff; font-size: .58rem; font-weight: 800; display: grid; place-items: center; padding: 0 .2rem; }

/* ---- Promo carousel (admin-managed flyers) ----
   Fixed-height box that never changes size regardless of the uploaded
   image's own dimensions (object-fit:cover normalizes it) — dots sit below
   as plain flow content, so this can never push the rest of the dashboard
   down. One full-width slide at a time, same side margins as every other
   home-page section (balance card, quick services) so it lines up exactly. */
.promo-carousel { margin: 1rem 1.1rem 0; }
.promo-viewport { position: relative; width: 100%; height: 160px; border-radius: 1rem; overflow: hidden; background: var(--muted); }
.promo-slide { position: absolute; inset: 0; opacity: 0; transition: opacity .5s ease; }
.promo-slide.active { opacity: 1; }
.promo-slide img { width: 100%; height: 100%; object-fit: cover; display: block; filter: blur(1.2px); }
.promo-dots { display: flex; justify-content: center; gap: .35rem; margin-top: .6rem; }
.promo-dots span { width: .4rem; height: .4rem; border-radius: 50%; background: oklch(0.85 0.01 265); }
.promo-dots span.active { background: var(--primary); width: 1.1rem; border-radius: 999px; }

/* ---- Simple top bar for inner pages (Services, Orders, Wallet, etc.) ---- */
.app-topbar-simple { display: flex; align-items: center; gap: .8rem; padding: 1.15rem 1.1rem .3rem; }
.app-topbar-simple a.back { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--card); border: 1px solid var(--border); color: var(--foreground); flex: 0 0 auto; }
.app-topbar-simple h1 { font-size: 1.15rem; margin: 0; }

/* ---- Balance card ---- */
.balance-card { margin: .75rem 1.1rem 0; border-radius: 1.1rem; padding: 1.4rem 1.25rem; background: linear-gradient(135deg, oklch(0.97 0.03 65), oklch(0.94 0.05 55)); border: 1px solid oklch(0.88 0.05 55); position: relative; overflow: hidden; }
.balance-card-head { display: flex; align-items: center; gap: .4rem; color: var(--muted-foreground); font-size: .82rem; font-weight: 600; }
.balance-amount { margin: .5rem 0 1.1rem; font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.quick-actions a { display: flex; flex-direction: column; align-items: center; gap: .5rem; border-radius: .9rem; padding: .8rem .3rem; background: var(--card); border: 1px solid oklch(0.9 0.03 55); font-size: .66rem; font-weight: 700; color: var(--foreground); text-align: center; }
.quick-actions a span.qa-icon { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--accent); color: var(--primary); }

/* ---- Quick services grid (Home page) ---- */
.section-row { display: flex; align-items: center; justify-content: space-between; margin: 1.6rem 1.1rem .8rem; }
.section-row h2 { font-size: 1rem; margin: 0; }
.section-row a { font-size: .78rem; font-weight: 700; color: var(--primary); }
.quick-services-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; padding: 0 1.1rem; }
.quick-services-grid a { display: flex; flex-direction: column; align-items: center; gap: .55rem; font-size: .68rem; font-weight: 700; color: var(--foreground); text-align: center; }
.quick-services-grid a.is-soon { opacity: .5; }
.qs-icon { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 1rem; background: var(--accent); color: var(--primary); }
.qs-icon.blue { background: oklch(0.94 0.04 250); color: oklch(0.58 0.18 250); }
.qs-icon.green { background: oklch(0.94 0.04 150); color: oklch(0.55 0.16 150); }
.qs-icon.violet { background: oklch(0.94 0.04 300); color: oklch(0.58 0.16 300); }

/* ---- Generic mobile content section (used by inner pages) ---- */
.m-section { margin: 1rem 1.1rem; }
.m-card { background: var(--card); border: 1px solid var(--border); border-radius: 1rem; padding: 1.1rem; margin-bottom: .9rem; }
.m-card h2 { font-size: .95rem; margin: 0 0 .8rem; }
.m-list-row { display: flex; align-items: center; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid var(--border); font-size: .78rem; }
.m-list-row:last-child { border-bottom: 0; }
.m-list-row > div { flex: 1; min-width: 0; }
.m-list-row b { display: block; font-size: .82rem; }
.m-list-row small { display: block; margin-top: .15rem; color: var(--muted-foreground); font-size: .68rem; }
.m-row-icon { flex: 0 0 auto; display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: .6rem; background: var(--accent); color: var(--primary); }

/* ---- Bottom tab bar ---- */
.bottom-nav { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 480px; display: flex; justify-content: space-around; background: var(--card); border-top: 1px solid var(--border); padding: .55rem .3rem calc(.55rem + env(safe-area-inset-bottom)); z-index: 40; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: .25rem; font-size: .62rem; font-weight: 700; color: var(--muted-foreground); flex: 1; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a span.nav-icon { display: grid; place-items: center; width: 1.3rem; height: 1.3rem; }

@media (min-width: 640px) {
  .mobile-shell { margin-top: 1.5rem; margin-bottom: 1.5rem; border-radius: 1.4rem; border: 1px solid var(--border); box-shadow: 0 20px 50px oklch(0.3 0.02 265 / .1); min-height: calc(100vh - 3rem); }
  .bottom-nav { border-radius: 0 0 1.4rem 1.4rem; }
}

/* ---- Dark mode toggle switch (Profile page) ---- */
.theme-switch { position: relative; display: inline-block; width: 2.6rem; height: 1.5rem; flex: 0 0 auto; margin-left: auto; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.theme-switch-track { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background-color .2s ease; cursor: pointer; }
.theme-switch-track::before { content: ""; position: absolute; height: 1.15rem; width: 1.15rem; left: .18rem; top: .17rem; background: #fff; border-radius: 50%; transition: transform .2s ease; box-shadow: 0 1px 3px oklch(0.2 0.02 265 / .3); }
.theme-switch input:checked + .theme-switch-track { background: var(--primary); }
.theme-switch input:checked + .theme-switch-track::before { transform: translateX(1.1rem); }

/* ---- Boosting / Numbers / Logs — shared "service catalog" UI ---- */
.wallet-strip { display: flex; align-items: center; gap: .5rem; background: var(--accent); border-radius: .8rem; padding: .7rem .9rem; margin-bottom: .8rem; font-size: .78rem; color: var(--muted-foreground); }
.wallet-strip b { color: var(--primary); font-size: .88rem; }
.wallet-strip a { margin-left: auto; font-weight: 700; color: var(--primary); font-size: .74rem; }
.chip-row { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .3rem; margin-bottom: .9rem; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: .4rem .85rem; border-radius: 999px; border: 1px solid var(--border); font-size: .74rem; font-weight: 700; color: var(--muted-foreground); background: var(--card); cursor: pointer; white-space: nowrap; }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }

.svc-card { background: var(--card); border: 1px solid var(--border); border-radius: 1rem; padding: 1rem; margin-bottom: .8rem; }
.svc-card-head { display: flex; align-items: center; gap: .7rem; }
.svc-icon { flex: 0 0 auto; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .7rem; background: var(--accent); color: var(--primary); }
.svc-icon.blue { background: oklch(0.94 0.04 250); color: oklch(0.58 0.18 250); }
[data-theme="dark"] .svc-icon.blue { background: oklch(0.3 0.06 250); color: oklch(0.82 0.08 250); }
.brand-icon-mask { display: inline-block; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; -webkit-mask-size: contain; mask-size: contain; }
.svc-card-title { flex: 1; min-width: 0; }
.svc-card-title b { display: block; font-size: .88rem; }
.svc-card-title small { color: var(--muted-foreground); font-size: .72rem; }
.svc-price { flex: 0 0 auto; color: var(--primary); font-size: .88rem; white-space: nowrap; }
.svc-price span { font-size: .65rem; font-weight: 600; color: var(--muted-foreground); }
.svc-desc { font-size: .76rem; color: var(--muted-foreground); margin: .6rem 0 0; line-height: 1.5; }

.order-disclosure { margin-top: .8rem; }
.order-disclosure summary { list-style: none; cursor: pointer; }
.order-disclosure summary::-webkit-details-marker { display: none; }
.order-disclosure[open] summary { margin-bottom: .8rem; background: var(--secondary); color: var(--secondary-foreground); }
.order-form { display: flex; flex-direction: column; gap: 0; }
.estimate-row { display: flex; justify-content: space-between; align-items: center; font-size: .76rem; color: var(--muted-foreground); background: var(--muted); border-radius: .6rem; padding: .55rem .75rem; margin: .3rem 0 .8rem; }
.estimate-row b { color: var(--primary); font-size: .88rem; }

/* ---- Admin quick-add shortcuts ---- */
.quick-add-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.quick-add-card { display: block; border: 1px solid var(--border); border-radius: .9rem; padding: 1.1rem; color: var(--foreground); transition: border-color .15s ease, transform .15s ease; }
.quick-add-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.quick-add-card .qa-icon { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .7rem; background: var(--accent); color: var(--primary); margin-bottom: .8rem; }
.quick-add-card .qa-icon.blue { background: oklch(0.94 0.04 250); color: oklch(0.58 0.18 250); }
.quick-add-card .qa-icon.green { background: oklch(0.94 0.04 150); color: oklch(0.55 0.16 150); }
.quick-add-card b { display: block; font-size: .88rem; }
.quick-add-card small { display: block; margin-top: .3rem; color: var(--muted-foreground); font-size: .74rem; }

/* ---- Inline edit rows in admin data tables (Services, Logs) ---- */
tr.edit-row { display: none; }
tr.edit-row.open { display: table-row; }
tr.edit-row td { background: var(--muted); padding: 1rem !important; }
.edit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; margin-bottom: .8rem; }
.edit-grid .field { margin-bottom: 0; }

/* ---- Invite & Earn (referral) page ---- */
.invite-hero { padding: .5rem 0 1.2rem; }
.invite-hero h1 { font-size: 1.7rem; font-weight: 800; margin: 0; }
.invite-hero h1 span { color: var(--primary); }
.invite-hero p { color: var(--muted-foreground); font-size: .85rem; margin: .4rem 0 0; }
.invite-via-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; text-align: center; }
.invite-via-grid a { color: var(--foreground); font-size: .72rem; font-weight: 700; }
.invite-icon { display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 50%; margin: 0 auto .5rem; }
.copy-link-row { display: flex; align-items: center; gap: .6rem; background: var(--card); border: 1px solid var(--border); border-radius: .9rem; padding: .8rem .9rem; margin: 1rem 0; }
.copy-link-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; color: var(--muted-foreground); }
.copy-link-row .btn { flex: 0 0 auto; height: 2.2rem; padding: 0 .9rem; font-size: .76rem; }
.how-it-works { background: var(--accent); border-radius: 1rem; padding: 1rem; }
.how-it-works-head { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: .92rem; margin-bottom: .8rem; color: var(--foreground); }
.step-row { display: flex; align-items: center; gap: .8rem; background: var(--card); border-radius: .8rem; padding: .8rem .9rem; margin-bottom: .6rem; }
.step-row:last-child { margin-bottom: 0; }
.step-row p { flex: 1; margin: 0; font-size: .8rem; }
.step-num { flex: 0 0 auto; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--primary); color: var(--primary-foreground); font-size: .74rem; font-weight: 800; }

/* ===========================================================
   RESPONSIVE PATCH — append-only, added without touching any
   existing rule above.
   =========================================================== */

/* ---- Admin data tables on phones/small tablets ----
   Every admin table sits inside a .panel. Rather than editing
   the markup of every admin page individually, this makes any
   .panel that overflows (i.e. contains a wide table) scroll
   horizontally on its own — panels without a table are
   completely unaffected since overflow-x:auto only does
   anything when content is actually wider than the box. */
.panel { overflow-x: auto; }
.panel table.data-table { min-width: 640px; }

/* ---- Admin sidebar on tablets: the existing row-of-icons
   layout below 900px gets a bit more breathing room and wraps
   its label text instead of clipping it ---- */
@media (max-width: 900px) {
  .app-sidebar a { flex: 0 0 auto; white-space: nowrap; font-size: .8rem; }
}

/* ---- Comfortable tap targets on touch screens, site-wide ----
   Small ghost/icon buttons (row actions, edit toggles) were
   sized for a mouse; this keeps a minimum touch-friendly height
   on touch devices only, without changing desktop's compact look. */
@media (hover: none) and (pointer: coarse) {
  .btn-ghost, .btn-icon, .chip, .bottom-nav a, .theme-switch { min-height: 40px; }
}

/* ---- Very small phones (under 360px): the mobile-shell's own
   1.1rem side padding plus card padding can crowd out content
   on the smallest screens still in real use ---- */
@media (max-width: 359px) {
  .app-topbar-mobile, .m-section, .balance-card, .promo-carousel { margin-left: .85rem; margin-right: .85rem; }
  .quick-services-grid, .service-select-grid, .edit-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: 1fr; }
}

/* ---- Tablet range (768–1023px): the mobile-shell's fixed
   480px width now sits with real breathing room on both sides
   rather than looking arbitrarily narrow next to empty space ---- */
@media (min-width: 768px) and (max-width: 1023px) {
  .mobile-shell { max-width: 560px; }
}
