/* =============================================================
   1. Variables — verde + negro + glassmorphism
   ============================================================= */
:root {
  --bg: #06090a;
  --bg-soft: #0b1211;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(57, 255, 136, 0.35);
  --ink: #eafff1;
  --ink-soft: #9db6a9;
  --ink-mute: #6b8577;
  --accent: #39ff88;
  --accent-2: #00d68f;
  --accent-dim: #1c7a4c;
  --accent-glow: rgba(57, 255, 136, 0.45);
  --danger: #ff5c5c;
  --danger-soft: rgba(255, 92, 92, 0.12);
  --warn: #ffcc66;
  --warn-soft: rgba(255, 204, 102, 0.12);
  --ok-soft: rgba(57, 255, 136, 0.12);

  --serif: "Newsreader", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius-s: 10px;
  --radius: 18px;
  --radius-l: 26px;
  --blur: 18px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(18px, 5vw, 56px);
  --maxw: 1180px;
}

/* =============================================================
   2. Reset
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  position: relative;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
ul { list-style: none; padding: 0; }
::selection { background: var(--accent); color: #04140b; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* Fondo: resplandor verde ambiental, fijo, detrás de todo */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(650px 500px at 12% -5%, rgba(57, 255, 136, 0.16), transparent 60%),
    radial-gradient(550px 480px at 105% 15%, rgba(0, 214, 143, 0.14), transparent 60%),
    radial-gradient(800px 600px at 50% 120%, rgba(57, 255, 136, 0.08), transparent 60%),
    var(--bg);
}

/* =============================================================
   3. Glass — la pieza base del glassmorphism
   ============================================================= */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 20px 60px -30px rgba(0,0,0,0.6);
}
.glass-strong { background: var(--surface-strong); border-color: var(--border-strong); }

/* =============================================================
   4. Layout
   ============================================================= */
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.center-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }

/* =============================================================
   5. Brand
   ============================================================= */
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 600; font-size: 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(155deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  box-shadow: 0 0 24px -4px var(--accent-glow);
}
.brand-mark svg { width: 18px; height: 18px; }

/* =============================================================
   6. Buttons
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 24px; border-radius: 999px; font-weight: 600; font-size: 15px;
  transition: transform .25s var(--ease-out), box-shadow .25s var(--ease-out), background .2s, border-color .2s, opacity .2s;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04140b;
  box-shadow: 0 8px 30px -8px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 36px -6px var(--accent-glow); }
.btn-ghost { background: var(--surface); border: 1px solid var(--border); color: var(--ink); }
.btn-ghost:hover { border-color: var(--border-strong); }
.btn-danger-ghost { background: var(--danger-soft); color: var(--danger); border: 1px solid transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 16px; font-size: 13.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* =============================================================
   7. Topbar (app.html)
   ============================================================= */
.app-topbar { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--border); }
.app-topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 68px; max-width: 1280px; }
.usage-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
  font-family: var(--mono); font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
}
.usage-pill svg { width: 14px; height: 14px; color: var(--accent); }
.logout-btn { color: var(--ink-mute); }
.logout-btn:hover { color: var(--danger); }

/* =============================================================
   8. Auth card
   ============================================================= */
.auth-card { width: 100%; max-width: 400px; padding: 36px 32px; }
.auth-card .brand { justify-content: center; margin-bottom: 26px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 8px; color: var(--ink-soft); }
.field input, .field select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-s);
  background: rgba(255,255,255,0.03); transition: border-color .2s, background .2s; color: var(--ink);
}
.field input::placeholder { color: var(--ink-mute); }
.field input:focus, .field select:focus { border-color: var(--accent); background: rgba(57,255,136,0.05); }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239db6a9' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
.form-msg { font-size: 13.5px; padding: 11px 14px; border-radius: var(--radius-s); margin-bottom: 16px; display: none; }
.form-msg.is-visible { display: block; }
.form-msg.error { background: var(--danger-soft); color: var(--danger); }

/* =============================================================
   9. Búsqueda — formulario principal
   ============================================================= */
.search-panel { padding: 28px; margin-bottom: 24px; }
.search-grid { display: grid; grid-template-columns: 1.1fr 1fr 1fr auto; gap: 14px; align-items: end; }
@media (max-width: 900px) { .search-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .search-grid { grid-template-columns: 1fr; } }
.search-grid .btn { height: 46px; padding-inline: 28px; }

.progress-shell { margin-top: 20px; }
.progress-track { height: 6px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .4s var(--ease-out); width: 0%; box-shadow: 0 0 14px var(--accent-glow); }
.progress-label { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-soft); margin-top: 12px; }
.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================
   10. Resultados — tarjetas de leads
   ============================================================= */
.results-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.results-head h2 { font-size: 1.3rem; }
.leads-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }

.lead-card { padding: 22px; display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; }
.lead-rank {
  position: absolute; top: 0; right: 0; width: 46px; height: 46px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04140b; font-family: var(--mono); font-weight: 700; font-size: 15px;
  display: grid; place-items: center; border-radius: 0 var(--radius) 0 var(--radius-l);
}
.lead-name { font-family: var(--serif); font-size: 1.15rem; padding-right: 40px; }
.lead-address { font-size: 13.5px; color: var(--ink-soft); }

.lead-problem {
  font-size: 13px; padding: 10px 12px; border-radius: var(--radius-s);
  background: var(--warn-soft); color: var(--warn); display: flex; gap: 8px; align-items: flex-start;
}
.lead-problem svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

.lead-links { display: flex; flex-wrap: wrap; gap: 8px; }
.lead-link {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-soft);
  transition: border-color .2s, color .2s;
}
.lead-link:hover { border-color: var(--border-strong); color: var(--accent); }
.lead-link svg { width: 13px; height: 13px; }
.lead-link.is-unverified { border-style: dashed; }
.confidence-tag { font-size: 10px; opacity: .7; margin-left: 2px; }

.lead-message { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 13px 14px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; max-height: 130px; overflow-y: auto; }
.lead-actions { display: flex; gap: 8px; margin-top: auto; }
.copy-btn { flex: 1; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-mute); }
.empty-state svg { width: 44px; height: 44px; margin-inline: auto 14px; opacity: .5; }

/* =============================================================
   11. Toast
   ============================================================= */
.toast-stack { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast { padding: 13px 16px; border-radius: var(--radius-s); font-size: 14px; animation: toast-in .3s var(--ease-out); }
.toast.ok { background: var(--ok-soft); border: 1px solid var(--border-strong); color: var(--accent); }
.toast.error { background: var(--danger-soft); border: 1px solid rgba(255,92,92,0.35); color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* =============================================================
   12. Responsive tweaks
   ============================================================= */
@media (max-width: 540px) {
  .app-topbar .wrap { padding-inline: 16px; }
}


/* Ajustes de interfaz: selector oscuro y botón de copia compacto */
.field select {
  color-scheme: dark;
  background-color: #0b1211;
  color: #ffffff;
}
.field select option {
  background-color: #0b1211;
  color: #ffffff;
}
.field select option:disabled {
  color: #9db6a9;
}
.copy-btn {
  flex: 0 0 auto;
  align-self: flex-start;
  min-height: 36px;
  padding: 8px 14px;
}
.copy-btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
}


/* =============================================================
   13. Modos y oportunidades de intención
   ============================================================= */
.mode-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0,0,0,.28);
}
.mode-btn {
  padding: 8px 15px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  transition: background .2s, color .2s, box-shadow .2s;
}
.mode-btn:hover { color: var(--ink); }
.mode-btn.is-active {
  color: #04140b;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 20px -8px var(--accent-glow);
}
.opportunity-grid { grid-template-columns: 1.1fr 1fr .8fr auto; }
.source-note {
  margin-top: 14px;
  color: var(--ink-mute);
  font-size: 12px;
}
.opportunities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 18px;
}
.opportunity-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.opportunity-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.intent-badge {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255,204,102,.12);
  border: 1px solid rgba(255,204,102,.25);
  color: var(--warn);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.intent-badge.is-high {
  background: var(--ok-soft);
  border-color: var(--border-strong);
  color: var(--accent);
}
.source-domain {
  color: var(--ink-mute);
  font-family: var(--mono);
  font-size: 10.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.opportunity-title { font-size: 1.12rem; }
.opportunity-meta { color: var(--ink-mute); font-size: 12px; }
.opportunity-need { color: var(--ink-soft); font-size: 13.5px; }
.budget-tag {
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--accent);
  background: var(--ok-soft);
  font-size: 12px;
  font-weight: 600;
}
.opportunity-reason {
  padding: 10px 12px;
  border-radius: var(--radius-s);
  background: rgba(255,255,255,.035);
  border-left: 2px solid var(--accent-dim);
  color: var(--ink-soft);
  font-size: 12.5px;
}
.opportunity-source {
  align-self: flex-start;
  color: var(--accent);
}
@media (max-width: 900px) {
  .opportunity-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .mode-switch { display: flex; width: 100%; border-radius: 14px; }
  .mode-btn { flex: 1; white-space: normal; line-height: 1.25; }
  .opportunity-grid { grid-template-columns: 1fr; }
  .opportunities-grid { grid-template-columns: 1fr; }
}
