/* ==========================================================================
   style.css - Raj Fitness Club
   Dark gym theme, mobile-first. Change colours in the :root block below.
   ========================================================================== */

:root {
  --bg: #121212;
  --surface: #1b1b1d;
  --surface-2: #232326;
  --line: #2f2f33;
  --text: #f2f2f2;
  --muted: #9a9aa2;

  --accent: #ff4500;        /* main brand colour (buttons, highlights) */
  --accent-press: #e03d00;
  --green: #00e676;         /* Active */
  --yellow: #ffc400;        /* Expiring soon */
  --red: #ff4d4d;           /* Expired */

  --radius: 12px;
  --font-display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; line-height: 1.1; letter-spacing: .01em; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.4rem; }
p { margin: 0; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* ---------- Loader ---------- */
.loader { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 100; transition: opacity .25s; }
.loader.done { opacity: 0; pointer-events: none; }
.spinner { width: 38px; height: 38px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App bar ---------- */
.appbar { position: sticky; top: 0; z-index: 20; background: rgba(18,18,18,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.appbar-inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.appbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--accent); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: .02em; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; }
.brand-lg .brand-mark { width: 56px; height: 56px; font-size: 1.9rem; border-radius: 12px; }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card > h3 { margin-bottom: 14px; }

/* ---------- Buttons ---------- */
.btn { font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; cursor: pointer; transition: background .15s, border-color .15s, transform .05s; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-press); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-wa { background: #1faa59; color: #fff; }
.btn-wa:hover { background: #188a49; }
.btn-danger { background: transparent; color: var(--red); border-color: #5a2a2a; }
.btn-danger:hover { background: #2a1717; }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: .9rem; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1.8rem; line-height: 1; cursor: pointer; padding: 0 6px; }
.icon-btn:hover { color: var(--text); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: .9rem; color: var(--muted); font-weight: 500; }
input, select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; min-height: 44px; }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(255,69,0,.2); }
input::placeholder { color: #6a6a72; }
input[type="date"] { color-scheme: dark; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 70px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font: inherit; font-size: .85rem; padding: 8px; cursor: pointer; }
.form-error { color: var(--red); background: #2a1717; border: 1px solid #5a2a2a; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: .92rem; }
.notice { padding: 10px 12px; border-radius: 10px; margin: 14px 0; font-size: .92rem; }
.notice-warn { background: #2b2410; border: 1px solid #5c4a10; color: var(--yellow); }
.grid-2 { display: grid; gap: 0 14px; grid-template-columns: 1fr; }

/* ---------- Login ---------- */
.login-view { min-height: calc(100vh - 20px); display: grid; place-items: center; padding: 20px 16px;
  background: radial-gradient(900px 400px at 50% -10%, rgba(255,69,0,.18), transparent 60%); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px 22px; display: grid; gap: 6px; }
.login-card .brand { margin-bottom: 8px; }
.login-card form { margin-top: 14px; }
.login-card .muted.small { margin-top: 12px; }

/* ---------- Status badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-active { color: var(--green); background: rgba(0,230,118,.1); border-color: rgba(0,230,118,.35); }
.badge-expiring { color: var(--yellow); background: rgba(255,196,0,.1); border-color: rgba(255,196,0,.35); }
.badge-expired { color: var(--red); background: rgba(255,77,77,.1); border-color: rgba(255,77,77,.35); }

/* ---------- Member dashboard ---------- */
.profile-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--accent); display: grid; place-items: center; font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; flex: none; }
.profile-id { flex: 1; min-width: 0; }
.profile-id h2 { overflow-wrap: anywhere; }

.countdown { display: grid; gap: 16px; margin: 22px 0; padding: 20px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); align-items: center; }
.days { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.days span { font-family: var(--font-display); font-weight: 700; font-size: clamp(4.5rem, 22vw, 7rem); line-height: .9; color: var(--green); }
.days small { color: var(--muted); font-size: 1rem; }
.countdown[data-status="expiring"] .days span { color: var(--yellow); }
.countdown[data-status="expired"] .days span { color: var(--red); }
.live { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-bottom: 10px; }
.progress { height: 8px; background: #101012; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; border-radius: 99px; background: var(--green); transition: width .6s; }
.countdown[data-status="expiring"] .progress > div { background: var(--yellow); }
.countdown[data-status="expired"] .progress > div { background: var(--red); }
.countdown .small { margin-top: 8px; }

.details { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; margin: 0; }
.details dt { color: var(--muted); font-size: .85rem; }
.details dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Admin: stats ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.stat-green { border-left-color: var(--green); }
.stat-red { border-left-color: var(--red); }
.stat-orange { border-left-color: var(--accent); }
.stat-num { font-family: var(--font-display); font-weight: 700; font-size: 2.4rem; line-height: 1; }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-sub { color: var(--yellow); font-size: .8rem; min-height: 1em; }

/* ---------- Admin: toolbar & filters ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.toolbar h3 { margin: 0; }
.filters { display: grid; gap: 12px; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { font: inherit; font-size: .92rem; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.chip b { color: var(--muted); font-weight: 600; margin-left: 4px; }
.chip.is-on { background: var(--accent); border-color: var(--accent); }
.chip.is-on b { color: #fff; }

/* ---------- Tables (turn into stacked cards on phones) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: .85rem; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.mname { font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.amount { font-weight: 600; color: var(--green); }
.mono { font-variant-numeric: tabular-nums; }

@media (max-width: 767px) {
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; margin-bottom: 10px; }
  .table.stack td { border: 0; padding: 7px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; flex: none; }
  .table.stack td.actions { justify-content: flex-start; padding-top: 10px; border-top: 1px solid var(--line); margin-top: 4px; }
  .table.stack td.actions::before { display: none; }
}

/* ---------- Dialogs ---------- */
.dialog { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
.dialog-wide { width: min(760px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(0,0,0,.7); }
.dialog[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
.dialog form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 18px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 30px); background: #2a2a2e; border: 1px solid var(--line); border-left: 4px solid var(--green); padding: 12px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-left-color: var(--red); }

/* ---------- Larger screens ---------- */
@media (min-width: 768px) {
  .container { padding: 24px; gap: 20px; }
  .card { padding: 24px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .details { grid-template-columns: repeat(4, 1fr); }
  .countdown { grid-template-columns: auto 1fr; gap: 40px; padding: 24px 28px; }
  .filters { grid-template-columns: 320px 1fr; align-items: center; }
  .who { max-width: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
