/* ============================================
   CUESTIONARIO EPD — García Parot Abogados
   ============================================ */

:root {
  --primary: #1e3a5f;
  --primary-light: #2a5a8f;
  --accent: #c9a84c;
  --accent-light: #e8d49a;
  --bg: #f8f9fb;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #5a6178;
  --border: #e2e5ec;
  --danger: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --critical-bg: #fef2f2;
  --critical-border: #fca5a5;
  --alta-bg: #fffbeb;
  --alta-border: #fcd34d;
  --media-bg: #f0f9ff;
  --media-border: #93c5fd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

/* Screens */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* =====================
   WELCOME SCREEN
   ===================== */
.welcome-container {
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  justify-content: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.logo-img {
  height: 28px;
  width: auto;
  filter: brightness(0.3);
}

.logo-small-img {
  height: 18px;
  width: auto;
  filter: brightness(0.3);
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: -0.2px;
}

.welcome-container h1 {
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  color: var(--primary);
  line-height: 1.3;
  margin-bottom: 8px;
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

.confidential-badge {
  background: var(--primary);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 6px 20px;
  border-radius: 20px;
  margin-bottom: 28px;
}

.welcome-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 32px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.welcome-info p { margin-bottom: 8px; }
.welcome-info p:last-child { margin-bottom: 0; }
.welcome-info strong { color: var(--text); }

/* Login form */
.login-box {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  transition: var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.login-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 20px;
  margin-top: 8px;
}

.select-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  text-align: center;
}

.user-select {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-user {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  transition: var(--transition);
  text-align: left;
  position: relative;
}

.btn-user:hover {
  border-color: var(--primary);
  background: #f0f4f8;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.user-icon {
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-role {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* =====================
   QUIZ HEADER
   ===================== */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-small {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.header-user {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.header-center {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 300px;
  margin: 0 20px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
}

.btn-icon:hover { background: var(--bg); color: var(--text); }

/* =====================
   QUIZ MAIN
   ===================== */
.quiz-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.question-container {
  width: 100%;
  max-width: 640px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.question-number {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.priority-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 12px;
}

.priority-CRÍTICA { background: var(--critical-bg); color: var(--danger); border: 1px solid var(--critical-border); }
.priority-ALTA { background: var(--alta-bg); color: #b45309; border: 1px solid var(--alta-border); }
.priority-MEDIA { background: var(--media-bg); color: #1d4ed8; border: 1px solid var(--media-border); }

.question-text {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: 12px;
}

.question-context {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
  padding: 12px 16px;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary-light);
}

.answer-textarea {
  width: 100%;
  min-height: 140px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  transition: var(--transition);
}

.answer-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.answer-textarea::placeholder { color: #b0b8c8; }

.answer-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.saved-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--success);
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.3s;
}

.saved-indicator.visible { opacity: 1; }

/* Documents checklist (Section H) */
.documents-section { width: 100%; max-width: 640px; }

.documents-section h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--primary);
}

.documents-section .section-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.doc-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: var(--transition);
}

.doc-item:hover { border-color: var(--primary-light); }

.doc-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

.doc-label {
  flex: 1;
  font-size: 14px;
  cursor: pointer;
}

.doc-entity {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.doc-note-input {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

.doc-note-input:focus { outline: none; border-color: var(--primary); }

/* =====================
   QUIZ FOOTER
   ===================== */
.quiz-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.btn-nav:hover { background: var(--bg); border-color: var(--primary); }
.btn-nav:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-nav:disabled:hover { background: var(--surface); border-color: var(--border); }

.btn-next {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-next:hover { background: var(--primary-light); }
.btn-next:disabled { background: var(--primary); opacity: 0.5; }
.btn-next:disabled:hover { background: var(--primary); }

.btn-next.btn-finish {
  background: var(--success);
  border-color: var(--success);
}
.btn-next.btn-finish:hover { background: #059669; }

.footer-center { flex: 1; text-align: center; }

.section-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* =====================
   OVERVIEW SCREEN
   ===================== */
.overview-main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.overview-section {
  margin-bottom: 32px;
}

.overview-section h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.overview-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.overview-item:hover { background: #f8fafc; margin: 0 -12px; padding: 12px; border-radius: var(--radius-sm); }

.overview-status {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  margin-top: 2px;
}

.status-done { background: #dcfce7; color: var(--success); }
.status-empty { background: #fee2e2; color: var(--danger); }

.overview-q {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.overview-q small {
  display: block;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 4px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 500px;
}

.overview-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.stat-number { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* =====================
   COMPLETE SCREEN
   ===================== */
.complete-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  justify-content: center;
  text-align: center;
}

.check-circle { margin-bottom: 24px; }

.complete-container h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
}

.complete-container > p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.6;
}

.complete-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary:hover { background: var(--primary-light); }

.btn-secondary {
  width: 100%;
  padding: 14px;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover { border-color: var(--primary); }

.btn-link {
  background: none;
  border: none;
  color: var(--primary-light);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px;
  text-decoration: underline;
}

.send-status {
  margin-top: 20px;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  display: none;
}

.send-status.success { display: block; background: #dcfce7; color: #166534; }
.send-status.error { display: block; background: #fef2f2; color: #991b1b; }
.send-status.loading { display: block; background: #f0f9ff; color: #1e40af; }

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 640px) {
  .welcome-container { padding: 24px 16px; }
  .welcome-container h1 { font-size: 22px; }
  .quiz-header { padding: 10px 16px; }
  .header-center { max-width: 140px; margin: 0 10px; }
  .progress-text { display: none; }
  .quiz-main { padding: 20px 16px; }
  .question-text { font-size: 17px; }
  .quiz-footer { padding: 10px 16px; }
  .btn-nav { padding: 10px 14px; font-size: 13px; }
  .overview-stats { grid-template-columns: 1fr; }
  .overview-main { padding: 16px; }
}

@media (max-width: 380px) {
  .btn-prev span { display: none; }
  .header-user { display: none; }
}

/* Keyboard nav hint */
.keyboard-hint {
  position: fixed;
  bottom: 70px;
  right: 24px;
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.6;
}

@media (max-width: 640px) {
  .keyboard-hint { display: none; }
}

/* =====================
   QUESTIONNAIRE SELECTOR
   ===================== */
.questionnaire-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.btn-questionnaire {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 18px 20px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: var(--transition);
}

.btn-questionnaire:hover {
  border-color: var(--primary);
  background: #f0f4f8;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.q-selector-info { flex: 1; }

.q-selector-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.q-selector-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.q-selector-rut {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.q-selector-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: 16px;
}

.q-selector-pct {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  min-width: 36px;
  text-align: right;
}

.progress-mini {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-mini-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.3s;
}
