/* Bill Splitter — dark theme. Blue-gray/purplish palette, yellow accents.
   Modern and flat: no glass, no gradients-for-the-sake-of-it. */

:root {
  color-scheme: dark;               /* native controls (selects, etc.) render dark */
  --bg: #12141c;                    /* deep blue-gray page background */
  --card: #1b1f2c;                  /* elevated surfaces */
  --card-2: #232839;                /* slightly higher elevation (hover, chips) */
  --border: #2c3245;
  --text: #e9ebf3;
  --muted: #8d93a8;
  --accent: #f6c945;                /* the yellow — primary actions, active tab */
  --accent-press: #e3b52e;
  --accent-ink: #17181f;            /* text on yellow */
  --violet: #8b93ff;                /* secondary tint — links, small highlights */
  --danger: #ff7575;
  --radius: 12px;
  --nav-height: 62px;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display rules below. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

h1 { font-size: 1.05rem; margin: 0; font-weight: 650; letter-spacing: 0.01em; }
.crumb { color: var(--muted); font-weight: 500; font-size: 0.92em; }
.muted { color: var(--muted); font-weight: normal; font-size: 0.85em; }

/* ---- Login ---- */
#login-view {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--card);
  padding: 2rem 2.2rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  text-align: center;
  min-width: 270px;
}
.login-card h1 { font-size: 1.3rem; }
.tagline {
  margin: 0.15rem 0 0.8rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}
.login-card button {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
}
.dev-badge {
  background: var(--card-2);
  color: var(--accent);
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  vertical-align: middle;
  border: 1px solid var(--border);
}

/* ---- Header ---- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.header-user { font-size: 0.85rem; color: var(--muted); }

/* ---- Bottom navigation ---- */
#tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); /* iPhone home-bar clearance */
  z-index: 10;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.66rem;
  letter-spacing: 0.03em;
  padding: 0;
  border-radius: 0;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--accent); }
.tab:hover { background: none; color: var(--text); }
.tab.active:hover { color: var(--accent); }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.2rem 1rem calc(var(--nav-height) + 1.2rem); /* keep clear of the nav */
}

/* ---- Forms ---- */
form label {
  display: block;
  margin: 1.05rem 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}
.hint {
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  color: var(--muted);
  opacity: 0.75;
}
input[type="text"], select {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--card);
  color: var(--text);
}
input::placeholder { color: var(--muted); opacity: 0.6; }
input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.field-row { display: flex; gap: 0.5rem; }
.field-row input { flex: 1; }
.field-row select.compact { width: auto; }

/* Paid by → Owed by, side by side */
.field-row.halves { align-items: flex-end; }
.field-row.halves > div { flex: 1; }
.row-arrow {
  flex: 0 0 auto !important;
  color: var(--muted);
  padding-bottom: 0.8rem;
  font-size: 0.95rem;
}

.preview {
  min-height: 1.3rem;
  margin-top: 0.25rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.preview .total { color: var(--accent); font-weight: 600; }
.preview .bad { color: var(--danger); }

button {
  padding: 0.7rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
}
button:hover { background: var(--accent-press); }
button.secondary {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}
button.secondary:hover { background: var(--border); }
/* Quiet text links — muted by default so yellow stays the only loud color;
   delete reveals its red only on hover. */
.link-btn {
  background: none; border: none; color: var(--muted);
  padding: 0; margin-left: 0.6rem; cursor: pointer; font-size: 0.85rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { background: none; color: var(--text); }

/* Delete: at the very bottom of the edit form, quiet until you mean it. */
.delete-btn {
  margin-top: 2.2rem;
  width: 100%;
  padding: 0.7rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--danger);
  font-weight: 500;
}
.delete-btn:hover { background: none; border-color: var(--danger); }

/* Save button: full width, tall — a thumb target you can't miss. */
.form-actions { margin-top: 1.4rem; display: flex; flex-direction: column; gap: 0.6rem; }
.form-actions button { width: 100%; padding: 0.95rem; font-size: 1.05rem; }
.error { margin-top: 0.8rem; color: var(--danger); font-size: 0.9rem; }

/* ---- Bill cards ---- */
.bill-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.95rem;
  margin-bottom: 0.6rem;
}
.bill-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
/* The bill title is the tap target that opens the bill for editing. */
.bill-title {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.bill-title:hover { background: none; color: var(--accent-press); text-decoration: underline; text-underline-offset: 3px; }
.bill-amount { white-space: nowrap; font-weight: 650; }
.bill-meta { font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }

/* ---- Balances ---- */
.balance-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
  margin-bottom: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.balance-card strong { color: var(--accent); }
.settle-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  width: 100%;
  margin-top: 0.5rem;
}
.settle-form input { flex: 1; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 0;
}

/* ---- Cats (as promised to Martina) ---- */
.cat-peek {
  position: fixed;
  bottom: calc(var(--nav-height) - 6px); /* cats peek from behind the nav bar */
  z-index: 9;                             /* …so they slide out UNDER it: 9 < nav's 10 */
  pointer-events: none;                   /* cats never block clicks */
  line-height: 1;
  transform: translateY(105%) rotate(var(--tilt, 0deg));
  animation: cat-peek 3.2s ease-in-out forwards;
}
.cat-bubble {
  position: absolute;
  top: -1.2em;
  left: 70%;
  font-size: 0.85rem;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  color: var(--text);
  white-space: nowrap;
}
@keyframes cat-peek {
  0%   { transform: translateY(105%) rotate(var(--tilt, 0deg)); }
  18%  { transform: translateY(8%)   rotate(var(--tilt, 0deg)); }
  82%  { transform: translateY(8%)   rotate(var(--tilt, 0deg)); }
  100% { transform: translateY(105%) rotate(var(--tilt, 0deg)); }
}
