/**
 * TurfPe Ecosystem - Master Sitewide CSS
 * Enforces Strict Light Theme, Unified Header & Footer, and Device Responsiveness
 */

/* ==========================================================================
   1. GLOBAL RESET & STRICT LIGHT THEME
   ========================================================================== */
:root {
  color-scheme: light !important;
  --tp-bg: #f8fafc;
  --tp-surface: #ffffff;
  --tp-surface-subtle: #f1f5f9;
  --tp-text: #0f172a;
  --tp-text-muted: #64748b;
  --tp-line: #e2e8f0;
  --tp-primary: #6f42f5;
  --tp-primary-hover: #5b2ee5;
  --tp-primary-light: #f5f3ff;
  --tp-primary-border: #ddd6fe;
  --tp-accent: #2563eb;
  --tp-radius: 12px;
  --tp-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06);

  /* Force override any tool variables that try to define dark themes */
  --bg: #f8fafc !important;
  --bg2: #ffffff !important;
  --card: #ffffff !important;
  --border: #e2e8f0 !important;
  --text: #0f172a !important;
  --muted: #64748b !important;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  max-width: 100vw;
  overflow-x: hidden;
  background-color: var(--tp-bg) !important;
  color: var(--tp-text) !important;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Fluid media constraints */
img, video, canvas, svg, table, iframe {
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
   2. STRICT LIGHT THEME OVERRIDES (Eliminate Dark Mode Everywhere)
   ========================================================================== */
/* Force light backgrounds across Tailwind dark classes & arbitrary hex colors */
body :where(
  .bg-black, .bg-slate-950, .bg-gray-950, .bg-zinc-950, .bg-neutral-950,
  .bg-slate-900, .bg-gray-900, .bg-zinc-900, .bg-neutral-900,
  .bg-\[\#060614\], .bg-\[\#030712\], .bg-\[\#0a0f1e\], .bg-\[\#0c0c22\], .bg-\[\#111827\],
  .dark, [data-theme="dark"], .dark\:bg-black, .dark\:bg-slate-950, .dark\:bg-gray-950, .dark\:bg-slate-900
) {
  background-color: var(--tp-bg) !important;
  background-image: none !important;
  color: var(--tp-text) !important;
}

/* Force clean white surfaces on cards, panels, modals */
body :where(
  .card, .glass, .glass-card, .bg-white\/5, .bg-white\/10, .bg-black\/30, .bg-black\/40, .bg-black\/50,
  .dark\:bg-slate-800, .dark\:bg-gray-800
) {
  background-color: var(--tp-surface) !important;
  background-image: none !important;
  border-color: var(--tp-line) !important;
  color: var(--tp-text) !important;
  box-shadow: var(--tp-shadow) !important;
}

/* Force dark typography on text previously set to white/light */
body :where(
  .text-white, h1.text-white, h2.text-white, h3.text-white, h4.text-white,
  p.text-white, span.text-white, a.text-white,
  .text-slate-100, .text-slate-200, .text-gray-100, .text-gray-200,
  .dark\:text-white, .dark\:text-slate-100
) {
  color: var(--tp-text) !important;
}

/* Muted secondary text */
body :where(
  .text-slate-400, .text-slate-500, .text-gray-400, .text-gray-500, .text-zinc-400,
  .dark\:text-slate-400, .dark\:text-gray-400
) {
  color: var(--tp-text-muted) !important;
}

/* Clean borders */
body :where(
  .border-slate-800, .border-slate-700, .border-gray-800, .border-gray-700,
  .border-white\/5, .border-white\/10, .border-white\/20,
  .dark\:border-slate-800, .dark\:border-gray-800
) {
  border-color: var(--tp-line) !important;
}

/* Code, terminals, logs */
body :where(
  #console, #api-log, #extracted-text-panel, #chat-messages, .font-mono
) {
  background-color: var(--tp-surface-subtle) !important;
  color: var(--tp-text) !important;
  border-color: #cbd5e1 !important;
}

/* Inputs & Form Controls */
body :where(input, textarea, select) {
  background-color: #ffffff !important;
  color: var(--tp-text) !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px;
}
body :where(input:focus, textarea:focus, select:focus) {
  border-color: var(--tp-primary) !important;
  outline: 2px solid rgba(111, 66, 245, 0.15) !important;
}

/* ==========================================================================
   3. STRICT SUPPRESSION OF ROGUE TOOL HEADERS & FOOTERS
   ========================================================================== */
header:not(.turfpe-shell),
footer:not(.turfpe-footer),
body > header:not(.turfpe-shell),
body > footer:not(.turfpe-footer),
body > nav:not(.turfpe-shell),
main > header,
main > footer,
header.nav:not(.turfpe-shell),
footer.foot:not(.turfpe-footer),
div.header:not(.turfpe-shell),
div.footer:not(.turfpe-footer),
#root > header,
#root > footer,
#root header:not(.turfpe-shell),
#root footer:not(.turfpe-footer),
.legacy-header,
.legacy-footer {
  display: none !important;
}

/* ==========================================================================
   4. UNIFIED TURFPE HEADER COMPONENT (.turfpe-shell)
   ========================================================================== */
.turfpe-shell {
  position: sticky !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 2147483640 !important;
  background: rgba(255, 255, 255, 0.98) !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
  border-bottom: 1px solid var(--tp-line) !important;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04) !important;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif !important;
}

.turfpe-shell__inner {
  max-width: 1240px;
  min-height: 70px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.turfpe-shell__brand {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 1.55rem !important;
  font-weight: 900 !important;
  letter-spacing: -0.06em !important;
  color: #171b2e !important;
  text-decoration: none !important;
  line-height: 1 !important;
  flex-shrink: 0;
}

.turfpe-shell__brand span {
  color: var(--tp-primary) !important;
}

.turfpe-shell__nav {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 0 auto 0 32px;
}

.turfpe-shell__nav a {
  color: #475569 !important;
  font-size: 0.95rem !important;
  font-weight: 650 !important;
  text-decoration: none !important;
  transition: color 0.15s ease !important;
}

.turfpe-shell__nav a:hover,
.turfpe-shell__nav a.active {
  color: var(--tp-primary) !important;
}

.turfpe-shell__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.turfpe-shell__button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 40px !important;
  padding: 0 16px !important;
  border: 1px solid #dbe3ef !important;
  border-radius: 10px !important;
  background: #ffffff !important;
  color: #334155 !important;
  font-size: 0.88rem !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.turfpe-shell__button:hover {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

.turfpe-shell__button--primary {
  background: var(--tp-primary) !important;
  border-color: var(--tp-primary) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 10px rgba(111, 66, 245, 0.25) !important;
}

.turfpe-shell__button--primary:hover {
  background: var(--tp-primary-hover) !important;
  border-color: var(--tp-primary-hover) !important;
  color: #ffffff !important;
}

.turfpe-shell__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--tp-line);
  border-radius: 10px;
  background: #ffffff;
  color: #171b2e;
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ==========================================================================
   5. UNIFIED TURFPE FOOTER COMPONENT (.turfpe-footer)
   ========================================================================== */
.turfpe-footer {
  position: relative !important;
  z-index: 10 !important;
  margin-top: 80px !important;
  background-color: #ffffff !important;
  border-top: 1px solid var(--tp-line) !important;
  color: #475569 !important;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif !important;
}

.turfpe-footer__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 56px 24px 32px;
  box-sizing: border-box;
}

.turfpe-footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 48px;
}

.turfpe-footer__brand-col p {
  margin: 12px 0 0;
  max-width: 320px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--tp-text-muted);
}

.turfpe-footer__badge {
  display: inline-block;
  margin-top: 16px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--tp-primary-light);
  border: 1px solid var(--tp-primary-border);
  color: var(--tp-primary);
  font-size: 0.76rem;
  font-weight: 800;
}

.turfpe-footer__col h4 {
  margin: 0 0 16px;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #0f172a;
}

.turfpe-footer__col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.turfpe-footer__col a {
  color: #475569 !important;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  transition: color 0.15s ease !important;
}

.turfpe-footer__col a:hover {
  color: var(--tp-primary) !important;
}

.turfpe-footer__bottom {
  padding-top: 24px;
  border-top: 1px solid var(--tp-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.86rem;
  color: var(--tp-text-muted);
}

.turfpe-footer__bottom a {
  color: inherit !important;
  text-decoration: none !important;
}

.turfpe-footer__bottom a:hover {
  color: var(--tp-primary) !important;
}

/* ==========================================================================
   6. RESPONSIVENESS ACROSS MOBILE, TABLET & DESKTOP
   ========================================================================== */
@media (max-width: 900px) {
  .turfpe-footer__grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
}

@media (max-width: 768px) {
  .turfpe-shell__inner {
    min-height: 64px;
    padding: 0 18px;
  }

  .turfpe-shell__toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .turfpe-shell__nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--tp-line);
    padding: 12px 18px 18px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
    margin: 0;
  }

  .turfpe-shell[data-open="true"] .turfpe-shell__nav,
  .turfpe-shell__nav.is-open {
    display: flex !important;
  }

  .turfpe-shell__nav a {
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 1rem !important;
  }

  .turfpe-shell__actions {
    display: none;
  }

  .turfpe-shell[data-open="true"] .turfpe-shell__actions--mobile {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
  }

  .turfpe-footer__grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .turfpe-footer__bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .turfpe-shell__inner {
    padding: 0 14px;
  }
  .turfpe-shell__brand {
    font-size: 1.4rem !important;
  }
  .turfpe-footer__inner {
    padding: 40px 18px 24px;
  }
}

/* User Session Pill in Header */
.turfpe-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  padding: 4px 6px 4px 12px;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  font-size: 13px;
}
.turfpe-user-pill__credits {
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  padding: 3px 8px;
  border-radius: 9999px;
}
.turfpe-user-pill__name {
  font-weight: 500;
  color: #1e293b;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.turfpe-user-pill__logout {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
  padding: 4px 10px;
  border-radius: 9999px;
  cursor: pointer;
  font-weight: 500;
  font-size: 12px;
  transition: all 0.15s ease;
}
.turfpe-user-pill__logout:hover {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}

/* Strictly hide mobile actions container on desktop */
.turfpe-shell__actions--mobile {
  display: none !important;
}

@media (max-width: 768px) {
  .turfpe-shell__actions {
    display: none !important;
  }
  .turfpe-shell__nav.is-open .turfpe-shell__actions--mobile,
  .turfpe-shell[data-open="true"] .turfpe-shell__actions--mobile {
 display: flex !important;
 }
}


/* ==========================================================================
   TOOL TOPBAR — sub-navigation bar for tools that had their own <header>.
   Uses <div class="tool-topbar"> so it is NOT suppressed by shell rules.
   ========================================================================== */
.tool-topbar {
  position: sticky;
  top: 64px; /* sits below the 64px turfpe-shell */
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}
.tool-topbar__inner {
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Scan AI Pro dark variant */
[data-scan-topbar="true"].tool-topbar {
  background: rgba(3, 7, 18, 0.92) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  box-shadow: none !important;
}
