/*
 * Mobile-first responsive overrides for FiduciarySignal.
 *
 * Loaded after the inline styles in dashboard.html so it can override them.
 * Strategy: leave the existing desktop layout untouched, but rework the page
 * for phone-sized viewports — bigger tap targets, single-column cards,
 * bottom navigation, and full-bleed search.
 */

/* ── PWA-friendly base ─────────────────────────────────────────────── */
:root {
  --bottom-nav-h: 64px;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: contain; }

/* Hide bottom nav on desktop; it'll come back via media query */
.mobile-nav { display: none; }

/* Legal footer — always shown; required for store submission */
.legal-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: 18px 16px;
  font-size: 12px;
  color: #6b6b6b;
  border-top: 1px solid #DEE2E6;
  background: white;
  flex-wrap: wrap;
}
.legal-footer a { color: #047857; text-decoration: none; }
.legal-footer a:hover { text-decoration: underline; }

/* ── Phone breakpoint ──────────────────────────────────────────────── */
@media (max-width: 720px) {

  body {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  }

  /* On mobile, push legal footer up so it isn't hidden behind bottom nav */
  .legal-footer {
    margin-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    font-size: 11px;
    gap: 14px;
    padding: 14px 12px;
  }

  /* Header: tighter, no oversized logo */
  .header {
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-top));
    gap: 12px;
  }
  .header-logo { height: 36px; }
  .header-text h1 { font-size: 16px; line-height: 1.2; }
  .header-text .subtitle { font-size: 12px; }

  /* Search bar: stack vertically, full width inputs */
  .search-bar {
    padding: 12px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .search-group { min-width: 0; width: 100%; }
  .search-group input[type=text] {
    font-size: 16px;  /* prevents iOS auto-zoom */
    padding: 12px 14px;
  }
  .search-group button {
    padding: 12px 20px;
    font-size: 15px;
  }
  .upload-group { display: none; }  /* hide upload on phones; available via menu */
  .adv-toggle {
    align-self: flex-end;
    padding: 6px 4px;
    font-size: 13px;
  }

  /* Advanced search: 2-column grid */
  .adv-panel { padding: 16px; }
  .filter-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .filter-field input,
  .filter-field select { font-size: 16px; padding: 10px; }
  .adv-actions button { flex: 1; padding: 12px; }

  /* Tabs become horizontal-scroll pills, but we mostly use bottom nav instead */
  .tabs {
    padding: 0 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom-width: 1px;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    padding: 12px 16px;
    font-size: 13px;
    white-space: nowrap;
  }

  /* Content: tighter side margins */
  .content { padding: 0 12px; margin: 12px auto; }

  /* Cards: single column, slightly more padding for touch */
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 16px; }
  .card .value { font-size: 24px; }

  /* Info tables: stack key/value instead of side-by-side */
  .info-table { font-size: 13px; }
  .info-table th,
  .info-table td { padding: 10px 12px; }
  .info-table td:first-child {
    width: 45%;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: #666;
  }

  /* Alerts: more breathing room */
  .alert-box { padding: 14px 16px; margin-bottom: 10px; }
  .alert-box h4 { font-size: 14px; }
  .alert-box p { font-size: 13px; }

  /* Charts: full width, no min */
  .chart-grid { grid-template-columns: 1fr; gap: 14px; }
  .chart-card { padding: 12px; }

  /* Generate panel */
  .gen-panel { padding: 24px 16px; }
  .gen-btn { width: 100%; padding: 14px; font-size: 16px; }
  .gen-btn.secondary { margin-left: 0; margin-top: 12px; width: 100%; }

  /* Search modal: full screen on phones */
  .search-results { padding-top: 0; }
  .search-panel {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
    height: 100vh;
  }
  .search-panel-body { max-height: calc(100vh - 56px); }

  /* Results table → cards */
  .results-table { font-size: 12px; }
  .results-table thead { display: none; }
  .results-table tr {
    display: block;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
  }
  .results-table tr:nth-child(even) td { background: transparent; }
  .results-table td {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border: none;
    font-size: 13px;
  }
  .results-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .3px;
  }

  /* ── Bottom mobile nav ──────────────────────────────────────────── */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    padding-bottom: var(--safe-bottom);
    background: white;
    border-top: 1px solid var(--border, #DEE2E6);
    z-index: 900;
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
  }
  .mobile-nav button {
    flex: 1;
    background: transparent;
    border: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 4px;
    color: #6b6b6b;
    font-size: 11px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav button .icon {
    font-size: 22px;
    line-height: 1;
  }
  .mobile-nav button.active { color: var(--blue, #047857); font-weight: 600; }
  .mobile-nav button:active { background: rgba(4, 120, 87, .08); }

  /* Hide the desktop tab strip when bottom nav is in play */
  .tabs.mobile-hidden { display: none; }
}

/* ── Public preview gating overlay ─────────────────────────────────── */
.preview-locked {
  position: relative;
  overflow: hidden;
}
.preview-locked::after {
  content: "Sign in for full access";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(248,249,250,0) 0%, rgba(248,249,250,.95) 60%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 24px;
  font-weight: 700;
  color: var(--blue, #047857);
  pointer-events: none;
  letter-spacing: .3px;
}
.lock-badge {
  display: inline-block;
  padding: 2px 10px;
  background: var(--blue, #047857);
  color: white;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 8px;
}

/* ── Auth pages ────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  background: linear-gradient(160deg, #141E29 0%, #1D2B3A 55%, #0F1822 100%);
}
.auth-card {
  background: white;
  border-radius: 14px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.brand-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 18px;
}
.lockup-mark {
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #0a5e49, #064231);
  border: 1px solid rgba(217,180,91,.55);
  color: #D4A012;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .02em;
  padding: 9px 10px;
  border-radius: 9px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07);
}
.lockup-name {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.01em;
  color: #1D2B3A;
}
.auth-card h1 {
  font-size: 20px;
  text-align: center;
  color: #1D2B3A;
  margin-bottom: 6px;
}
.auth-card .sub {
  font-size: 13px;
  color: #666;
  text-align: center;
  margin-bottom: 24px;
}
.auth-card label {
  display: block;
  font-size: 12px;
  color: #666;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  margin-bottom: 6px;
}
.auth-card input[type=email],
.auth-card input[type=text],
.auth-card input[type=password] {
  width: 100%;
  padding: 14px 14px;
  border: 2px solid #DEE2E6;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  margin-bottom: 16px;
}
.auth-card input[type=email]:focus,
.auth-card input[type=text]:focus,
.auth-card input[type=password]:focus { border-color: #D9B45B; }
.auth-card button.primary {
  width: 100%;
  background: #1D2B3A;
  color: white;
  border: 0;
  padding: 14px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.auth-card button.primary:hover { background: #0a5e49; }
.auth-card .meta {
  text-align: center;
  font-size: 12px;
  color: #6b6b6b;
  margin-top: 16px;
}
.auth-card .meta a { color: #0a5e49; text-decoration: none; font-weight: 600; }
.auth-flash {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}
.auth-flash.error { background: #FDECEA; color: #B00020; }
.auth-flash.info  { background: #E8F0FE; color: #1A56DB; }
.auth-flash.ok    { background: #E6F4EA; color: #006600; }

/* User chip in header */
.user-chip {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #BDC3C7;
}
.user-chip a {
  color: #fff;
  background: rgba(255,255,255,.12);
  padding: 4px 10px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
}
.user-chip a:hover { background: rgba(255,255,255,.22); }

@media (max-width: 720px) {
  .user-chip { font-size: 11px; }
  .user-chip .email { display: none; }
}
