@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  /* ink family -- fondo oscuro de la sidebar, con un sesgo calido (no gris puro) */
  --ink: #17120D;
  --ink-2: #241C15;
  --ink-3: #352A20;

  /* superficies claras */
  --paper: #F6F1EA;
  --paper-2: #EFE7DB;
  --white: #FFFFFF;
  --card-line: rgba(23, 18, 13, 0.09);

  /* marca */
  --orange: #F26522;
  --orange-h: #E05A1A;
  --orange-deep: #C2450F;
  --glow: #FFC98A;

  /* texto */
  --dark: #1C1712;
  --text-sec: #8A7C6E;
  --text-on-ink: #F3EAE0;
  --text-on-ink-sec: #B3A493;

  /* semantico */
  --good: #3C8F5C;
  --good-bg: #E7F3EC;
  --danger: #C0392B;
  --danger-bg: #FBEAEA;

  /* legado -- alias para plantillas/paginas que todavia no se tocaron */
  --gray-bg: var(--paper);
  --gray-bg-2: var(--paper-2);

  --shadow-card: 0 1px 2px rgba(23, 18, 13, .04), 0 14px 32px -18px rgba(23, 18, 13, .22);
  --sidebar-w: 260px;
}

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

html { font-size: 16px; }

body {
  font-family: 'Manrope', sans-serif;
  background: var(--paper);
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
h1 { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: 16.5px; font-weight: 800; letter-spacing: -0.01em; }

/* ─── Shell: dashboard autenticado ────────────────────────────────────── */
.shell { display: flex; align-items: flex-start; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: radial-gradient(130% 140% at 8% -10%, var(--ink-3) 0%, var(--ink) 48%, #100C09 100%);
  color: var(--text-on-ink);
  padding: 26px 16px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 28px; }
.brand-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(150deg, var(--orange) 0%, var(--orange-deep) 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
  box-shadow: 0 6px 16px -4px rgba(242, 101, 34, .5);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: var(--text-on-ink-sec); margin-top: 1px; }

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-on-ink-sec);
  padding: 4px 10px 10px;
}
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text-on-ink-sec);
  font-size: 13.5px;
  font-weight: 600;
  position: relative;
  transition: background .15s, color .15s;
}
.nav-item svg { flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .05); color: var(--text-on-ink); }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(242, 101, 34, .22), rgba(242, 101, 34, .04));
  color: #fff;
}
.nav-item.is-active svg { opacity: 1; }
.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--glow), var(--orange));
}
.nav-item .nav-badge { margin-left: auto; }

.sidebar-spacer { flex: 1; }

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 10px 4px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  margin-top: 8px;
}
.account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink-3);
  border: 1px solid rgba(255, 255, 255, .1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12.5px;
  flex-shrink: 0;
}
.account-name {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-sub { font-size: 11.5px; color: var(--text-on-ink-sec); }
.account-info { min-width: 0; }
.logout-btn {
  margin-left: auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-on-ink-sec);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.main { flex: 1; min-width: 0; padding: 40px 44px 64px; }
.main-narrow { max-width: 620px; }

.main-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.main-head h1 { margin: 0; }
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  background: linear-gradient(90deg, var(--orange-deep), var(--orange) 55%, var(--glow));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
  display: inline-block;
}
.head-sub { color: var(--text-sec); font-size: 14px; margin-top: 6px; max-width: 48ch; }

/* ─── Shell: paginas sin login ─────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(60% 50% at 15% 0%, rgba(242, 101, 34, .1), transparent 60%),
    var(--paper);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border: 1px solid var(--card-line);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
}
.auth-card .brand { padding: 0 0 26px; }
.auth-card h1 { font-size: 22px; margin-bottom: 22px; }

/* ─── Forms ───────────────────────────────────────────────────────────── */
form p { margin-bottom: 16px; }
form p:has(button) { margin-bottom: 0; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-sec); margin-bottom: 6px; }
input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--card-line);
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  color: var(--dark);
  background: var(--paper-2);
  transition: border-color 0.15s, background 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--orange);
  background: var(--white);
}
form ul.errorlist {
  list-style: none;
  color: var(--danger);
  font-size: 13px;
  margin: 6px 0 0;
}
.helptext { display: block; font-size: 12px; color: var(--text-sec); margin-top: 6px; }

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-primary { background: var(--ink); color: var(--white); box-shadow: var(--shadow-card); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-accent { background: var(--orange); color: var(--white); box-shadow: 0 6px 18px -4px rgba(242, 101, 34, 0.45); }
.btn-accent:hover { background: var(--orange-h); transform: translateY(-1px); }
.btn-ghost { background: var(--paper-2); color: var(--dark); padding: 9px 18px; font-size: 13px; border-radius: 100px; }
.btn-ghost:hover { background: var(--card-line); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #f5d5d2; }
.btn-full { width: 100%; margin-top: 4px; }

/* ─── Auth links ──────────────────────────────────────────────────────── */
.auth-links { margin-top: 20px; font-size: 14px; color: var(--text-sec); text-align: center; }
.auth-links a { color: var(--orange); font-weight: 700; }

/* ─── Stat tiles ──────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 30px; }
.stat {
  background: var(--white);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.stat::after {
  content: '';
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  right: -36px;
  top: -46px;
  background: radial-gradient(circle, var(--stat-glow, var(--orange)) 0%, transparent 72%);
  opacity: .15;
}
.stat-label { font-size: 11.5px; font-weight: 700; color: var(--text-sec); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin-top: 7px; line-height: 1; }
.stat-value.accent { color: var(--orange); }
.stat-value.good { color: var(--good); font-size: 20px; }
.stat-foot { font-size: 12px; color: var(--text-sec); margin-top: 7px; }

/* ─── Panel (lista de tarjetas: catalogo, conversaciones) ────────────────── */
.panel {
  background: var(--white);
  border: 1px solid var(--card-line);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--card-line);
}
.panel-head h2 { margin: 0; }
.panel-foot { padding: 14px 22px; }

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--card-line);
}
.row:last-child { border-bottom: none; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(155deg, var(--av-1, var(--orange)), var(--av-2, var(--orange-deep)));
}
.avatar.square { border-radius: 12px; overflow: hidden; }
.avatar.square img { width: 100%; height: 100%; object-fit: cover; display: block; }

.row-body { min-width: 0; flex: 1; }
.row-top { display: flex; align-items: center; gap: 8px; }
.row-name { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-flag { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); flex-shrink: 0; }
.row-meta { margin-left: auto; font-size: 12px; color: var(--text-sec); flex-shrink: 0; white-space: nowrap; }
.row-preview {
  font-size: 13.5px;
  color: var(--text-sec);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-price { color: var(--orange); font-weight: 800; font-size: 15px; flex-shrink: 0; }
.row-actions { display: flex; gap: 8px; flex-shrink: 0; }
.row-actions a {
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 100px;
  background: var(--paper-2);
}
.row-actions a:hover { background: var(--card-line); }
.row-actions a.danger { color: var(--danger); }

.empty-state { text-align: center; padding: 44px 20px; color: var(--text-sec); }
.empty-state p { margin: 0 0 16px; }

/* ─── Checklist de onboarding (Inicio) ───────────────────────────────── */
.checklist-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  border: 2px solid var(--card-line);
  color: var(--text-sec);
}
.checklist-icon.is-done { border-color: var(--good); color: var(--good); background: var(--good-bg); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 20px; }
.pagination-info { font-size: 13px; color: var(--text-sec); }

/* ─── Toggle IA/Humano ────────────────────────────────────────────────── */
.toggle { display: flex; background: var(--paper-2); border: 1px solid var(--card-line); border-radius: 100px; padding: 3px; flex-shrink: 0; }
.toggle button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 100px;
  cursor: pointer;
  color: var(--text-sec);
}
.btn-modo { border: none; border-radius: 100px; padding: 6px 14px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: background .15s; }
.btn-modo-ia { background: var(--paper-2); color: var(--text-sec); }
.btn-modo-ia:hover { background: var(--card-line); }
.btn-modo-humano { background: var(--orange); color: var(--white); }
.btn-modo-humano:hover { background: var(--orange-h); }

.confirm-text { color: var(--text-sec); margin-bottom: 24px; }
.confirm-actions { display: flex; gap: 12px; }

/* ─── Conectar WhatsApp ───────────────────────────────────────────────── */
.alert-warning {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 13.5px;
  line-height: 1.6;
  margin-bottom: 26px;
}
.whatsapp-estado-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 36px 20px;
  text-align: center;
}
.whatsapp-estado-box img { width: 220px; height: 220px; border-radius: 12px; background: var(--white); padding: 10px; border: 1px solid var(--card-line); }
.whatsapp-numero { font-weight: 800; font-size: 17px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); flex-shrink: 0; }

/* ─── Small screens ───────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 14px 16px; overflow-x: auto; }
  .brand { padding: 0; margin-right: 14px; flex-shrink: 0; }
  .brand-sub { display: none; }
  .nav-group-label { display: none; }
  .nav { flex-direction: row; flex-shrink: 0; }
  .nav-item { padding: 8px 10px; }
  .nav-item span.nav-badge { display: none; }
  .sidebar-spacer { display: none; }
  .account { display: none; }
  .main { padding: 24px 16px 40px; max-width: 100vw; }
  .main-head { gap: 12px; }
  .stats { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .row-meta { margin-left: 52px; }
}
