/* =============================================================================
   styles.css  —  Poker Tracker  (dark, near-monochrome: money is the only color)
   ========================================================================== */

/* ----------------------------------------------------------------------------
   THEME TOKENS
   ------------------------------------------------------------------------- */
:root {
  --bg:          #0B0B0D;   /* app background (near-black)            */
  --surface:     #161618;   /* cards                                  */
  --surface-2:   #202024;   /* inputs, segmented track                */
  --surface-3:   #2A2A30;   /* pressed / hover                        */
  --border:      rgba(255, 255, 255, 0.08);
  --border-2:    rgba(255, 255, 255, 0.14);

  --text:        #F5F5F7;   /* primary text (near-white = the accent) */
  --text-dim:    #9A9AA1;   /* secondary                              */
  --text-faint:  #67676E;   /* labels, captions                       */

  --money-up:    #30D158;   /* profit green  — the ONLY real color    */
  --money-down:  #FF453A;   /* loss red                               */

  --r:    18px;   /* card radius        */
  --r-sm: 13px;   /* input radius       */
  --r-xs: 10px;
  --pill: 999px;

  --maxw: 520px;  /* phone-first; centers if opened on desktop */

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ----------------------------------------------------------------------------
   RESET / BASE
   ------------------------------------------------------------------------- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;          /* no rubber-band on the whole page */
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
button { cursor: pointer; background: none; border: none; }

.money { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.up   { color: var(--money-up); }
.down { color: var(--money-down); }

/* ----------------------------------------------------------------------------
   APP SHELL
   ------------------------------------------------------------------------- */
#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100%;
  padding: calc(var(--safe-top) + 8px) 18px calc(var(--safe-bottom) + 120px);
  position: relative;
}

/* header --------------------------------------------------------------------*/
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  margin-bottom: 6px;
}
.app-header .title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text);
}
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--pill);
  color: var(--text-dim);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.icon-btn:active { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }

/* ----------------------------------------------------------------------------
   HERO  —  big all-time profit + win rate
   ------------------------------------------------------------------------- */
.hero {
  text-align: center;
  padding: 22px 0 14px;
}
.hero-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.hero-value {
  font-size: clamp(46px, 15vw, 64px);
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1;
}
.hero-value.flat { color: var(--text); }     /* exactly ₪0 */
.hero-sub {
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-dim);
}
.hero-sub strong { color: var(--text); font-weight: 600; }

/* ----------------------------------------------------------------------------
   CHART
   ------------------------------------------------------------------------- */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 12px 10px;
  margin-top: 6px;
}
.chart-wrap {
  position: relative;
  width: 100%;
  height: 168px;
  touch-action: none;            /* the chart owns drags here (scrub, not scroll) */
  -webkit-user-select: none;
  user-select: none;
}
.chart-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* scrub crosshair readout pill (stock-app style) */
.scrub-readout {
  position: absolute;
  top: 6px;
  left: 0;
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 5px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--pill);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  pointer-events: none;          /* never eats the drag */
  font-variant-numeric: tabular-nums;
}
.scrub-readout .sr-date { font-size: 12px; color: var(--text-dim); }
.scrub-readout .sr-val  { font-size: 14px; font-weight: 700; }

.chart-empty {
  height: 168px;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: 14px;
  text-align: center;
  line-height: 1.5;
}

/* timeframe segmented control */
.timeframe {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  background: var(--surface-2);
  border-radius: var(--pill);
  padding: 4px;
}
.timeframe button {
  flex: 1;
  height: 34px;
  border-radius: var(--pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.15s var(--ease), background 0.2s var(--ease);
}
.timeframe button.active {
  background: var(--text);     /* near-white pill = the monochrome "accent" */
  color: var(--bg);
}

/* ----------------------------------------------------------------------------
   SESSIONS LIST
   ------------------------------------------------------------------------- */
.list-section { margin-top: 26px; }
.list-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  padding-left: 4px;
}

.date-group { margin-bottom: 18px; }
.date-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  padding: 0 4px 8px;
}

.rows {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 12px 16px;
  text-align: left;
  transition: background 0.12s var(--ease);
}
.row:not(:last-child) { border-bottom: 1px solid var(--border); }
.row:active { background: var(--surface-2); }

.row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.row-game { font-size: 16px; font-weight: 600; color: var(--text); }
.row-meta { font-size: 13px; color: var(--text-faint); display: flex; align-items: center; gap: 7px; }
.row-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-faint); flex: none; }
.row-date { color: var(--text-dim); }

.row-profit { font-size: 17px; font-weight: 700; white-space: nowrap; }

/* empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
}
.empty .big { font-size: 15px; color: var(--text-dim); margin-bottom: 4px; }
.empty .small { font-size: 13px; }

/* ----------------------------------------------------------------------------
   FAB  (+)
   ------------------------------------------------------------------------- */
.fab {
  position: fixed;
  right: max(18px, calc(50% - var(--maxw) / 2 + 18px));
  bottom: calc(var(--safe-bottom) + 22px);
  width: 60px; height: 60px;
  border-radius: var(--pill);
  background: var(--text);          /* white button on dark = money-app vibe */
  color: var(--bg);
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s var(--ease), opacity 0.2s var(--ease);
  z-index: 30;
}
.fab:active { transform: scale(0.92); }
.fab svg { width: 28px; height: 28px; }

/* ----------------------------------------------------------------------------
   SHEETS / MODALS  (entry form, menu)
   ------------------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
  z-index: 40;
  backdrop-filter: blur(2px);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: var(--maxw);
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--border-2);
  padding: 10px 18px calc(var(--safe-bottom) + 22px);
  transition: transform 0.28s var(--ease);
  z-index: 50;
  max-height: 92vh;
  overflow-y: auto;
}
.sheet.open { transform: translate(-50%, 0); }

.sheet-grip {
  width: 38px; height: 5px; border-radius: 3px;
  background: var(--surface-3);
  margin: 6px auto 14px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.sheet-title { font-size: 19px; font-weight: 700; }
.sheet-cancel { font-size: 16px; color: var(--text-dim); padding: 6px 2px; }

/* ----------------------------------------------------------------------------
   FORM
   ------------------------------------------------------------------------- */
.field { margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 9px;
  padding-left: 2px;
}

/* segmented control (game type, venue) */
.segmented {
  display: flex;
  gap: 5px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 5px;
}
.segmented button {
  flex: 1;
  height: 46px;
  border-radius: var(--r-xs);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.15s var(--ease), background 0.2s var(--ease);
}
.segmented button.active {
  background: var(--text);
  color: var(--bg);
}

/* money + text inputs */
.input {
  width: 100%;
  height: 54px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 0 16px;
  font-size: 17px;
  color: var(--text);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.input:focus { outline: none; border-color: var(--border-2); background: var(--surface-3); }
.input::placeholder { color: var(--text-faint); }

/* money input with a ₪ prefix */
.money-input { position: relative; }
.money-input .prefix {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  font-size: 17px;
  color: var(--text-faint);
  pointer-events: none;
}
.money-input .input { padding-left: 34px; font-variant-numeric: tabular-nums; }

textarea.input {
  height: auto;
  min-height: 80px;
  padding: 14px 16px;
  resize: none;
  line-height: 1.4;
}

/* live profit preview inside the form */
.profit-preview {
  text-align: center;
  font-size: 15px;
  color: var(--text-faint);
  margin: 2px 0 20px;
  min-height: 20px;
}
.profit-preview .amount { font-weight: 700; font-size: 17px; }

/* ----------------------------------------------------------------------------
   BUTTONS
   ------------------------------------------------------------------------- */
.btn {
  width: 100%;
  height: 54px;
  border-radius: var(--r-sm);
  font-size: 17px;
  font-weight: 700;
  transition: transform 0.1s var(--ease), opacity 0.15s var(--ease), background 0.15s var(--ease);
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:disabled { opacity: 0.4; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--money-down); border: 1px solid var(--border-2); }
.btn-row { display: flex; gap: 12px; margin-top: 4px; }
.btn-row .btn { margin-top: 0; }

.menu-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 0 6px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  border-radius: var(--r-sm);
  transition: background 0.12s var(--ease);
}
.menu-item:active { background: var(--surface-2); }
.menu-item .mi-icon { width: 40px; height: 40px; border-radius: var(--r-xs); background: var(--surface-2); display: grid; place-items: center; color: var(--text-dim); flex: none; }
.menu-item .mi-icon svg { width: 20px; height: 20px; }
.menu-item .mi-text { display: flex; flex-direction: column; gap: 2px; }
.menu-item .mi-sub { font-size: 13px; color: var(--text-faint); font-weight: 400; }
.menu-sep { height: 1px; background: var(--border); margin: 8px 0; }

/* ----------------------------------------------------------------------------
   CONFIRM DIALOG
   ------------------------------------------------------------------------- */
.dialog {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  width: calc(100% - 64px);
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  padding: 22px 20px 18px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
  text-align: center;
}
.dialog.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.dialog-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.dialog-msg { font-size: 14px; color: var(--text-dim); line-height: 1.45; margin-bottom: 20px; }

/* ----------------------------------------------------------------------------
   TOAST  (errors + confirmations — never fail silently)
   ------------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 96px);
  transform: translate(-50%, 16px);
  max-width: calc(var(--maxw) - 36px);
  width: max-content;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 13px 18px;
  border-radius: var(--pill);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--money-down); }

/* hidden helper */
[hidden] { display: none !important; }

/* ----------------------------------------------------------------------------
   AUTH SCREEN  (login / signup — shown only when logged out)
   ------------------------------------------------------------------------- */
.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px calc(20px + env(safe-area-inset-right, 0px))
           calc(24px + var(--safe-bottom)) calc(20px + env(safe-area-inset-left, 0px));
  background: var(--bg);
  z-index: 100;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 26px 20px 20px;
}
.auth-brand {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
}
.auth-tagline {
  margin: 6px 0 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}
.auth-tabs { margin-bottom: 18px; }
.auth-error {
  margin: 4px 0 12px;
  color: var(--money-down);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}
.auth-hint {
  margin-top: 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.5;
}
