/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  --blue:        #003F8A;
  --blue-mid:    #0052b3;
  --blue-dark:   #002B7F;
  --gold:        #F5A623;
  --gold-dark:   #d4880a;
  --sand:        #F2E8D5;
  --sand-dark:   #e5d8c3;
  --bg:          #EEF2FA;
  --white:       #FFFFFF;
  --text:        #1A1A2E;
  --muted:       #64748b;
  --danger:      #C62828;
  --success:     #2E7D32;
  --warn:        #E65100;
  --radius:      14px;
  --radius-sm:   8px;
  --radius-pill: 999px;
  --shadow-sm:   0 2px 8px rgba(0,63,138,.08);
  --shadow-md:   0 4px 20px rgba(0,63,138,.12);
  --trans:       0.2s ease;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  /* Subtle animated gradient background */
  background: linear-gradient(135deg, #dde8fb 0%, #eef2fa 40%, #f5eee0 100%);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 56px;
  background: var(--blue);
  /* Glass effect on scroll */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 16px rgba(0,43,127,.35);
}

/* Decorative top stripe (Israeli flag inspired) */
.app-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold) 0%, #fff8e1 50%, var(--gold) 100%);
}

.app-header__back {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--trans);
  padding: 4px 0;
}
.app-header__back:hover { color: #fff; }

.app-header__title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

/* ── Main Layout ─────────────────────────────────────────────────────────── */
.app-main {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px;
  animation: cardIn 0.35s ease both;
}

.card--results {
  background: rgba(255,255,255,0.9);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -0.2px;
}

.card__title-icon { font-size: 18px; line-height: 1; }

/* ── Stats Bar ───────────────────────────────────────────────────────────── */
.stats-bar {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--sand);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* ── Add Row ─────────────────────────────────────────────────────────────── */
.add-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.add-row .input { flex: 1; min-width: 0; }

/* ── CSV Row ─────────────────────────────────────────────────────────────── */
.csv-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.csv-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--sand);
  border: 1px solid var(--sand-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--trans);
  -webkit-tap-highlight-color: transparent;
}
.csv-label:hover { background: var(--sand-dark); }

.csv-template-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--blue);
  background: transparent;
  border: 1px solid rgba(0,63,138,.25);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--trans), border-color var(--trans);
  -webkit-tap-highlight-color: transparent;
}
.csv-template-btn:hover {
  background: rgba(0,63,138,.06);
  border-color: var(--blue);
}

.csv-hint {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 11px 13px;
  font-size: 16px;      /* 16px+ prevents iOS zoom */
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  border: 1.5px solid #d1d9e8;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--trans), box-shadow var(--trans);
  -webkit-appearance: none;
}
.input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,63,138,.12);
}
.input--sm  { font-size: 15px; padding: 8px 11px; }
.input--pct { width: 64px; text-align: center; padding: 8px 6px; font-size: 15px; }
.input--amount { max-width: 130px; font-size: 16px; }

/* Shake animation for empty-name add attempt */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}
.input--shake { animation: shake 0.4s ease; border-color: var(--danger) !important; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--trans), opacity var(--trans), box-shadow var(--trans);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,63,138,.3);
}
.btn--primary:hover { background: var(--blue-mid); }

.btn--share {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff;
  flex: 1;
  box-shadow: 0 2px 12px rgba(213,136,10,.35);
  font-size: 15px;
  padding: 14px 20px;
  border-radius: var(--radius);
}
.btn--share:hover { opacity: 0.92; }

.btn--ghost {
  background: rgba(0,63,138,.06);
  color: var(--muted);
  border: 1.5px solid rgba(0,63,138,.12);
  font-size: 13px;
  padding: 11px 16px;
}
.btn--ghost:hover { background: rgba(0,63,138,.10); color: var(--text); }

.btn-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
  -webkit-tap-highlight-color: transparent;
}
.btn-remove:hover, .btn-remove:active { background: rgba(198,40,40,.1); color: var(--danger); }

/* ── Actions Row ─────────────────────────────────────────────────────────── */
.actions-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

/* ── Participant List ─────────────────────────────────────────────────────── */
#participant-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

/* Entrance animation for participant items */
@keyframes piIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.participant-item {
  background: linear-gradient(135deg, var(--sand) 0%, #ede4d0 100%);
  border: 1px solid rgba(0,63,138,.08);
  border-radius: 12px;
  padding: 14px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease, box-shadow 0.2s ease;
}
.participant-item.pi-visible { opacity: 1; animation: piIn 0.25s ease both; }
.participant-item:hover { box-shadow: 0 4px 16px rgba(0,63,138,.10); }

/* Removing animation */
.participant-item.pi-removing {
  opacity: 0;
  transform: translateX(12px);
}

.pi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.pi-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.pi-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Currency Pills ──────────────────────────────────────────────────────── */
.currency-pills {
  display: flex;
  gap: 6px;
}

.pill {
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: 1.5px solid var(--blue);
  border-radius: var(--radius-pill);
  background: var(--white);
  color: var(--blue);
  cursor: pointer;
  min-height: 36px;
  transition: background var(--trans), color var(--trans), transform var(--trans);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.pill:hover:not(.pill--active) { background: rgba(0,63,138,.06); }
.pill--active {
  background: var(--blue);
  color: var(--white);
  box-shadow: 0 2px 6px rgba(0,63,138,.25);
}
.pill:active { transform: scale(0.95); }

/* ── Other Currency ──────────────────────────────────────────────────────── */
.currency-other {
  width: 100%;
  margin-top: 10px;
}

.currency-other__toggle {
  font-size: 12px;
  font-weight: 500;
  color: var(--blue);
  cursor: pointer;
  list-style: none;
  padding: 4px 0;
  user-select: none;
  transition: opacity var(--trans);
}
.currency-other__toggle::-webkit-details-marker { display: none; }
.currency-other__toggle::before { content: '▸\00a0'; font-size: 10px; }
details[open] .currency-other__toggle::before { content: '▾\00a0'; }
.currency-other__toggle:hover { opacity: 0.75; }
.currency-other .input { margin-top: 8px; }

/* ── Split Section ───────────────────────────────────────────────────────── */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.split-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.split-field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.split-field__pct {
  font-size: 36px;
  font-weight: 900;
  color: var(--blue);
  letter-spacing: -1.5px;
  line-height: 1;
}

.slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #d1d9e8;
  outline: none;
  cursor: pointer;
  accent-color: var(--blue);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid var(--white);
  box-shadow: 0 2px 8px rgba(0,63,138,.3);
  cursor: pointer;
  transition: transform 0.1s ease;
}
.slider::-webkit-slider-thumb:active { transform: scale(1.2); }
.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid var(--white);
  box-shadow: 0 2px 8px rgba(0,63,138,.3);
  cursor: pointer;
}

.split-input-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.split-unit {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.split-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* ── Results ─────────────────────────────────────────────────────────────── */

/* Summary bar */
.result-summary-bar {
  display: flex;
  align-items: center;
  background: var(--sand);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  gap: 0;
}
.result-summary-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.result-summary-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}
.result-summary-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue);
}
.result-summary-sep {
  width: 1px;
  height: 36px;
  background: rgba(0,63,138,.15);
  flex-shrink: 0;
}

/* Per-currency breakdown */
.cur-breakdown {
  background: rgba(0,63,138,.04);
  border: 1px solid rgba(0,63,138,.08);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.cur-breakdown__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 10px;
}
.cur-breakdown__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cur-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cur-row__currency {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  background: rgba(0,63,138,.1);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  min-width: 44px;
  text-align: center;
}
.cur-row__amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.cur-row__count {
  font-size: 12px;
  color: var(--muted);
}

/* Main result cards — stacked vertically, full width */
.result-columns {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-card {
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.result-card--guide {
  background: linear-gradient(135deg, #003F8A 0%, #0052b3 100%);
  color: #fff;
}
.result-card--driver {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d3561 100%);
  color: #fff;
}

.result-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.result-card__badge {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.9;
}

.result-card__pct {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.5px;
  opacity: 0.35;
}

/* Per-currency rows inside each result card */
.result-card__currencies {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-card__cur-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-card__cur-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(255,255,255,0.2);
  padding: 3px 8px;
  border-radius: 999px;
  min-width: 46px;
  text-align: center;
  flex-shrink: 0;
}

.result-card__cur-amount {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

/* Warning box */
.result-warn {
  background: #fff3e0;
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  color: #7a4200;
  margin-bottom: 12px;
}

/* Total pool row */
.result-total {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 4px 2px;
}
.result-total__label { font-weight: 600; }

/* Empty / loading state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.empty-state__icon {
  font-size: 36px;
  opacity: 0.6;
}

/* ── Toast Notification ──────────────────────────────────────────────────── */
@keyframes toastIn  { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(-50%) translateY(6px); } }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  z-index: 9999;
  max-width: calc(100vw - 32px);
  text-align: center;
  animation: toastIn 0.25s ease both;
  pointer-events: none;
  box-shadow: 0 4px 24px rgba(0,0,0,.20);
}
.toast--out  { animation: toastOut 0.3s ease both; }
.toast--info    { background: var(--blue);    color: #fff; }
.toast--warn    { background: var(--warn);    color: #fff; }
.toast--error   { background: var(--danger);  color: #fff; }
.toast--success { background: var(--success); color: #fff; }

/* ── Card entrance animation ─────────────────────────────────────────────── */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.10s; }
.card:nth-child(3) { animation-delay: 0.15s; }

/* ── Mobile adjustments ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .app-main { padding: 16px 12px 100px; }

  .result-card__cur-amount { font-size: 20px; }

  .split-grid { gap: 16px; }
  .split-field__pct { font-size: 30px; }

  .actions-row { flex-direction: column; }
  .btn--share { width: 100%; }
  .btn--ghost { width: 100%; }
}

@media (max-width: 360px) {
  .currency-pills { flex-wrap: wrap; }
  .pill { padding: 6px 10px; }
}
