/* ==========================================================
   BackYou Reseñas — estilos de la encuesta y del panel
   ========================================================== */

:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #4f46e5;
  --good: #16a34a;
  --warn: #ea580c;
  --bad: #dc2626;
  --star: #f59e0b;
  --brand: #111827;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .9rem; margin-top: 1.2em; color: var(--ink-2); }
code { font-size: .85em; background: var(--bg); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: .85rem; margin: .3em 0 0; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn--primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn--primary:hover { background: #1e293b; }
.btn--brand { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn--brand:hover { background: var(--brand); filter: brightness(1.1); }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--bad); }
.btn--sm { padding: 5px 10px; font-size: .8rem; }
.btn--block { width: 100%; padding: 14px; font-size: 1rem; }
.link-danger { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 2px 6px; }
.link-danger:hover { color: var(--bad); }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 5px; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.form input:not([type=checkbox]):not([type=radio]), .form select, .form textarea,
.filters select, .user-row input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-weight: 400; color: var(--ink); background: #fff;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.form input[type=color] { padding: 4px; height: 42px; }
.form--inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.form--inline label { flex: 1 1 160px; }
.form--inline label.grow { flex: 3 1 260px; }
.form--inline label.narrow { flex: 0 1 80px; }
.form .check, .form .radio { display: flex; align-items: center; gap: 8px; font-weight: 500; flex: 0 0 auto; }
.form .radio { align-items: flex-start; font-weight: 400; }
.form .radio input { margin-top: 4px; }
.box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 10px; }
.box legend { font-size: .8rem; font-weight: 700; color: var(--muted); padding: 0 6px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash--ok { background: #dcfce7; color: #14532d; }
.flash--error { background: #fee2e2; color: #7f1d1d; }

/* ==========================================================
   Encuesta pública
   ========================================================== */
body.survey {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 10%, #fff) 0%, #fff 60%);
}
.survey-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 24px;
  padding: 32px 24px; box-shadow: 0 10px 40px rgba(15, 23, 42, .1); text-align: center;
}
.survey-card h1 { font-size: 1.4rem; }
.survey-head { margin-bottom: 20px; }
.survey-logo { max-width: 140px; max-height: 72px; object-fit: contain; display: block; margin: 0 auto 8px; }
.survey-logo--text {
  width: 64px; height: 64px; border-radius: 18px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 1.8rem; font-weight: 700;
}
.survey-biz { margin: 0; font-size: .85rem; color: var(--muted); font-weight: 500; }

.stars { display: flex; justify-content: center; gap: 4px; margin: 20px 0 8px; }
.star {
  font-size: 3rem; line-height: 1; padding: 4px; border: 0; background: none; cursor: pointer;
  color: #d8dde5; transition: color .12s, transform .12s; -webkit-tap-highlight-color: transparent;
}
.star.on { color: var(--star); }
.star:hover, .star:focus-visible { transform: scale(1.15); outline: none; }
.hint { font-size: .85rem; margin: 6px 0 0; }
.big-emoji { font-size: 3rem; margin-bottom: 8px; }

.survey-card .form { text-align: left; margin-top: 16px; }
.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  font-weight: 500; font-size: .9rem; cursor: pointer; transition: all .12s;
}
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); }
.contact summary { cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--ink-2); padding: 4px 0; }
.contact[open] { display: grid; gap: 12px; }
.survey-error { color: var(--bad); font-weight: 500; margin: 16px 0 0; }
.survey-foot { color: var(--muted); font-size: .75rem; margin-top: 18px; }

/* ==========================================================
   Panel
   ========================================================== */
body.admin { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 16px;
  padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; }
.biz-switch select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 600; max-width: 220px; }
.biz-name { font-weight: 600; color: var(--ink-2); }
.topbar-user { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: .9rem; color: var(--muted); }
.menu-btn { display: none; border: 0; background: none; font-size: 1.4rem; cursor: pointer; padding: 4px; }

.shell { display: flex; min-height: calc(100vh - 60px); }
.sidebar { width: 230px; flex: 0 0 230px; padding: 20px 12px; border-right: 1px solid var(--line); background: #fff; }
.sidebar a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; font-size: .92rem; }
.sidebar a:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: var(--ink); color: #fff; }
.nav-sep { margin: 18px 12px 6px; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.content { flex: 1; min-width: 0; padding: 28px; max-width: 1200px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.back { color: var(--muted); margin-right: 6px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg a { padding: 6px 12px; border-radius: 7px; color: var(--ink-2); font-size: .85rem; font-weight: 500; }
.seg a.active { background: var(--ink); color: #fff; }
.seg a:hover { text-decoration: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card--flush { padding: 0; overflow-x: auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.pad { padding: 16px 20px; margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2--tight { gap: 14px; margin-top: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.edit-box { background: var(--bg); border-radius: 10px; padding: 14px; margin-bottom: 14px; display: grid; gap: 10px; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi span { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi strong { display: block; font-size: 1.8rem; letter-spacing: -.02em; margin: 2px 0; }
.kpi small { color: var(--muted); font-size: .78rem; }
.kpi--good strong { color: var(--good); }
.kpi--warn strong { color: var(--warn); }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: .88rem; }
.bar-label { width: 32px; color: var(--ink-2); font-weight: 600; }
.bar-label--wide { width: 130px; }
.bar { flex: 1; height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; min-width: 2px; }
.bar i.good { background: var(--good); }
.bar i.warn { background: var(--warn); }
.bar-val { width: 36px; text-align: right; color: var(--muted); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.feed a { display: grid; gap: 2px; color: inherit; min-width: 0; }
.feed a:hover { text-decoration: none; }
.feed-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-meta { font-size: .78rem; color: var(--muted); }

.rating { color: var(--star); letter-spacing: 1px; font-weight: 600; white-space: nowrap; }
.rating.r1, .rating.r2 { color: var(--bad); }
.rating.r3 { color: var(--warn); }
.rating--lg { font-size: 1.8rem; margin: 0 0 12px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: .72rem; font-weight: 600; background: var(--bg); color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.badge--new { background: #fee2e2; color: #991b1b; }
.badge--in_progress { background: #fef3c7; color: #92400e; }
.badge--resolved { background: #dcfce7; color: #166534; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table--click tbody tr { cursor: pointer; }
.table--click tbody tr:hover { background: #fafbfc; }
.table td.clip { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.clip a { color: inherit; }
.table tr.inactive { opacity: .55; }
.edit-row td { background: var(--bg); }
.edit-row .form--inline { margin-bottom: 10px; }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0 0 16px; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters select { width: auto; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }

.spots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.spot { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.spot-actions { display: flex; gap: 10px; align-items: center; font-size: .8rem; margin-top: 4px; }

.user-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.user-row input { width: 170px; padding: 6px 10px; }
.user-row + .form { margin-top: 12px; }

/* ---------- Tarjetas QR imprimibles ---------- */
.qr-sheet { display: grid; grid-template-columns: repeat(auto-fill, 8.5cm); gap: 12px; }
.qr-card {
  width: 8.5cm; height: 5.5cm; background: #fff; border: 1px solid #d0d5dd; border-radius: 10px;
  overflow: hidden; display: flex; flex-direction: column; break-inside: avoid; page-break-inside: avoid;
}
.qr-card-top { background: var(--brand); color: #fff; padding: 6px 12px; height: 1.1cm; display: flex; align-items: center; justify-content: center; }
.qr-card-top img { max-height: .8cm; max-width: 100%; object-fit: contain; }
.qr-card-top strong { font-size: .85rem; }
.qr-card-body { flex: 1; display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.qr { width: 3.6cm; height: 3.6cm; flex: 0 0 3.6cm; }
.qr img, .qr canvas { width: 100% !important; height: 100% !important; }
.qr-card-text p { margin: 0; line-height: 1.25; }
.qr-ask { font-weight: 700; font-size: .95rem; }
.qr-stars { color: var(--star); font-size: 1.05rem; letter-spacing: 1px; margin: 2px 0 !important; }
.qr-cta { font-size: .72rem; color: var(--ink-2); }
.qr-title { font-weight: 700; font-size: .9rem; margin-top: 8px !important; }
.qr-sub { font-size: .7rem; color: var(--muted); }

@media print {
  @page { margin: 1cm; }
  body.admin { background: #fff; }
  .topbar, .sidebar, .no-print, .flash { display: none !important; }
  .content { padding: 0; max-width: none; }
  .shell { display: block; }
  .qr-sheet { gap: 0.4cm; }
  .qr-card { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .menu-btn { display: block; }
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar-user span { display: none; }
  .biz-switch select { max-width: 150px; }
  .sidebar {
    position: fixed; top: 60px; left: 0; bottom: 0; z-index: 15;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .content { padding: 20px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
}
