/* ── TradeAssist Diagnostics — style.css ── */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0a0d14;
  --surface:     #111827;
  --surface2:    #1a2235;
  --border:      rgba(255,255,255,0.08);
  --border-glow: rgba(99,179,237,0.3);
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --text-dim:    #94a3b8;

  --blue:   #3b82f6;
  --cyan:   #06b6d4;
  --green:  #10b981;
  --yellow: #f59e0b;
  --red:    #ef4444;
  --purple: #8b5cf6;

  --font:  'Inter', system-ui, sans-serif;
  --mono:  'JetBrains Mono', 'Fira Code', monospace;
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated grid background */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(59,130,246,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: 0;
  pointer-events: none;
}
.bg-grid::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59,130,246,0.12), transparent);
  pointer-events: none;
}

.app-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(10,13,20,0.8);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 16px rgba(59,130,246,0.4);
}

.logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cyan);
  background: rgba(6,182,212,0.1);
  border: 1px solid rgba(6,182,212,0.25);
  border-radius: 4px;
  padding: 2px 6px;
}

.header-time {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Main ── */
.main-content {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(120deg, #e2e8f0 30%, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  margin-top: 0.35rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ── Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.3rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 20px rgba(59,130,246,0.3);
  white-space: nowrap;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 28px rgba(59,130,246,0.5);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary.loading svg {
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-copy {
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-copy:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

/* ── Architecture Card ── */
.arch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.arch-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.arch-flow {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.arch-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 100px;
  padding: 0.75rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.arch-node.cloudflare { border-color: rgba(249,115,22,0.3); }
.arch-node.oracle      { border-color: rgba(16,185,129,0.3); }
.arch-node.gemini      { border-color: rgba(139,92,246,0.3); }

.arch-node-icon { font-size: 1.3rem; }
.arch-node-label { font-size: 0.75rem; font-weight: 600; color: var(--text); text-align: center; }
.arch-node-sub   { font-size: 0.67rem; color: var(--text-muted); text-align: center; font-family: var(--mono); }

.arch-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex: 1;
  min-width: 60px;
  padding: 0 0.25rem;
}
.arch-arrow-line {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, var(--border), rgba(59,130,246,0.4), var(--border));
  position: relative;
}
.arch-arrow-line::after {
  content: '›';
  position: absolute;
  right: -4px;
  top: -9px;
  color: var(--blue);
  font-size: 1rem;
}
.arch-arrow-label {
  font-size: 0.63rem;
  color: var(--text-muted);
  font-family: var(--mono);
  white-space: nowrap;
}

/* ── Status Grid ── */
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 700px) {
  .status-grid { grid-template-columns: 1fr; }
  .arch-flow { flex-direction: column; }
  .arch-arrow { flex-direction: row; min-width: auto; width: 100%; }
  .arch-arrow-line { width: 100%; height: 1px; }
  .arch-arrow-line::after { right: -4px; top: -9px; }
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.3s;
}
.status-card.status-ok     { border-color: rgba(16,185,129,0.3); }
.status-card.status-fail   { border-color: rgba(239,68,68,0.3); }
.status-card.status-warn   { border-color: rgba(245,158,11,0.3); }

.status-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.status-icon-wrap {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.status-icon-wrap.env     { background: rgba(59,130,246,0.15); color: var(--blue); }
.status-icon-wrap.network { background: rgba(6,182,212,0.15);  color: var(--cyan); }
.status-icon-wrap.db      { background: rgba(16,185,129,0.15); color: var(--green); }
.status-icon-wrap.gemini  { background: rgba(139,92,246,0.15); color: var(--purple); }

.status-card-title { font-size: 0.9rem; font-weight: 600; }
.status-card-sub   { font-size: 0.75rem; color: var(--text-muted); }

.status-pill {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 20px;
  padding: 3px 10px;
  background: rgba(100,116,139,0.2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: all 0.3s;
}
.status-pill.ok      { background: rgba(16,185,129,0.15);  color: var(--green);  border-color: rgba(16,185,129,0.3); }
.status-pill.fail    { background: rgba(239,68,68,0.15);   color: var(--red);    border-color: rgba(239,68,68,0.3); }
.status-pill.warn    { background: rgba(245,158,11,0.15);  color: var(--yellow); border-color: rgba(245,158,11,0.3); }
.status-pill.info    { background: rgba(59,130,246,0.15);  color: var(--blue);   border-color: rgba(59,130,246,0.3); }
.status-pill.loading { background: rgba(59,130,246,0.1);   color: var(--blue);   animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.status-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.status-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: var(--surface2);
  border-radius: 7px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

.si-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.si-dot.ok      { background: var(--green); box-shadow: 0 0 6px var(--green); }
.si-dot.fail    { background: var(--red);   box-shadow: 0 0 6px var(--red); }
.si-dot.warn    { background: var(--yellow); }
.si-dot.info    { background: var(--blue); }
.si-dot.missing { background: var(--red); }
.si-dot.skipped { background: var(--text-muted); }

.si-content { flex: 1; }
.si-name    { color: var(--text-dim); font-size: 0.75rem; margin-bottom: 1px; }
.si-value   { color: var(--text); font-family: var(--mono); font-size: 0.78rem; word-break: break-all; }

/* ── Result Panel ── */
.result-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.result-panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

.elapsed-badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--green);
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: 4px;
  padding: 1px 6px;
}

.result-code {
  padding: 1.25rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: #a8daff;
  line-height: 1.7;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre;
}

/* ── Guide Card ── */
.guide-card {
  background: var(--surface);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.guide-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--yellow);
  margin-bottom: 1rem;
}

.guide-alert {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.guide-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.guide-method {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}

.guide-method-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 0.4rem;
}

.guide-method-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.guide-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.guide-step {
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text-dim);
  padding: 0.3rem 0.6rem;
  background: rgba(0,0,0,0.2);
  border-radius: 5px;
  border-left: 2px solid var(--cyan);
  line-height: 1.5;
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-endpoint {
  font-family: var(--mono);
  color: var(--blue);
}

/* ── Auth Error Banner ── */
.auth-error-banner {
  background: rgba(239,68,68,0.07);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.auth-error-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 0.75rem;
}

.auth-error-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.auth-error-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.auth-label {
  font-weight: 700;
  color: var(--red);
  min-width: 36px;
  font-size: 0.75rem;
  padding-top: 1px;
}

.auth-code {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: rgba(239,68,68,0.1);
  color: #fca5a5;
  padding: 1px 6px;
  border-radius: 4px;
  word-break: break-all;
}

.auth-sql-block {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 7px;
  overflow: hidden;
}

.sql-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  letter-spacing: 0.03em;
}

.sql-pre {
  margin: 0;
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: #86efac;
  line-height: 1.7;
  overflow-x: auto;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
