/* =========================================================
   GreenMix — Account & Auth styles
   Dark mode fixed · Modal · History cards
   ========================================================= */

/* ── Dark mode body fill fix ── */
html, body {
  min-height: 100%;
  background-color: var(--bg);
}

/* Ensure no dark gaps between sections */
.main-wrap {
  background: var(--bg);
  min-height: calc(100vh - 200px);
}

.tab-section {
  background: var(--bg);
  min-height: 60vh;
}

/* ── Account nav button ── */
.account-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 6px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  white-space: nowrap;
}
.account-nav-btn:hover {
  border-color: var(--accent);
  color: var(--text-1);
}

/* Nav avatar circle */
.nav-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: 28px;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s var(--ease);
}

@keyframes modalIn {
  from { transform: translateY(16px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  border-radius: 50%;
  color: var(--text-2);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.15s;
}
.modal-close:hover {
  background: var(--bg-3);
  color: var(--text-1);
}

/* Modal logo / header */
.modal-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}

/* Auth tabs */
.auth-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 3px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  padding: 7px;
  border: none;
  background: transparent;
  border-radius: var(--r-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text-1);
  box-shadow: var(--shadow);
}

/* Auth fields */
.auth-field {
  margin-bottom: 14px;
}
.auth-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}
.auth-field input {
  width: 100%;
  padding: 9px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text-1);
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.auth-error {
  font-size: 12px;
  color: var(--red);
  min-height: 18px;
  margin-bottom: 10px;
  line-height: 1.4;
}

.auth-submit-btn {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.auth-submit-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}
.auth-submit-btn.signout-btn {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  margin-top: 8px;
}
.auth-submit-btn.signout-btn:hover {
  background: var(--red);
  color: #fff;
  box-shadow: none;
}

/* Signed-in state */
.user-avatar-large {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--eco));
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-user-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 2px;
}
.modal-user-email {
  font-size: 12px;
  color: var(--text-3);
}

/* Account stats */
.account-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 20px 0;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.acc-stat {
  text-align: center;
}
.acc-stat-v {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.acc-stat-l {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── History tab ── */
.history-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 320px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  color: var(--text-3);
  text-align: center;
  padding: 48px 32px;
}
.history-empty-state p {
  font-size: 13px;
  color: var(--text-2);
  max-width: 260px;
  line-height: 1.6;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.history-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.3s var(--ease);
  position: relative;
  overflow: hidden;
}
.history-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-mid);
}
.history-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.history-card.eco-card-hist::before {
  background: var(--eco);
}

.hist-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.hist-grade {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
}
.hist-date {
  font-size: 10.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.hist-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.hist-pill {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  font-weight: 500;
  background: var(--bg-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.hist-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.hist-stat {
  text-align: center;
}
.hist-stat-v {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}
.hist-stat-l {
  font-size: 9.5px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hist-load-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid var(--accent-mid);
  border-radius: var(--r-xs);
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}
.hist-load-btn:hover {
  background: var(--accent);
  color: #fff;
}

.history-clear-btn {
  margin-top: 16px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}
.history-clear-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .account-nav-btn { padding: 5px 8px; }
  .account-nav-btn span:last-of-type { display: none; }
  .modal-box { margin: 16px; max-width: calc(100% - 32px); }
  .history-grid { grid-template-columns: 1fr; }
}

/* ── Additional dark mode gap fixes ── */
html {
  background: var(--bg);
}

/* Hero background should match theme perfectly */
.hero {
  background: var(--surface);
}

/* Tab sections fill the background */
.tab-section {
  background: transparent;
}

/* Page-level background coverage */
.main-wrap {
  min-height: calc(100vh - 160px);
}

/* Mobile body padding when nav is shown */
@media (max-width: 768px) {
  body.has-mobile-nav {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }
}

/* ── Google sign-in button ── */
.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  margin-bottom: 0;
}
.google-btn:hover {
  border-color: #4285F4;
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.12);
  background: var(--bg-2);
}
.google-btn:active {
  transform: scale(0.99);
}

/* ── Divider between Google and email forms ── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 16px;
  color: var(--text-3);
  font-size: 11.5px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-2);
}

/* ── Provider badge in signed-in modal ── */
.modal-provider-badge {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ── Nav avatar — support background image (Google photo) ── */
.nav-avatar {
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--accent);
  background-repeat: no-repeat;
}

/* ── User avatar large — support background image ── */
.user-avatar-large {
  border-radius: 50%;
  overflow: hidden;
  background-repeat: no-repeat;
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN GATE MODAL
═══════════════════════════════════════════════════════════════ */

.login-gate-box {
  max-width: 420px;
}

/* Header with lock icon */
.gate-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.gate-lock-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  background: var(--accent-light);
  border: 1px solid var(--accent-mid);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.gate-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
  margin-bottom: 3px;
}
.gate-sub {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
}

/* Benefits list */
.gate-benefits {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.gate-benefit {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.4;
}
.gate-benefit svg { flex-shrink: 0; margin-top: 1px; }

/* Submit button variant */
.gate-submit-btn {
  background: linear-gradient(135deg, var(--accent) 0%, #1D4ED8 100%) !important;
}
.gate-submit-btn:hover {
  background: linear-gradient(135deg, #1D4ED8 0%, #1e40af 100%) !important;
}

/* Footer note */
.gate-footer {
  margin-top: 14px;
  font-size: 10.5px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.5;
}

/* ── Calc button locked state ── */
.calc-btn.btn-locked {
  background: var(--bg-3);
  border: 1.5px dashed var(--border-2);
  color: var(--text-2);
  box-shadow: none;
}
.calc-btn.btn-locked:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: none;
  transform: none;
}

/* Auth hint below locked button */
.calc-btn-auth-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  justify-content: center;
  margin-top: 8px;
}
.calc-btn-auth-hint svg { flex-shrink: 0; }
.gate-inline-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.gate-inline-link:hover { color: #1D4ED8; }

@media (max-width: 480px) {
  .gate-benefits { grid-template-columns: 1fr; }
}
