/* =============================================
   SEO Auto Reporter — Silvertoad Brand Styles
   ============================================= */

:root {
  --navy: #1a2332;
  --navy-light: #2d3a4f;
  --coral: #e85d75;
  --coral-light: #f28a9c;
  --bg: transparent;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-solid: #ffffff;
  --surface-hover: #f8f9fb;
  --border: rgba(0, 0, 0, 0.06);
  --text: #1a2332;
  --text-muted: #5a6578;
  --text-light: #8b95a5;
  --success: #22c55e;
  --error: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  background: url('/static/images/silvertoad-gradient.png') no-repeat center center fixed;
  background-size: cover;
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Navbar — fully transparent on gradient */
.navbar {
  padding: 0 32px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
}
.nav-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 20px; color: white; }
.nav-logo-img { width: 32px; height: 32px; object-fit: contain; display: block; }
.nav-links { display: flex; gap: 16px; align-items: center; }
.nav-link { color: rgba(255,255,255,0.75); text-decoration: none; font-size: 13px; font-weight: 500; }
.nav-link:hover { color: white; }

/* Container & Flash */
.container { width: 100%; display: flex; flex-direction: column; }
.flash-container { padding: 12px 32px 0; max-width: 1600px; margin: 0 auto; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 15px; margin-bottom: 8px; text-align: center; font-weight: 500; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* GA Status Badge */
.badge-disconnected { background: rgba(239,68,68,0.15); color: #ef4444; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.badge-connected { background: rgba(34,197,94,0.15); color: #22c55e; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }

/* App Header */
.app-header { text-align: center; padding: 18px 32px 28px; }
.app-header h1 { font-size: 32px; font-weight: 700; color: white; margin-bottom: 6px; text-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.app-header p { font-size: 16px; color: rgba(255,255,255,0.8); }

/* Main Grid — centred, responsive 4 / 2 / 1 column layout */
.app-grid {
  display: grid;
  grid-template-areas:
    "debug input output history";
  grid-template-columns: 260px 360px 1fr 200px;
  grid-template-rows: auto;
  gap: 20px;
  padding: 0 24px 16px;
  margin: 0 auto;
  width: 100%;
  max-width: 1480px;
}

.debug-col  { grid-area: debug; }
#inputCol   { grid-area: input; }
#rightCol   { grid-area: output; }
.history-col{ grid-area: history; }

/* Medium screens — 2 columns: setup on left, output on right */
@media (max-width: 1200px) {
  .app-grid {
    grid-template-areas:
      "debug  output"
      "input  output"
      "history output";
    grid-template-columns: 320px 1fr;
    grid-template-rows: auto auto 1fr;
  }
}

/* Small screens — single stacked column */
@media (max-width: 768px) {
  .app-grid {
    grid-template-areas:
      "debug"
      "input"
      "output"
      "history";
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
}

/* Left column */
.app-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.debug-col .debug-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.debug-col .raw-body {
  flex: 1;
  max-height: 300px;
  overflow-y: auto;
  min-height: 0;
}
.debug-col .raw-body pre {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}

/* Right column */


/* Panels — white cards on gradient */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tags */
.tag {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tag-required { background: #fee2e2; color: #dc2626; }
.tag-optional { background: #f1f5f9; color: var(--text-muted); }
.tag-success { background: #dcfce7; color: #16a34a; }

/* Upload */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255,255,255,0.5);
}
.upload-zone:hover { border-color: var(--coral); background: rgba(255,255,255,0.8); }
.upload-inner p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.upload-inner strong { color: var(--navy); }
.upload-svg { width: 28px; height: 28px; color: var(--text-light); }

.file-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.file-bar #fileName {
  overflow-wrap: anywhere;
  word-break: break-all;
  min-width: 0;
}
.link-btn { background: none; border: none; color: var(--error); font-size: 13px; cursor: pointer; }

.extract-summary {
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
}
.extract-summary .ext-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.extract-summary .ext-row:last-child { border-bottom: none; }
.ext-label { color: var(--text-muted); }
.ext-value { font-weight: 500; color: var(--navy); }

/* Forms */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.panel label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.panel input, .panel select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--surface-solid);
  transition: all 0.15s;
}
.panel input:focus, .panel select:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(232, 93, 117, 0.1);
}

/* GA */
.ga-panel { padding: 16px; }
.ga-compact p { font-size: 13px; margin-bottom: 4px; color: var(--text-muted); }
.ga-assign-row { display: flex; gap: 8px; margin-bottom: 4px; }
.assign-status { font-size: 12px; color: var(--success); margin-bottom: 4px; min-height: 18px; font-weight: 500; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--coral); color: white; }
.btn-primary:hover { background: var(--coral-light); transform: translateY(-1px); }
.btn-secondary { background: var(--surface-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-generate {
  width: 100%;
  padding: 16px;
  background: white;
  color: var(--navy);
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.btn-generate:hover { background: #f8f9fb; transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0,0,0,0.15); }
.btn-generate:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-small { padding: 6px 14px; font-size: 13px; }
.btn-icon { width: 18px; height: 18px; }

/* Preview */
.preview-panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; max-height: 600px; min-height: 0; }
.preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.preview-btns { display: flex; gap: 8px; }
.subject-line {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
  flex-shrink: 0;
}
.email-preview-box {
  padding: 22px;
  overflow-y: auto;
  font-size: 15px;
  flex: 1;
  min-height: 0;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 70px 24px;
  color: var(--text-light);
  text-align: center;
}
.empty-state p { margin-top: 8px; font-size: 14px; }

/* Options */
.opts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 14px;
}
.opt-check {
  display: flex;
  align-items: flex-start;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 0;
  line-height: 1.4;
}
.opt-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin: 2px 8px 0 0;
  accent-color: var(--coral);
}
.opt-check span {
  display: inline;
}


/* Raw Data / Debug */
.raw-panel { padding: 0; }
.raw-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  font-family: inherit;
}
.raw-icon { width: 18px; height: 18px; transition: transform 0.2s; }
.raw-toggle.open .raw-icon { transform: rotate(180deg); }
.raw-body { border-top: 1px solid var(--border); }
.raw-body.hidden { display: none; }

/* Debug Panel - thin compact bar */
.debug-panel { padding: 10px 14px; }
.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.debug-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}
.debug-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.debug-panel .raw-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
}
.debug-panel .debug-header.open .raw-icon {
  transform: rotate(180deg);
}
#rawDataDisplay {
  margin: 0;
  padding: 14px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.5;
  max-height: 300px;
  overflow-y: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}
#rawDataDisplay code { font-family: 'Menlo', 'Monaco', 'Consolas', monospace; white-space: pre-wrap; word-break: break-word; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: white;
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  pointer-events: none;
  background: var(--navy);
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(26, 35, 50, 0.2);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Preview Page (standalone) */
.preview-page { padding: 24px; max-width: 900px; margin: 0 auto; }
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.toolbar-actions { display: flex; gap: 8px; }
.preview-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.preview-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
}
.preview-header h1 { font-size: 20px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.preview-header .meta { font-size: 13px; color: var(--text-muted); }
.email-render { padding: 24px; }

/* History */
.history-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.history-item:hover { background: var(--border); }
.history-item-title { font-weight: 600; color: var(--navy); font-size: 13px; }
.history-item-meta { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-subject {
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border);
}
.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

/* Hidden */
.hidden { display: none !important; }

/* A/B picker active state */
#pickVariationA.active, #pickVariationB.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

/* Narrative badge */
#narrativeBadge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.btn-danger { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fecaca; transform: translateY(-1px); }


