/* ===== MedicaIA - Sistema de diseno (inspirado en Hotmart) ===== */
:root {
  --primary: #ff4d4d;          /* rojo/coral Hotmart */
  --primary-dark: #e63939;
  --primary-soft: #fff0f0;
  --ink: #1d2433;
  --muted: #6b7280;
  --line: #e8ebf0;
  --bg: #f5f7fb;
  --white: #ffffff;
  --green: #16a34a;
  --green-soft: #e7f7ee;
  --amber: #d97706;
  --amber-soft: #fff7e6;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(29, 36, 51, 0.08);
  --shadow-sm: 0 2px 8px rgba(29, 36, 51, 0.06);
  --sidebar-w: 256px;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ===== Botones ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px; border: none; cursor: pointer;
  font-size: 15px; font-weight: 600; font-family: inherit; transition: .15s ease;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--white); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-green { background: var(--green); }
.btn-green:hover { background: #128a3e; }
.btn-danger { background: #fff; color: var(--primary); border: 1px solid #ffd2d2; }
.btn-danger:hover { background: var(--primary-soft); }
.btn-sm { padding: 8px 14px; font-size: 13.5px; border-radius: 10px; }

/* ===== Inputs ===== */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; color: var(--ink); }
.input, .field input, .field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 15px; font-family: inherit; background: var(--white); transition: .15s;
}
.input:focus, .field input:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ===== Cards ===== */
.card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  border: 1px solid var(--line); padding: 24px;
}

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.badge-free { background: var(--amber-soft); color: var(--amber); }
.badge-premium { background: var(--green-soft); color: var(--green); }
.badge-pendiente { background: var(--amber-soft); color: var(--amber); }
.badge-aprobado { background: var(--green-soft); color: var(--green); }
.badge-rechazado { background: var(--primary-soft); color: var(--primary); }

/* ===== Alertas ===== */
.alert { padding: 12px 16px; border-radius: 12px; font-size: 14px; margin-bottom: 16px; display: none; }
.alert.show { display: block; }
.alert-error { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #ffd2d2; }
.alert-ok { background: var(--green-soft); color: var(--green); border: 1px solid #bdebcd; }

/* ===== Layout autenticacion (login/registro) ===== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background-image: linear-gradient(135deg, rgba(15,30,25,.35), rgba(10,143,91,.30)), url('/img/login-bg.png');
  background-size: cover; background-position: center; background-repeat: no-repeat; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { text-align: center; margin-bottom: 8px; }
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--muted); font-size: 14px; }
.auth-switch a { color: var(--primary); font-weight: 600; }

/* ===== Marca ===== */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-size: 18px; }
.brand .logo-em { font-style: normal; }

/* ===== Shell con sidebar (app autenticada) ===== */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--white); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 16px; position: fixed; top: 0; bottom: 0; left: 0; z-index: 30;
  transition: transform .25s ease;
}
.sidebar .brand { padding: 8px 10px 20px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 14.5px;
}
.nav a .ic { font-size: 18px; width: 22px; text-align: center; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 14px; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.userbox .meta { overflow: hidden; }
.userbox .meta b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userbox .meta span { font-size: 12px; color: var(--muted); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--white); border-bottom: 1px solid var(--line); padding: 14px 28px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 20; }
.topbar h2 { font-size: 18px; }
.topbar .spacer { flex: 1; }
.hamb { display: none; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--ink); }
.content { padding: 28px; max-width: 1080px; width: 100%; margin: 0 auto; }

/* ===== Pill de lecturas restantes ===== */
.lecturas-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--primary-soft);
  color: var(--primary-dark); padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: 13.5px; }

/* ===== Grid utilidades ===== */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; gap: 12px; align-items: center; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ===== Escaner ===== */
.scan-tabs { display: flex; gap: 8px; margin-bottom: 18px; background: var(--bg); padding: 6px; border-radius: 14px; }
.scan-tabs button { flex: 1; padding: 10px; border: none; background: transparent; border-radius: 10px;
  font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); font-family: inherit; }
.scan-tabs button.active { background: var(--white); color: var(--primary); box-shadow: var(--shadow-sm); }

.reco-foto { background: var(--amber-soft); color: var(--amber); border: 1px solid #ffe2b8;
  border-radius: 12px; padding: 11px 14px; font-size: 13.5px; line-height: 1.5; margin-bottom: 14px; }

.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 36px 20px; text-align: center;
  cursor: pointer; transition: .15s; background: var(--bg); }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .big { font-size: 40px; margin-bottom: 8px; }
.preview-img { max-width: 100%; max-height: 280px; border-radius: 12px; margin-top: 12px; }

/* ===== Resultado IA ===== */
.result-section { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: var(--white); }
.result-section + .result-section { margin-top: 14px; }
.result-section h4 { display: flex; align-items: center; gap: 10px; font-size: 16px; margin-bottom: 8px; }
.result-section .ic { font-size: 22px; }
.result-section p { color: #303a4d; }

/* ===== Tabla ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--bg); }

/* ===== Paywall / Yape ===== */
.yape-box { text-align: center; }
.yape-qr { width: 200px; height: 200px; border-radius: 16px; border: 1px solid var(--line);
  display: grid; place-items: center; margin: 0 auto 14px; background: #5b21b6; color: #fff; }
.precio { font-size: 38px; font-weight: 800; color: var(--ink); }
.precio small { font-size: 16px; color: var(--muted); font-weight: 600; }

/* ===== Loader ===== */
.spinner { width: 38px; height: 38px; border: 4px solid var(--line); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Stat cards (admin) ===== */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .num { font-size: 30px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 13.5px; font-weight: 600; }

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
.overlay.show { display: block; }

.hidden { display: none !important; }

/* ===== Pie de pagina ===== */
.site-footer { background: #0a8f5b; color: #eafff3; text-align: center;
  padding: 16px 18px; font-size: 13px; line-height: 1.6; margin-top: auto; }
.site-footer a { color: #fff; font-weight: 700; text-decoration: underline; }
.site-footer .marca { font-weight: 700; }
/* En la pantalla de login el footer queda al pie de la columna */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; }
.auth-page .auth-wrap { flex: 1; min-height: 0; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamb { display: block; }
  .content { padding: 18px; }
}
