/* =====================================================================
   styles.css — Plataforma SEO Local
   ===================================================================== */

:root {
  --bg: #0f1729;
  --bg-2: #16213e;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --line: #e6ebf4;
  --text: #1a2238;
  --text-soft: #5b6783;
  --text-faint: #8b97ب0;
  --text-faint: #8b97b0;
  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --brand-soft: #eef3ff;
  --accent: #14b8a6;
  --green: #16a34a;
  --green-soft: #e7f7ee;
  --amber: #f59e0b;
  --red: #ef4444;
  --shadow: 0 10px 30px -12px rgba(20, 33, 80, .25);
  --shadow-sm: 0 2px 8px -2px rgba(20, 33, 80, .12);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 268px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; }
a { color: var(--brand); text-decoration: none; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -6px rgba(37,99,235,.6); }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--line); }
.btn-ghost:hover { background: #eef1f7; color: var(--text); }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ============ PANTALLA DE ACCESO ============ */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, #1e3a8a 0%, transparent 55%),
              radial-gradient(1000px 500px at 110% 110%, #0d9488 0%, transparent 50%),
              var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 22px;
  padding: 38px 34px; box-shadow: 0 30px 70px -20px rgba(0,0,0,.5);
}
.auth-brand { font-size: 20px; font-weight: 800; color: var(--brand); margin-bottom: 22px; }
.auth-brand span { color: var(--text); }
.auth-title { font-size: 25px; font-weight: 800; letter-spacing: -.4px; }
.auth-sub { color: var(--text-soft); margin: 6px 0 24px; font-size: 15px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.field input {
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-size: 15px; color: var(--text); transition: border .15s, box-shadow .15s; background: #fff;
}
.field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.auth-error { color: var(--red); font-size: 13px; font-weight: 600; }
.auth-switch { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-soft); }
.auth-note { text-align: center; margin-top: 18px; font-size: 12px; color: var(--text-faint); line-height: 1.5; }

/* ============ LAYOUT APP ============ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg); color: #cdd6ee; display: flex; flex-direction: column;
  padding: 22px 16px; gap: 20px; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { font-size: 19px; font-weight: 800; color: #fff; padding: 4px 8px; }
.sidebar-brand span { color: #93c5fd; }

.biz-switcher { background: rgba(255,255,255,.05); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 9px; }
.biz-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #7f8db5; font-weight: 700; }
.biz-select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06); color: #fff; font-size: 14px; font-weight: 600;
}
.biz-select option { color: #1a2238; }
.biz-switcher .btn-ghost { background: transparent; color: #93c5fd; border-color: rgba(147,197,253,.3); }
.biz-switcher .btn-ghost:hover { background: rgba(147,197,253,.12); color: #bfdbfe; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  color: #aab4d4; font-size: 14.5px; font-weight: 600; text-align: left; transition: all .15s;
}
.nav-item span { font-size: 18px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 8px 20px -8px rgba(37,99,235,.8); }

.sidebar-foot { display: flex; flex-direction: column; gap: 10px; }
.user-chip { font-size: 13px; color: #aab4d4; padding: 8px 10px; background: rgba(255,255,255,.05); border-radius: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .btn-ghost { background: transparent; color: #8b97b0; border-color: rgba(255,255,255,.1); }
.sidebar-foot .btn-ghost:hover { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.3); }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 16px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.hamburger { display: none; font-size: 22px; color: var(--text); }
.topbar-title { font-size: 18px; font-weight: 700; flex: 1; }
.mini-ring {
  --p: 0; width: 46px; height: 46px; border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--line) 0);
  display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--text);
}
.mini-ring::before { content: ""; position: absolute; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); }
.mini-ring span { position: relative; z-index: 1; }
.topbar-progress { position: relative; }

.view-wrap { padding: 28px; max-width: 1080px; width: 100%; margin: 0 auto; }

/* ---------- Componentes genéricos ---------- */
.page-head { margin-bottom: 24px; }
.page-head h2 { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.page-head p { color: var(--text-soft); margin-top: 6px; font-size: 15px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm);
}

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* ---------- Dashboard ---------- */
.hero-card {
  background: linear-gradient(135deg, #1e3a8a, #2563eb 60%, #0d9488);
  color: #fff; border-radius: 20px; padding: 28px 30px; margin-bottom: 22px;
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap; box-shadow: var(--shadow);
}
.hero-text { flex: 1; min-width: 220px; }
.hero-text h2 { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.hero-text p { opacity: .9; margin-top: 6px; font-size: 15px; }
.hero-ring {
  --p: 0; width: 116px; height: 116px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255,255,255,.22) 0);
  display: grid; place-items: center; position: relative;
}
.hero-ring::before { content: ""; position: absolute; width: 92px; height: 92px; border-radius: 50%; background: rgba(30,58,138,.55); backdrop-filter: blur(4px); }
.hero-ring-val { position: relative; z-index: 1; text-align: center; }
.hero-ring-val b { font-size: 28px; font-weight: 800; display: block; line-height: 1; }
.hero-ring-val small { font-size: 11px; opacity: .85; }

.stat-card { display: flex; flex-direction: column; gap: 4px; }
.stat-card .stat-num { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.stat-card .stat-lbl { color: var(--text-soft); font-size: 13.5px; font-weight: 600; }
.stat-card .stat-ico { font-size: 22px; margin-bottom: 4px; }

.section-title { font-size: 17px; font-weight: 700; margin: 28px 0 14px; display: flex; align-items: center; gap: 8px; }

/* Tarjeta de módulo (en dashboard y lista) */
.mod-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .12s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 12px;
}
.mod-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #cdd9f0; }
.mod-top { display: flex; align-items: flex-start; gap: 14px; }
.mod-ico { font-size: 26px; line-height: 1; width: 48px; height: 48px; display: grid; place-items: center; background: var(--brand-soft); border-radius: 12px; flex-shrink: 0; }
.mod-meta { flex: 1; min-width: 0; }
.mod-meta h3 { font-size: 16px; font-weight: 700; }
.mod-meta p { font-size: 13px; color: var(--text-soft); margin-top: 2px; }
.mod-badge { font-size: 11px; font-weight: 700; color: var(--text-faint); background: var(--surface-2); padding: 4px 8px; border-radius: 20px; white-space: nowrap; }

.bar { height: 8px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #34d399); border-radius: 20px; transition: width .4s ease; }
.mod-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-soft); font-weight: 600; }
.mod-done-tag { color: var(--green); }

/* ---------- Vista de módulo (detalle) ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); font-weight: 600; font-size: 14px; margin-bottom: 16px; }
.back-link:hover { color: var(--brand); }

.detail-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 6px; }
.detail-head .mod-ico { width: 60px; height: 60px; font-size: 32px; }
.detail-head h2 { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.detail-head p { color: var(--text-soft); margin-top: 3px; }
.detail-time { font-size: 12.5px; color: var(--text-faint); font-weight: 600; margin-top: 6px; }

.tabs { display: flex; gap: 6px; margin: 22px 0 18px; background: var(--surface-2); padding: 5px; border-radius: 12px; width: fit-content; }
.tab { padding: 9px 18px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--text-soft); }
.tab.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }

.intro-box { background: var(--brand-soft); border: 1px solid #d7e3fb; border-radius: var(--radius); padding: 18px 20px; color: #1e3a8a; font-size: 14.5px; margin-bottom: 20px; }

.guide-section { margin-bottom: 22px; }
.guide-section h4 { font-size: 17px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.guide-section h4::before { content: ""; width: 4px; height: 18px; background: var(--brand); border-radius: 4px; }
.guide-section p { color: var(--text-soft); margin-bottom: 8px; font-size: 14.5px; }

/* Tareas */
.task-progress-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 14px; }
.task-progress-head .bar { flex: 1; }
.task-progress-head b { font-size: 14px; white-space: nowrap; }

.task {
  display: flex; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); margin-bottom: 10px; transition: border-color .15s, background .15s;
}
.task.done { background: var(--green-soft); border-color: #b9e6cb; }
.task-check {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); flex-shrink: 0; margin-top: 1px;
  display: grid; place-items: center; transition: all .15s; color: #fff; font-size: 14px;
}
.task.done .task-check { background: var(--green); border-color: var(--green); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; }
.task.done .task-title { text-decoration: line-through; color: var(--text-soft); }
.task-help { font-size: 13px; color: var(--text-soft); margin-top: 3px; }
.task-note {
  margin-top: 10px; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; resize: vertical; min-height: 0; color: var(--text); background: var(--surface-2);
}
.task-note:focus { outline: none; border-color: var(--brand); background: #fff; }

/* ---------- Recursos ---------- */
.res-card { display: flex; flex-direction: column; gap: 12px; }
.res-card h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.res-card pre {
  background: var(--bg); color: #d6e0f5; padding: 16px; border-radius: var(--radius-sm); font-size: 12.5px;
  white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, 'SF Mono', Menlo, monospace; line-height: 1.6;
}
.res-copy { align-self: flex-start; }

/* ---------- Perfil / Mi negocio ---------- */
.profile-form { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.profile-form .field.full { grid-column: 1 / -1; }
.profile-form textarea {
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font-size: 15px;
  resize: vertical; min-height: 80px; color: var(--text); font-family: inherit;
}
.profile-form textarea:focus, .profile-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,41,.6); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal-card { background: var(--surface); border-radius: 20px; padding: 30px; width: 100%; max-width: 460px; position: relative; box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); }
.modal-close { position: absolute; top: 16px; right: 16px; font-size: 18px; color: var(--text-faint); width: 32px; height: 32px; border-radius: 8px; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-card h3 { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.modal-card .modal-sub { color: var(--text-soft); font-size: 14px; margin-bottom: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 13px 22px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,.5); z-index: 200; opacity: 0; transition: all .3s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-soft); }
.empty .ico { font-size: 48px; margin-bottom: 12px; }
.empty h3 { font-size: 19px; font-weight: 700; color: var(--text); margin-bottom: 6px; }

/* ============ BANNER DE IMPERSONACIÓN ============ */
.imp-banner {
  position: sticky; top: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  gap: 16px; flex-wrap: wrap; padding: 10px 18px; background: linear-gradient(90deg, #b45309, #d97706);
  color: #fff; font-weight: 600; font-size: 13.5px; box-shadow: 0 2px 10px -2px rgba(0,0,0,.3);
}
.imp-exit { background: rgba(255,255,255,.95); color: #92400e; padding: 6px 14px; border-radius: 8px; font-weight: 700; font-size: 13px; }
.imp-exit:hover { background: #fff; }
body.impersonating .sidebar-brand::after { content: " · cliente"; color: #fbbf24; font-size: 12px; font-weight: 600; }

/* ============ NAV ADMIN ============ */
.nav-admin { color: #fcd34d !important; }
.nav-admin.active { background: #b45309 !important; color: #fff !important; box-shadow: 0 8px 20px -8px rgba(180,83,9,.8) !important; }
.nav-admin:hover { background: rgba(252,211,77,.12); color: #fde68a !important; }

/* ============ PANEL AGENCIA ============ */
.user-chip { cursor: pointer; }
.user-chip:hover { background: rgba(255,255,255,.1); }

.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.admin-table th { text-align: left; padding: 13px 16px; background: var(--surface-2); color: var(--text-soft); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface-2); }
.admin-user-name { font-weight: 700; }
.admin-user-email { font-size: 12.5px; color: var(--text-soft); }
.role-pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.role-pill.user { background: var(--brand-soft); color: var(--brand-2); }
.role-pill.admin { background: #fef3c7; color: #92400e; }
.metric-num { font-weight: 700; }
.btn-imp { background: #b45309; color: #fff; padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.btn-imp:hover { background: #92400e; }
.muted { color: var(--text-faint); font-size: 12.5px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; width: 280px; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: 0 0 60px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: block; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .profile-form { grid-template-columns: 1fr; }
  .view-wrap { padding: 18px; }
  .hero-card { padding: 22px; }
}
@media (min-width: 861px) { .hamburger { display: none; } }

/* Backdrop para sidebar móvil */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; }
@media (min-width: 861px) { .backdrop { display: none !important; } }
