/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --primary:       #59ab7a;
  --primary-dark:  #3d7468;
  --primary-light: #eaf5ef;
  --secondary:     #34a853;
  --danger:        #d93025;
  --warning:       #f9ab00;
  --text:          #202124;
  --text-muted:    #5f6368;
  --border:        #dadce0;
  --bg:            #f1f3f4;
  --white:         #ffffff;
  --sidebar-w:     240px;
  --radius:        8px;
  --shadow:        0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,.12);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Site Header ───────────────────────────────────────────────────────────── */
.site-header {
  background: var(--primary);
  color: var(--white);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: .75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.site-title { font-size: 1.25rem; font-weight: 600; color: var(--white); margin: 0; line-height: 1; }

/* ── Site Footer ───────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: .85rem;
  margin-top: 3rem;
}

/* ── Container ─────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.container-narrow { max-width: 760px; }

/* ── Page hero ─────────────────────────────────────────────────────────────── */
.page-hero { margin-bottom: 2rem; }
.page-hero h2 { font-size: 1.75rem; font-weight: 700; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}
.encuesta-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: box-shadow .2s, transform .15s;
  display: flex; flex-direction: column; gap: .75rem;
}
.encuesta-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.encuesta-card h3 { font-size: 1.1rem; font-weight: 600; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1.25rem;
  border: none; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: var(--white); }
.btn-secondary{ background: var(--secondary); color: var(--white); }
.btn-danger   { background: var(--danger); color: var(--white); }
.btn-outline  {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }
/* Variante para botones sobre fondo con color (ej: header verde) */
.btn-outline-white {
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.7);
  color: #fff;
}
.btn-outline-white:hover { background: rgba(255,255,255,.28); }
.btn-sm  { padding: .35rem .85rem; font-size: .82rem; }
.btn-lg  { padding: .75rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-dashed {
  background: transparent;
  border: 2px dashed var(--border);
  color: var(--primary);
  width: 100%; padding: .75rem;
  margin-top: 1rem;
}
.btn-dashed:hover { border-color: var(--primary); background: var(--primary-light); }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .75rem; }
.form-group label { font-size: .9rem; font-weight: 500; color: var(--text-muted); }
.form-control {
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  width: 100%;
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control-lg { font-size: 1.1rem; padding: .65rem 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 540px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1rem; }
.form-group-inline { display: flex; align-items: center; gap: .5rem; }
.check-group label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 400; }
.check-group input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.input-with-btn { display: flex; gap: .5rem; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: 1rem;
}
.alert-error   { background: #fce8e6; color: #c5221f; border: 1px solid #f28b82; }
.alert-success { background: #e6f4ea; color: #137333; border: 1px solid #81c995; }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #a8c7fa; }
.alert-warning { background: #fef7e0; color: #8a6000; border: 1px solid #f9d06a; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  font-size: .72rem; font-weight: 600; padding: .2rem .6rem;
  border-radius: 99px; text-transform: uppercase; letter-spacing: .04em;
}
.badge-optional { background: #fce8e6; color: #c5221f; }

/* ── Messages ──────────────────────────────────────────────────────────────── */
.loading-msg { text-align: center; color: var(--text-muted); padding: 3rem; }
.loading-block {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .55rem .9rem;
  box-shadow: var(--shadow);
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #dbe6df;
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.stats-loading {
  opacity: .55;
  pointer-events: none;
  transition: opacity .15s ease-in-out;
}
.empty-msg   { text-align: center; color: var(--text-muted); padding: 2rem; }
.text-muted  { color: var(--text-muted); }
.feedback-msg { font-size: .82rem; }
.feedback-ok  { color: var(--secondary); }
.feedback-err { color: var(--danger); }

/* ── Centered page (login / gracias) ───────────────────────────────────────── */
.centered-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1.5rem;
}
.login-card {
  width: 100%; max-width: 400px;
}
.login-header { text-align: center; margin-bottom: 1.5rem; }
.login-header h2 { font-size: 1.4rem; }
.login-footer { text-align: center; margin-top: 1.25rem; font-size: .85rem; }
.gracias-card { text-align: center; max-width: 440px; }
.gracias-icon {
  font-size: 3.5rem; color: var(--secondary);
  background: #e6f4ea; border-radius: 50%;
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.25rem;
}

/* ── Admin layout ───────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  color: rgba(255,255,255,.9);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 50;
}
.sidebar-brand {
  padding: 1.25rem 1.5rem;
  font-weight: 700; font-size: 1rem;
  border-bottom: 1px solid rgba(255,255,255,.15);
  color: #fff;
  background: var(--primary);
}
.sidebar-nav { flex: 1; padding: 1rem 0; }
.sidebar-link {
  display: block; padding: .65rem 1.5rem;
  color: rgba(255,255,255,.85); font-size: .9rem;
  transition: background .15s, color .15s;
}
.sidebar-link:hover, .sidebar-link.active {
  background: rgba(255,255,255,.15); color: #fff; text-decoration: none;
}
.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.15);
  display: flex; flex-direction: column; gap: .5rem;
  font-size: .82rem;
}
.admin-content {
  margin-left: var(--sidebar-w);
  flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}
.admin-topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 40;
}
.page-title { font-size: 1.2rem; font-weight: 600; flex: 1; }

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); margin: 1.5rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th { background: var(--bg); font-weight: 600; text-align: left; padding: .75rem 1rem; border-bottom: 2px solid var(--border); }
.data-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }
.action-btns { display: flex; gap: .5rem; }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal-dialog {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%; max-width: 480px;
  max-height: 95vh; overflow-y: auto;
}
.modal-dialog-lg { max-width: 620px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); }
.modal-close:hover { color: var(--text); }
.modal-dialog form { padding: 1.25rem 1.5rem; }

/* ── Survey builder ─────────────────────────────────────────────────────────── */
.builder-wrap { padding: 1.5rem; }
.pregunta-builder {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.pregunta-builder-header {
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.pregunta-builder-header:hover { background: var(--bg); }
.pregunta-num { font-weight: 700; color: var(--primary); min-width: 24px; }
.pregunta-titulo-text { flex: 1; font-weight: 500; }
.pregunta-body { padding: 1rem; }
.opcion-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .5rem; font-size: .88rem;
}
.opcion-item .opcion-label { flex: 1; }
.opcion-tags { display: flex; gap: .25rem; }
.tag {
  font-size: .7rem; padding: .15rem .5rem; border-radius: 99px;
  background: var(--bg); color: var(--text-muted); border: 1px solid var(--border);
}
.tag-green { background: #e6f4ea; color: var(--secondary); border-color: #81c995; }
.tag-blue  { background: var(--primary-light); color: var(--primary); border-color: #a8c7fa; }

/* ── Survey form (public) ───────────────────────────────────────────────────── */
.encuesta-header { border-left: 4px solid var(--primary); }
.pregunta-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.pregunta-card.has-error { border-color: var(--danger); }
.pregunta-num-label { font-size: .8rem; color: var(--primary); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.pregunta-texto { font-size: 1rem; font-weight: 600; margin: .4rem 0 1rem; }
.opciones-list { display: flex; flex-direction: column; gap: .6rem; }
.opcion-label-public {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.opcion-label-public:hover { border-color: var(--primary); background: var(--primary-light); }
.opcion-label-public input[type=radio],
.opcion-label-public input[type=checkbox] { accent-color: var(--primary); width: 16px; height: 16px; }
.opcion-label-public.selected { border-color: var(--primary); background: var(--primary-light); }
.texto-adicional { margin-top: .5rem; }
.texto-adicional textarea { resize: vertical; min-height: 80px; }
.campo-texto-req { border-color: var(--danger) !important; }
.error-msg { color: var(--danger); font-size: .82rem; margin-top: .4rem; }

/* ── Statistics ─────────────────────────────────────────────────────────────── */
.stats-summary { display: flex; gap: 2rem; flex-wrap: wrap; }
.stat-box { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.stat-number { font-size: 2.5rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.chart-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin: 1rem 1.5rem; }
.chart-card h4 { font-size: 1rem; margin-bottom: 1rem; }
.chart-container { position: relative; max-height: 300px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: 1rem; }
.stats-table th { background: var(--bg); padding: .5rem .75rem; text-align: left; border-bottom: 2px solid var(--border); }
.stats-table td { padding: .45rem .75rem; border-bottom: 1px solid var(--border); }
.progress-bar-wrap { display: flex; align-items: center; gap: .5rem; width: 100%; }
.progress-bar { height: 8px; background: var(--border); border-radius: 99px; flex: 1; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 99px; }
.progress-fill.satisfactoria { background: var(--secondary); }
.textos-list { margin: 0 1.5rem; }
.texto-item { background: var(--white); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .75rem; box-shadow: var(--shadow); font-size: .9rem; }
.texto-meta { font-size: .78rem; color: var(--text-muted); margin-bottom: .25rem; }
.section-title { font-size: 1.1rem; font-weight: 600; padding: 1rem 1.5rem .5rem; }

/* ── Print ─────────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .admin-topbar, .btn { display: none !important; }
  .admin-content { margin-left: 0; }
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; }
  .admin-content { margin-left: 0; }
  .admin-layout { flex-direction: column; }
}

/* ── Escala 1-5 (DE_ESCALA = 'S') ─────────────────────────────────────────── */
.scale-intro {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: .75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.scale-table-wrap { overflow-x: auto; }

.scale-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .93rem;
}

.scale-table thead tr th {
  background: #f5f5f5;
  border: 1px solid var(--border);
  padding: .55rem .5rem;
  font-weight: 600;
  white-space: nowrap;
}

.scale-table tbody td {
  border: 1px solid var(--border);
  padding: .5rem .5rem;
  vertical-align: middle;
}

.scale-col-pregunta {
  text-align: left;
  min-width: 260px;
  padding: .6rem .75rem !important;
}

.scale-col-resp {
  text-align: center;
  min-width: 58px;
}

.scale-col-resp input[type=radio] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.scale-num { font-weight: 700; color: var(--primary); margin-right: .25rem; }

.scale-row-alt td { background: #fafafa; }

.scale-table tbody tr:hover td { background: var(--primary-light); }

.scale-texto-row td { padding: .4rem .75rem; background: #f0f4fe; }
.scale-texto-row textarea { width: 100%; resize: vertical; }
