/* ========== RESET & BASE ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #10b981;
  --danger: #ef4444;
  --text: #1e293b;
  --text-light: #64748b;
  --bg: #f8fafc;
  --white: #ffffff;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  padding-bottom: 100px;
  overscroll-behavior: contain;
}

/* ========== PROGRESS BAR ========== */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--border);
  z-index: 100;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 50%;
  transition: width 0.4s ease;
}

/* ========== HEADER ========== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 4px;
  z-index: 50;
}

.logo {
  display: flex;
  align-items: center;
}

.header-logo {
  height: 28px;
  width: auto;
}

.step-indicator {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 500;
}

/* ========== SCREENS ========== */
.screen {
  display: none;
  padding: 20px;
  max-width: 540px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

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

/* ========== SECTION BLOCKS ========== */
.section-block {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary-light);
}

/* ========== FORM FIELDS ========== */
.field {
  margin-bottom: 18px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.req {
  color: var(--danger);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="url"],
.field input[type="date"],
.field input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field input::placeholder {
  color: #94a3b8;
}

.field input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* ========== LOGIN ========== */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  min-height: 80dvh;
  max-width: 400px;
  margin: 0 auto;
}

.login-logo {
  margin-bottom: 20px;
}

.logo-img {
  width: 200px;
  height: auto;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 0.95rem;
  color: var(--text-light);
  line-height: 1.6;
  margin-bottom: 24px;
}

.login-container .field {
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
}

.login-container .btn-primary {
  margin-top: 12px;
}

.input-password-wrapper {
  position: relative;
}

.input-password-wrapper input {
  padding-right: 48px;
}

.btn-toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.btn-toggle-password .hidden {
  display: none;
}

.login-error {
  font-size: 0.85rem;
  color: var(--danger);
  font-weight: 500;
}

.login-error.hidden {
  display: none;
}

/* ========== SECTION NOTE ========== */
.section-note {
  font-size: 0.9rem;
  color: var(--text-light);
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ========== DATE SELECTS ========== */
.date-selects {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 10px;
}

.date-selects select {
  width: 100%;
  padding: 14px 12px;
  font-size: 1rem;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.date-selects select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.date-selects select.error {
  border-color: var(--danger);
}

/* ========== RADIO GROUP ========== */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.radio-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.radio-option input {
  accent-color: var(--primary);
}

/* ========== BUTTONS ========== */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--white);
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
}

.nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  gap: 12px;
}

.nav-buttons .btn-primary {
  flex: 1;
}

/* ========== AUDIO SCREEN ========== */
.audio-intro {
  text-align: center;
  padding: 20px 0 10px;
}

.audio-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--primary);
}

.audio-description {
  font-size: 1rem;
  color: var(--text-light);
  line-height: 1.7;
  margin-bottom: 12px;
}

/* ========== AUDIO TIP BOX ========== */
.audio-tip-box {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #92400e;
  margin-top: 16px;
}

.audio-tip-box strong {
  color: #78350f;
}

/* ========== RECORDER ========== */
.recorder-container {
  padding: 20px 0;
  display: flex;
  justify-content: center;
  position: relative;
}

.recorder-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.recorder-state.hidden {
  display: none;
}

/* Botão gravar */
.btn-record {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  cursor: pointer;
  justify-content: center;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn-record span {
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-record:hover {
  background: var(--primary);
  color: var(--white);
}

.btn-record:active {
  transform: scale(0.95);
}

/* Barra de gravação fixa */
.recording-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 2px solid var(--danger);
  border-radius: 50px;
  padding: 10px 20px;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.2);
  width: 100%;
  max-width: 400px;
}

.recorder-container.sticky .recording-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  width: calc(100% - 40px);
  max-width: 400px;
}

.recording-pulse-small {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.6; }
}

.recording-bar-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
}

.timer {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.btn-stop-small {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--white);
  background: var(--danger);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Concluído */
.done-icon {
  margin-bottom: 4px;
}

.done-duration {
  font-size: 1rem;
  color: var(--text-light);
  font-weight: 500;
}

#audioPlayback {
  width: 100%;
  max-width: 320px;
  margin: 8px 0;
  border-radius: 10px;
}

.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  padding: 8px 0;
  margin-bottom: 4px;
}

.done-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}

.done-actions .btn-secondary {
  flex: 1;
  padding: 12px 14px;
  font-size: 0.85rem;
}

.done-actions .btn-primary {
  flex: 1.2;
  padding: 12px 14px;
  font-size: 0.9rem;
}

/* ========== BLOCOS DE PERGUNTAS ========== */
.audio-blocks {
  margin-top: 8px;
}

.topic-block {
  background: var(--white);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topic-block-last {
  margin-bottom: 0;
}

.block-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-bottom: 1px solid var(--border);
}

.block-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.block-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.block-questions {
  padding: 16px 20px;
}

.block-questions p {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 10px;
  line-height: 1.5;
}

.block-questions ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.block-questions li {
  padding: 8px 0 8px 24px;
  position: relative;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.6;
  border-bottom: 1px solid #f1f5f9;
}

.block-questions li:last-child {
  border-bottom: none;
}

.block-questions li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: transparent;
}

.block-questions li strong {
  color: var(--text);
  font-weight: 600;
}

.block-tip {
  font-size: 0.82rem !important;
  color: var(--text-light) !important;
  font-style: italic;
  margin-top: 10px !important;
  margin-bottom: 0 !important;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}

/* ========== SUCCESS SCREEN ========== */
.success-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  min-height: 70dvh;
}

.success-logo {
  width: 180px;
  height: auto;
  margin-bottom: 24px;
}

.success-icon {
  margin-bottom: 20px;
  animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.success-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.success-text {
  font-size: 1.05rem;
  color: var(--text-light);
  line-height: 1.7;
  max-width: 400px;
}

.success-subtext {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-top: 20px;
  font-weight: 500;
}

.btn-instagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--white);
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  border-radius: 50px;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-instagram:active {
  transform: scale(0.96);
}

.btn-instagram:hover {
  box-shadow: 0 4px 15px rgba(225, 48, 108, 0.4);
}

/* ========== LOADING OVERLAY ========== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.loading-overlay.hidden {
  display: none;
}

.loading-content {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 300px;
  width: 90%;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.loading-subtext {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* ========== MOBILE OPTIMIZATIONS ========== */
@media (max-width: 480px) {
  .screen {
    padding: 16px;
  }

  .section-block {
    padding: 20px 16px;
  }

  .field input {
    padding: 12px 14px;
  }

  .block-questions {
    padding: 14px 16px;
  }

  .block-header {
    padding: 14px 16px;
  }
}

/* Extra bottom padding when recording (for sticky bar) */
body.is-recording {
  padding-bottom: 180px;
}

/* iOS safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }
}

/* Prevent zoom on input focus (iOS) */
@media screen and (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}
