/* ===================================================================
   /log — manual data entry surface
   ===================================================================
   Auth-required page for logging the things HealthKit + wearables
   can't measure. Pulls design tokens from main.css; this file only
   defines page-local layouts.
   =================================================================== */

/* ---- Layout ---- */
.log-hero {
  padding: 116px 0 80px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
.log-hero .pill { margin-bottom: 1rem; }
.log-hero h1 {
  font-size: clamp(2.2rem, 4.4vw, 3.2rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 0.8rem;
}
.log-hero p.lede {
  max-width: 36rem;
  margin: 0 auto 2rem;
  color: var(--ink-3);
  font-size: 1.05rem;
  line-height: 1.55;
}

.log-shell {
  padding: 116px 0 80px;
}
.log-shell > .container {
  max-width: 760px;
}

/* ---- Auth card ---- */
.auth-card {
  max-width: 380px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  text-align: left;
}
.auth-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 0.4rem;
}
.auth-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  margin-bottom: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.auth-input:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(14, 132, 121, 0.15);
}
.auth-status {
  margin: 0.7rem 0 0;
  font-size: 0.88rem;
  min-height: 1.2em;
}
.auth-status.error { color: var(--crimson-500); }
.auth-status.success { color: var(--teal-700); }
.auth-fineprint {
  margin: 0.9rem 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--ink-4);
  text-align: center;
}

/* ---- Header ---- */
.log-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.log-header h1 {
  font-size: clamp(1.8rem, 3.2vw, 2.2rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
}
.log-header .log-sub {
  margin: 0;
  color: var(--ink-3);
  font-size: 0.95rem;
}
.log-meta {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.log-user {
  font-size: 0.85rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---- Banner stack ---- */
.banner-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
}
.banner-stack:empty { display: none; }
.banner {
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--line);
}
.banner.banner-success {
  background: var(--teal-50);
  color: var(--teal-700);
  border-color: var(--teal-200);
}
.banner.banner-error {
  background: rgba(201, 52, 58, 0.08);
  color: var(--crimson-500);
  border-color: rgba(201, 52, 58, 0.2);
}
.banner-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: inherit;
  opacity: 0.5;
  padding: 0 0.2rem;
}
.banner-close:hover { opacity: 1; }

/* ---- Card ---- */
.log-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.6rem;
  margin-bottom: 1.4rem;
  box-shadow: var(--shadow-sm);
}
.card-head {
  margin-bottom: 1.2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.card-head h2 {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.2rem;
}
.card-head .card-sub {
  color: var(--ink-3);
  font-size: 0.86rem;
}

/* ---- Form grid ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
}
@media (min-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.field-full {
  grid-column: 1 / -1;
}
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
}
.field-hint {
  font-size: 0.78rem;
  color: var(--ink-4);
  line-height: 1.4;
}

.input-row {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
}
.input-row input[type="number"],
.input-row input[type="date"],
.input-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  appearance: none;
}
.input-row input[type="number"]:focus,
.input-row input[type="date"]:focus,
.input-row input[type="text"]:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(14, 132, 121, 0.15);
}
.input-row .unit {
  display: inline-flex;
  align-items: center;
  padding: 0 0.7rem;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  color: var(--ink-3);
  white-space: nowrap;
}
.input-row .unit-select {
  -webkit-appearance: none;
  appearance: none;
  padding: 0 0.65rem;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  color: var(--ink-3);
  font-family: inherit;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%234A5757' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  padding-right: 1.4rem;
}

/* BP / mm:ss row */
.bp-row, .run-row {
  align-items: center;
}
.bp-row input[type="number"],
.run-row input[type="number"] {
  flex: 1 1 4rem;
  text-align: center;
}
.bp-slash {
  color: var(--ink-4);
  font-weight: 600;
  font-size: 1rem;
  padding: 0 0.1rem;
}

/* ---- Other markers (labs) ---- */
.other-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.other-rows:empty { margin-bottom: 0; }
.other-row {
  display: grid;
  grid-template-columns: 1fr 5rem 4rem auto;
  gap: 0.4rem;
  align-items: center;
}
.other-row input[type="text"],
.other-row input[type="number"] {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--surface);
  -webkit-appearance: none;
  appearance: none;
}
.other-row input[type="text"]:focus,
.other-row input[type="number"]:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(14, 132, 121, 0.15);
}
.other-row button.row-remove {
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--ink-4);
  font-size: 1rem;
  width: 2.2rem;
  height: 2.2rem;
  line-height: 1;
}
.other-row button.row-remove:hover {
  border-color: var(--crimson-500);
  color: var(--crimson-500);
}

/* ---- Chips ---- */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chip {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  color: var(--ink-3);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  font-weight: 500;
}
.chip:hover {
  transform: translateY(-1px);
  border-color: var(--teal-500);
}
.chip.active {
  background: var(--teal-700);
  color: white;
  border-color: var(--teal-700);
  font-weight: 600;
}
.chip:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
}

/* ---- Form actions ---- */
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}
.form-status {
  font-size: 0.84rem;
  color: var(--ink-4);
}
.form-status.success { color: var(--teal-700); }
.form-status.error { color: var(--crimson-500); }

/* ---- History ---- */
.history-group {
  border-top: 1px solid var(--line);
  padding: 0.9rem 0;
}
.history-group:first-child { border-top: 0; padding-top: 0; }
.history-group h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  margin: 0 0 0.7rem;
  font-weight: 600;
}
.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px dashed var(--line);
  gap: 0.7rem;
}
.history-row:last-child { border-bottom: 0; }
.history-row .row-meta {
  flex: 1;
  min-width: 0;
}
.history-row .row-meta .row-value {
  font-weight: 600;
  color: var(--ink-2);
}
.history-row .row-meta .row-when {
  color: var(--ink-4);
  font-size: 0.82rem;
  margin-left: 0.5rem;
}
.history-row .row-detail {
  display: block;
  color: var(--ink-3);
  font-size: 0.82rem;
  font-weight: 400;
  margin-top: 0.2rem;
}
.history-row button.row-delete {
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  color: var(--ink-3);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
  font-family: inherit;
}
.history-row button.row-delete:hover {
  border-color: var(--crimson-500);
  color: var(--crimson-500);
}
.history-row button.row-delete:disabled {
  opacity: 0.5;
  cursor: wait;
}
.empty-row {
  color: var(--ink-4);
  font-size: 0.9rem;
  text-align: center;
  padding: 1.4rem 0;
  margin: 0;
}

/* ---- Footer note ---- */
.log-footer-note {
  margin: 2rem auto 0;
  max-width: 36rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-4);
  text-align: center;
}

/* ---- Spinner ---- */
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: log-spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-left: 0.4rem;
}
@keyframes log-spin { to { transform: rotate(360deg); } }
