@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #eff6ff;
  --success:        #16a34a;
  --success-light:  #f0fdf4;
  --warning:        #d97706;
  --warning-light:  #fffbeb;
  --danger:         #dc2626;
  --danger-light:   #fef2f2;
  --sl-900:         #0f172a;
  --sl-800:         #1e293b;
  --sl-600:         #475569;
  --sl-400:         #94a3b8;
  --sl-300:         #cbd5e1;
  --sl-200:         #e2e8f0;
  --sl-100:         #f1f5f9;
  --sl-50:          #f8fafc;
  --white:          #ffffff;
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --radius-xl:      20px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:         0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:      0 16px 40px rgba(0,0,0,0.14);
  --t:              0.17s ease;
}

/* ── BASE ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--sl-50);
  color: var(--sl-800);
  margin: 0;
  min-height: 100vh;
  font-size: 0.9375rem;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar {
  background: var(--sl-900);
  height: 58px;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 200;
  gap: 0.5rem;
  box-shadow: 0 1px 0 rgba(255,255,255,0.05);
}
.topbar-brand {
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none;
}
.topbar-brand:hover { color: #fff; text-decoration: none; }
.topbar-logo {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800; color: white; flex-shrink: 0;
}
.topbar-sep { width: 1px; height: 18px; background: rgba(255,255,255,0.1); margin: 0 2px; }
.topbar-page { color: var(--sl-400); font-size: 0.8rem; font-weight: 500; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; }
.topbar-user { color: var(--sl-400); font-size: 0.78rem; margin-right: 4px; }
@media (max-width: 540px) { .topbar-user { display: none; } }
.btn-top {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.75);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: var(--t);
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
  line-height: 1.5;
}
.btn-top:hover { background: rgba(255,255,255,0.13); color: #fff; border-color: rgba(255,255,255,0.25); text-decoration: none; }
.btn-top.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-top.danger { border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.btn-top.danger:hover { background: rgba(239,68,68,0.18); color: #fff; border-color: #ef4444; }
@media (max-width: 420px) { .btn-top-text { display: none; } }

/* ── PAGE LAYOUT ─────────────────────────────────────────── */
.page-wrap { max-width: 1080px; margin: 0 auto; padding: 1.75rem 1rem 4rem; }
@media (min-width: 768px) { .page-wrap { padding: 2.25rem 1.5rem 4rem; } }
.page-title { font-size: 1.05rem; font-weight: 700; color: var(--sl-900); letter-spacing: -0.02em; margin: 0 0 0.2rem; }
.page-sub   { font-size: 0.78rem; color: var(--sl-400); margin: 0 0 1.75rem; }
.section-label {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--sl-400); margin-bottom: 0.75rem; display: block;
}

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--sl-200); box-shadow: var(--shadow-sm);
}
.card-body { padding: 1.25rem; }
.card-header-line {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--sl-100);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--white); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--sl-200); box-shadow: var(--shadow-sm); padding: 1.25rem;
}

/* ── TEMPLATE CARDS (dashboard) ──────────────────────────── */
.tpl-card {
  background: var(--white); border: 1.5px solid var(--sl-200);
  border-radius: var(--radius-lg); padding: 1.25rem; height: 100%;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.tpl-card:hover { border-color: var(--primary); box-shadow: 0 4px 20px rgba(37,99,235,0.13); transform: translateY(-2px); }
.tpl-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin-bottom: 0.875rem;
}
.tpl-card h5 { font-size: 0.92rem; font-weight: 700; margin: 0 0 0.3rem; letter-spacing: -0.01em; }
.tpl-card p  { font-size: 0.78rem; color: var(--sl-400); margin: 0 0 1rem; line-height: 1.55; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  border-radius: var(--radius-sm); font-weight: 600; font-size: 0.875rem;
  letter-spacing: -0.01em; transition: var(--t);
  display: inline-flex; align-items: center; gap: 5px;
}
.btn:focus { box-shadow: 0 0 0 3px rgba(37,99,235,0.22); outline: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-success:hover { background: #15803d; border-color: #15803d; }

/* ── FORMS ───────────────────────────────────────────────── */
.form-label {
  font-size: 0.73rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--sl-600); margin-bottom: 0.3rem; display: block;
}
.form-control, .form-select {
  border-radius: var(--radius-sm); border: 1.5px solid var(--sl-200);
  font-size: 0.9rem; color: var(--sl-800); background: var(--white);
  transition: border-color var(--t), box-shadow var(--t);
  padding: 0.48rem 0.75rem; font-family: inherit;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.14); outline: none;
}
.form-control-lg, .form-select-lg { padding: 0.6rem 0.9rem; font-size: 0.95rem; }
.form-text { font-size: 0.74rem; color: var(--sl-400); margin-top: 4px; }
.input-group .form-control { border-right: none; }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important; }

/* ── TABLES ──────────────────────────────────────────────── */
.table { font-size: 0.875rem; margin: 0; }
.table thead th {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--sl-400); background: var(--sl-50);
  border-bottom: 1px solid var(--sl-200); padding: 0.65rem 1rem; white-space: nowrap;
}
.table td { padding: 0.8rem 1rem; border-color: var(--sl-100); vertical-align: middle; }
.table-hover tbody tr:hover { background: #f9fbff; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 767px) { .table td, .table th { font-size: 0.8rem; padding: 0.55rem 0.65rem; } }
.custom-table-card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--sl-200); overflow: hidden; box-shadow: var(--shadow-sm); }

/* ── BADGES ──────────────────────────────────────────────── */
.badge { font-weight: 600; border-radius: 4px; font-size: 0.67rem; letter-spacing: 0.02em; }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert { border-radius: var(--radius); border: none; font-size: 0.875rem; padding: 0.75rem 1rem; }
.alert-success { background: var(--success-light); color: #14532d; }
.alert-danger  { background: var(--danger-light);  color: #7f1d1d; }
.alert-warning { background: var(--warning-light); color: #78350f; }
.alert-info    { background: var(--primary-light); color: #1e3a5f; }

/* ── MODALS ──────────────────────────────────────────────── */
.modal-content { border-radius: var(--radius-lg); border: none; box-shadow: var(--shadow-lg); }
.modal-header  { border-bottom: 1px solid var(--sl-100); padding: 1rem 1.25rem; }
.modal-footer  { border-top: 1px solid var(--sl-100); padding: 0.75rem 1.25rem; }
.modal-body    { padding: 0; }
.list-group-item { border-color: var(--sl-100); padding: 0.875rem 1.25rem; }
.list-group-item-action:hover { background: var(--sl-50); }

/* ── AUTH PAGES (login / registo) ────────────────────────── */
body.auth-page {
  background: linear-gradient(145deg, #1e3a8a 0%, #0f172a 100%);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.auth-wrap {
  width: 100%; max-width: 860px;
  display: grid; grid-template-columns: 1fr;
  border-radius: var(--radius-xl); overflow: hidden;
  box-shadow: 0 32px 80px rgba(0,0,0,0.45);
}
@media (min-width: 640px) { .auth-wrap { grid-template-columns: 1fr 1fr; } }
.auth-brand {
  background: linear-gradient(160deg, #1d4ed8 0%, #1e40af 100%);
  padding: 2.5rem 2rem; color: white;
  display: flex; flex-direction: column;
}
.auth-brand-name { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.04em; margin-bottom: 4px; }
.auth-brand-name span { color: rgba(255,255,255,0.5); font-weight: 400; }
.auth-brand-tag { font-size: 0.76rem; opacity: 0.55; margin-bottom: 2.5rem; }
.auth-feature { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; opacity: 0.8; margin-bottom: 12px; }
.auth-feature i { font-size: 1rem; }
.auth-brand-footer { font-size: 0.7rem; opacity: 0.3; margin-top: auto; padding-top: 2.5rem; }
.auth-form-panel {
  background: var(--white); padding: 2.5rem 2rem;
  display: flex; flex-direction: column; justify-content: center;
}
@media (max-width: 639px) { .auth-brand { display: none; } .auth-form-panel { border-radius: var(--radius-xl); } }
.auth-title { font-size: 1.3rem; font-weight: 700; color: var(--sl-900); letter-spacing: -0.025em; margin-bottom: 4px; }
.auth-sub   { font-size: 0.78rem; color: var(--sl-400); margin-bottom: 1.75rem; }
.auth-form-panel .form-label { color: var(--sl-600); }
.pw-toggle-btn {
  background: var(--sl-50); border: 1.5px solid var(--sl-200); border-left: none;
  color: var(--sl-400); padding: 0 12px; cursor: pointer;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
  transition: var(--t); line-height: 1;
}
.pw-toggle-btn:hover { color: var(--sl-600); background: var(--sl-100); }

/* ── SURVEY PAGE (responder) ─────────────────────────────── */
.survey-wrap { max-width: 620px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.survey-card {
  background: var(--white); border-radius: 18px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--sl-200); overflow: hidden;
}
.survey-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  padding: 1.75rem 1.5rem; color: white; text-align: center;
}
.survey-header h2 { font-size: 1.15rem; font-weight: 700; margin: 0 0 5px; letter-spacing: -0.02em; }
.survey-header p  { font-size: 0.78rem; opacity: 0.7; margin: 0; }
.survey-body { padding: 1.5rem; }
.survey-q-block { margin-bottom: 1.75rem; }
.survey-q-label { font-weight: 600; font-size: 0.88rem; color: var(--sl-800); margin-bottom: 0.75rem; display: block; line-height: 1.45; }
.survey-q-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; background: var(--primary); color: white;
  border-radius: 50%; font-size: 0.62rem; font-weight: 700;
  margin-right: 7px; flex-shrink: 0; vertical-align: middle;
}
.survey-divider { border: none; border-top: 1px solid var(--sl-100); margin: 1.25rem 0; }

/* NPS buttons – color coded */
.nps-btn-group { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.nps-scale-hints { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--sl-400); margin-top: 7px; padding: 0 2px; }
input.nps-radio { display: none; }
.nps-label {
  width: 42px; height: 42px;
  border: 2px solid var(--sl-200); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-weight: 700; font-size: 0.88rem;
  transition: transform 0.12s, border-color 0.12s, background 0.12s, color 0.12s, box-shadow 0.12s;
  user-select: none; color: var(--sl-600); background: var(--white);
}
@media (min-width: 480px) { .nps-label { width: 46px; height: 46px; } }
.nps-label:hover { transform: translateY(-3px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.nps-label[data-zone="det"]                           { border-color: #fecaca; color: #b91c1c; }
.nps-label[data-zone="det"]:hover                     { background: #fff0f0; border-color: #f87171; }
input.nps-radio:checked + .nps-label[data-zone="det"] { background: #ef4444; color: white; border-color: #ef4444; transform: scale(1.1); }
.nps-label[data-zone="neu"]                           { border-color: #fde68a; color: #92400e; }
.nps-label[data-zone="neu"]:hover                     { background: #fffbeb; border-color: #fbbf24; }
input.nps-radio:checked + .nps-label[data-zone="neu"] { background: #f59e0b; color: white; border-color: #f59e0b; transform: scale(1.1); }
.nps-label[data-zone="pro"]                           { border-color: #bbf7d0; color: #15803d; }
.nps-label[data-zone="pro"]:hover                     { background: #f0fdf4; border-color: #4ade80; }
input.nps-radio:checked + .nps-label[data-zone="pro"] { background: #16a34a; color: white; border-color: #16a34a; transform: scale(1.1); }

/* CSS-only star picker */
.star-picker { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 4px; }
.star-picker input { display: none; }
.star-picker label { font-size: 2.2rem; color: var(--sl-200); cursor: pointer; transition: color 0.1s, transform 0.1s; line-height: 1; user-select: none; }
.star-picker label:hover,
.star-picker label:hover ~ label                  { color: #f59e0b; }
.star-picker label:hover                          { transform: scale(1.18); }
.star-picker input:checked + label,
.star-picker input:checked + label ~ label        { color: #f59e0b; }
.star-picker-hint { font-size: 0.7rem; color: var(--sl-400); margin-top: 5px; }

/* Survey success */
.survey-success { text-align: center; padding: 3.5rem 1.5rem; }
.survey-success-icon { font-size: 4rem; display: block; margin-bottom: 1rem; animation: popIn 0.45s cubic-bezier(.175,.885,.32,1.275); }
@keyframes popIn { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.honeypot { position: absolute; left: -9999px; opacity: 0; pointer-events: none; }

/* ── SURVEY BUILDER (editar_pesquisa) ────────────────────── */
.perg-item {
  background: var(--sl-50); border: 1.5px solid var(--sl-200);
  border-radius: var(--radius); padding: 0.875rem 1rem;
  margin-bottom: 0.625rem; transition: box-shadow var(--t);
}
.perg-item:hover { box-shadow: var(--shadow-sm); border-color: var(--sl-300); }

/* ── MISC / COMPAT ───────────────────────────────────────── */
.sidebar { background: var(--sl-800); min-height: 100vh; color: white; padding: 20px; }
.sidebar .nav-link { color: var(--sl-400); padding: 9px 10px; border-radius: var(--radius-sm); margin-bottom: 4px; display: block; text-decoration: none; font-size: 0.875rem; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { background: rgba(255,255,255,0.08); color: white; }
hr { border-color: var(--sl-100); margin: 1.5rem 0; }
.progress { background: var(--sl-100); border-radius: 99px; }
.text-muted { color: var(--sl-400) !important; }
