/* ============================================================
   app.css — authenticated dashboard + auth pages
   Inherits CSS vars from styles.css
   ============================================================ */

/* ---------- AUTH (login + signup) ---------- */
.auth-body {
  background: linear-gradient(160deg, var(--paper) 0%, var(--paper-deep) 100%);
  min-height: 100vh;
}
.auth-wrap {
  max-width: 440px;
  margin: 0 auto;
  padding: 56px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.auth-brand {
  margin-bottom: 28px;
  font-size: 18px;
}
.auth-card {
  background: white;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%;
  box-shadow: var(--shadow-md);
}
.auth-card h1 {
  font-size: 28px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.auth-sub {
  margin: 0 0 24px;
  color: var(--ink-2);
  font-size: 15px;
}
.field {
  display: block;
  margin-bottom: 16px;
}
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  color: var(--ink);
}
.field textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green-500);
  background: white;
  box-shadow: 0 0 0 3px rgba(51, 159, 82, 0.18);
}
.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-3);
}
.field-hint code,
.tips-list code {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  background: var(--paper-deep);
  padding: 1px 5px;
  border-radius: 4px;
}
.field .optional {
  color: var(--ink-3);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.auth-error,
.form-error {
  background: #fdecec;
  color: #8a1f1f;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin: 14px 0 0;
}
.btn-full { width: 100%; justify-content: center; }
.auth-switch {
  margin: 18px 0 0;
  text-align: center;
  color: var(--ink-2);
  font-size: 14px;
}
.auth-switch a { margin-left: 6px; font-weight: 600; }
.auth-footer { margin-top: 24px; font-size: 14px; color: var(--ink-3); }

/* Apple Sign In button — styled per Apple HIG for web. */
.apple-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #000;
  color: #fff;
  border: none;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 13px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.06s ease;
}
.apple-btn:hover:not(:disabled) { background: #1c1c1c; }
.apple-btn:active:not(:disabled) { transform: translateY(1px); }
.apple-btn:disabled { opacity: 0.6; cursor: progress; }

.auth-divider {
  text-align: center;
  margin: 18px 0;
  position: relative;
}
.auth-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line);
  z-index: 0;
}
.auth-divider span {
  position: relative;
  z-index: 1;
  background: white;
  padding: 0 12px;
  color: var(--ink-3);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- APP CHROME ---------- */
.app-body { background: var(--paper); min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
.app-header {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line-2);
  position: sticky;
  top: 0;
  z-index: 30;
}
.app-header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
}
.app-nav {
  display: flex;
  gap: 2px;
  margin-left: 12px;
  flex: 1;
}
.tab-btn {
  background: transparent;
  border: none;
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-2);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.06s ease;
}
.tab-btn:hover { color: var(--ink); background: var(--paper-deep); }
.tab-btn:active { transform: scale(0.97); }
.tab-btn.active {
  background: var(--green-50);
  color: var(--green-700);
}
.tab-btn .tab-icon { opacity: 0.85; }
.tab-btn.active .tab-icon { opacity: 1; }

/* ----- User menu (top-right avatar + dropdown) ----- */
.app-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-menu { position: relative; }
.user-avatar-btn {
  background: transparent;
  border: none;
  padding: 2px;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.06s ease, box-shadow 0.15s ease;
}
.user-avatar-btn:hover { box-shadow: 0 0 0 3px var(--paper-deep); }
.user-avatar-btn:active { transform: scale(0.95); }
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  min-width: 240px;
  padding: 6px;
  z-index: 100;
}
.user-dropdown-head {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-dropdown-head strong { font-size: 14px; }
.user-dropdown-email {
  font-size: 12.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
}
.user-dropdown-item:hover { background: var(--paper-deep); }
.user-dropdown-danger { color: #b1372e; }
.user-dropdown-danger:hover { background: #fdecec; color: #8a1f1f; }

.btn-small { padding: 8px 14px; font-size: 14px; }
.btn-small.btn-cta { gap: 6px; }

.app-main { padding: 32px 24px 80px; }
.tab-pane { display: none; animation: paneIn 0.22s ease both; }
.tab-pane.active { display: block; }
@keyframes paneIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pane-head { margin: 0 0 24px; }
.pane-head-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.pane-head h1 {
  font-size: 32px;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.pane-sub { color: var(--ink-3); margin: 0; }
.section-title {
  font-size: 18px;
  margin: 32px 0 12px;
  letter-spacing: -0.01em;
}

/* ---------- CARDS ---------- */
.card {
  background: white;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

/* ---------- LOG A BILL ---------- */
.log-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
  align-items: start;
}
.log-form { display: block; }
.form-row { display: block; }
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}
.btn-geo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.btn-geo[data-state="located"] {
  background: var(--green-50);
  border-color: var(--green-300);
  color: var(--green-700) !important;
}

.log-side { display: flex; flex-direction: column; gap: 16px; }
.promo-card {
  background: linear-gradient(160deg, var(--paper) 0%, var(--paper-deep) 100%);
  border-color: var(--line);
}
.promo-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.promo-card h3 {
  font-size: 19px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.promo-card p {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--ink-2);
}
.tips-card h3 {
  font-size: 16px;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}
.tips-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-2);
  font-size: 14px;
}
.tips-list li { margin-bottom: 8px; line-height: 1.5; }
.tips-list li:last-child { margin-bottom: 0; }

.form-success {
  background: var(--green-50);
  border: 1px solid var(--green-300);
  color: var(--green-900);
  padding: 12px 14px;
  border-radius: 10px;
  margin-top: 14px;
  font-size: 14px;
}

/* ---------- BILLS GRID ---------- */
.bill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.bill-card {
  background: white;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  color: var(--ink);
  display: block;
}
.bill-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line);
}
.bill-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.bill-denom {
  font-size: 22px;
  font-weight: 800;
  color: var(--green-700);
  letter-spacing: -0.01em;
}
.bill-pill {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.bill-pill-hit {
  background: #fbedd0;
  color: #946100;
}
.bill-serial {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 6px;
}
.bill-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--ink-3);
}

/* Skeleton loaders */
.bill-skeleton {
  height: 96px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--paper-deep) 0%, #f7f2e6 50%, var(--paper-deep) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border: 1px solid var(--line-2);
}
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  background: white;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}
.empty-illus {
  color: var(--green-300);
  display: inline-flex;
  margin-bottom: 14px;
}
.empty-state h2 {
  font-size: 22px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.empty-state p {
  color: var(--ink-3);
  margin: 0 0 20px;
  font-size: 15px;
}
.empty-actions {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- MAP ---------- */
.map-wrap {
  position: relative;
}
.map-canvas {
  width: 100%;
  height: 560px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper-deep);
}
.map-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  color: var(--ink-2);
  z-index: 400;
  pointer-events: none;
}
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  box-sizing: border-box;
}
.legend-dot-mine {
  background: #339F52;
  border: 2px solid #197533;
}
.legend-dot-other {
  background: white;
  border: 2px solid #bf8800;
}
@media (max-width: 640px) {
  .map-canvas { height: 440px; }
  .map-legend { left: 10px; bottom: 10px; font-size: 12px; padding: 8px 10px; }
}

/* ---------- SEARCH ---------- */
.search-wrap { position: relative; margin-bottom: 18px; }
.search-icon {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}
.search-input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 14px 18px 14px 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(51, 159, 82, 0.18);
}
.user-list { display: grid; gap: 8px; }
.user-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--ink);
  transition: background 0.12s ease, transform 0.08s ease, box-shadow 0.15s ease;
}
.user-row:hover {
  background: var(--paper-deep);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}
.user-row-meta { display: flex; flex-direction: column; }
.user-row-meta small { color: var(--ink-3); font-size: 13px; }
.muted { color: var(--ink-3); font-size: 14px; padding: 14px 0; }

/* ---------- PROFILE ---------- */
.profile-card {
  display: flex;
  gap: 24px;
  align-items: center;
  background: white;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(25, 117, 51, 0.25);
}
.profile-meta h1, .profile-meta h2 { margin: 0; letter-spacing: -0.01em; }
.profile-handle { margin: 4px 0 14px; color: var(--ink-3); }
.profile-stats {
  display: flex;
  gap: 22px;
  margin: 0;
  flex-wrap: wrap;
}
.profile-stats > div {
  display: flex;
  flex-direction: column;
}
.profile-stats strong { font-size: 22px; color: var(--ink); letter-spacing: -0.01em; }
.profile-stats span { color: var(--ink-3); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.profile-cta-row {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .profile-card { flex-direction: column; text-align: center; padding: 24px; }
  .profile-stats { justify-content: center; }
}

/* ---------- BILL DETAIL ---------- */
.bill-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat-tile {
  background: white;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: center;
}
.stat-tile-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--green-700);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.stat-tile div:last-child {
  font-size: 13px;
  color: var(--ink-3);
}
@media (max-width: 640px) {
  .bill-summary { grid-template-columns: 1fr; }
  .stat-tile-num { font-size: 18px; }
}
.sightings-list { list-style: none; padding: 0; margin: 0; }
.sighting-row {
  display: grid;
  grid-template-columns: 140px 160px 1fr;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  background: white;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 14px;
}
.sighting-when { color: var(--ink-2); }
.sighting-who { font-weight: 600; }
.sighting-where { color: var(--ink-3); }
@media (max-width: 640px) {
  .sighting-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- TOAST ---------- */
.toast-region {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.22s ease, toastOut 0.25s ease 3.5s forwards;
}
.toast.toast-success { background: var(--green-700); }
.toast.toast-error { background: #8a1f1f; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-10px); }
}

/* ---------- MOBILE BOTTOM NAV ---------- */
.app-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.bottom-btn {
  flex: 1;
  background: transparent;
  border: none;
  font: inherit;
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.bottom-btn:hover { background: var(--paper-deep); color: var(--ink-2); }
.bottom-btn.active { color: var(--green-700); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
  .app-header-inner { gap: 12px; }
  .app-nav { display: none; }
  .app-main { padding: 24px 18px 96px; }
  .app-bottom-nav { display: flex; }
  .log-grid { grid-template-columns: 1fr; }
  .pane-head h1 { font-size: 26px; }
}

@media (max-width: 640px) {
  .form-row-2 { grid-template-columns: 1fr; }
  .pane-head-row { align-items: flex-start; }
  .btn-cta { width: 100%; justify-content: center; }
  .empty-actions .btn { flex: 1 1 auto; justify-content: center; }
}
