/* Onde está o Dr. Fernando? — style.css
   Design tokens alinhados com MedicinUp (gold-500) + ecrã da chamada (dark).
   Zero libs externas. Mobile-first com refinements em desktop. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,700;1,400&display=swap');

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

:root {
  /* MedicinUp brand */
  --gold-50:  #FAF6E8;
  --gold-100: #F1E8C3;
  --gold-200: #E5D58E;
  --gold-300: #D9C25A;
  --gold-400: #D4AF37;
  --gold-500: #C5A028;
  --gold-600: #B08D20;
  --gold-700: #8C7019;

  /* Call screen (dark UI) */
  --call-green:        #2D9F6E;
  --call-green-dark:   #1A6B4A;
  --call-red:          #FF3B30;
  --call-bg-dark:      #1A1A1A;
  --call-bg-dark-2:    #2C2C2E;

  /* Neutrals */
  --black:      #000000;
  --white:      #FFFFFF;
  --gray-50:    #F9FAFB;
  --gray-100:   #F3F4F6;
  --gray-200:   #E5E7EB;
  --gray-300:   #D1D5DB;
  --gray-500:   #6B7280;
  --gray-600:   #4B5563;
  --gray-700:   #374151;
  --gray-900:   #111827;

  /* Semantic */
  --bg:         var(--white);
  --text:       #1A1A1A;
  --text-soft:  var(--gray-500);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --shadow-gold: 0 8px 32px rgba(197, 160, 40, 0.18);
}

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  overflow-x: hidden;
}

::selection { background: var(--gold-400); color: white; }

a { color: var(--gold-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── BRAND wordmark (Medicin + Up italic gold) ──────────────────── */

.brand {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.025em;
  color: var(--black);
  user-select: none;
}
.brand .up {
  color: var(--gold-500);
  font-style: italic;
}

/* ─── SCREEN management ──────────────────────────────────────────── */

.screen { display: none; }
.screen.active { display: block; }

#screen-call.active {
  display: flex;
  flex-direction: column;
}
#screen-result.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── LANDING (screen-landing) ───────────────────────────────────── */

#screen-landing {
  min-height: 100dvh;
  display: none;
  flex-direction: column;
  background: var(--white);
}
#screen-landing.active { display: flex; }

.landing-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
.landing-nav .brand { font-size: 1.25rem; }

.landing-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px 24px;
  text-align: center;
  gap: 24px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.hero-avatar {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: var(--shadow-gold);
  background: var(--gold-50);
}
.hero-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.hero-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.hero-sub {
  font-size: 1rem;
  line-height: 1.55;
  color: var(--gray-600);
  max-width: 460px;
}

.hero-cta {
  margin-top: 8px;
  background: var(--call-green);
  color: white;
  border: none;
  border-radius: var(--r-pill);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 16px 40px;
  min-height: 56px;
  min-width: 220px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 6px 18px rgba(45, 159, 110, 0.28);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.hero-cta:hover { background: var(--call-green-dark); }
.hero-cta:active { transform: scale(0.98); }
.hero-cta svg { width: 20px; height: 20px; }

.partner-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--gold-50);
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  color: var(--gray-700);
  font-weight: 500;
}
.partner-badge img { height: 18px; width: auto; }

/* Partner block (linha própria, logo SPH grande) */
.partner-block {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 36px 24px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--gray-200);
}
.partner-block-label {
  font-size: 0.85rem;
  color: var(--gray-600);
  letter-spacing: 0.02em;
  font-weight: 500;
  margin: 0;
}
.partner-block-link {
  display: inline-block;
  padding: 8px 18px;
  border-radius: var(--r-md);
  transition: background 0.15s ease;
}
.partner-block-link:hover {
  background: var(--gold-50);
  text-decoration: none;
}
.partner-block-logo {
  height: 130px;
  width: auto;
  display: block;
}
@media (min-width: 720px) {
  .partner-block-logo { height: 160px; }
  .partner-block { padding: 48px 24px 32px; }
}

.landing-footer {
  padding: 16px 20px 24px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--gray-500);
  line-height: 1.6;
}
.landing-footer a { color: var(--gray-600); text-decoration: underline; }
.landing-footer .sep { margin: 0 8px; color: var(--gray-300); }

/* ─── CONSENT MODAL ──────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
  animation: fade-in 0.18s ease;
}
.modal-overlay.show { display: flex; }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
.modal-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.5rem;
  margin-bottom: 14px;
  letter-spacing: -0.02em;
}
.modal-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--gray-700);
}
.modal-text ul {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}
.modal-text li {
  padding-left: 18px;
  position: relative;
  margin-bottom: 10px;
}
.modal-text li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-500);
}

.modal-partner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  padding: 12px 14px;
  background: var(--gold-50);
  border-radius: var(--r-sm);
  font-size: 0.78rem;
  color: var(--gray-700);
}
.modal-partner img { height: 28px; width: auto; }
.modal-partner a { color: var(--gold-600); text-decoration: underline; }

.modal-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0 20px;
  font-size: 0.9rem;
  color: var(--gray-700);
  cursor: pointer;
  user-select: none;
}
.modal-check input {
  margin-top: 3px;
  width: 18px; height: 18px;
  accent-color: var(--gold-500);
  cursor: pointer;
  flex-shrink: 0;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 480px) {
  .modal-actions { flex-direction: row-reverse; }
  .modal-actions > * { flex: 1; }
}

.btn {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 13px 22px;
  min-height: 48px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--call-green);
  color: white;
}
.btn-primary:not(:disabled):hover { background: var(--call-green-dark); }

.btn-gold {
  background: var(--gold-500);
  color: white;
}
.btn-gold:not(:disabled):hover { background: var(--gold-600); }

.btn-dark {
  background: var(--black);
  color: white;
}
.btn-dark:not(:disabled):hover { background: var(--gray-700); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:not(:disabled):hover { border-color: var(--gray-600); color: var(--text); }

.btn-danger {
  background: var(--call-red);
  color: white;
}

.btn-block { width: 100%; }

/* ─── CALL SCREEN (fullscreen dark) ──────────────────────────────── */

#screen-call {
  position: fixed;
  inset: 0;
  background: var(--call-bg-dark);
  color: white;
  z-index: 100;
  padding: 56px 24px 40px;
  justify-content: space-between;
  align-items: center;
}

.call-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}

.call-avatar {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  background: rgba(255,255,255,0.04);
  flex-shrink: 0;
}
.call-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.call-avatar.pulse::before,
.call-avatar.pulse::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  animation: pulse-ring 2s ease-in-out infinite;
}
.call-avatar.pulse::after {
  inset: -18px;
  border-color: rgba(255,255,255,0.12);
  animation-delay: 0.3s;
}
@keyframes pulse-ring {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.06); opacity: 0.6; }
}

.call-name {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 6px;
}
.call-status {
  font-size: 1rem;
  color: rgba(255,255,255,0.65);
  min-height: 22px;
}
.call-timer {
  font-size: 1.1rem;
  font-weight: 500;
  color: rgba(255,255,255,0.86);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  min-height: 26px;
}

#waveform-canvas {
  width: 100%;
  max-width: 320px;
  height: 44px;
  opacity: 0;
  transition: opacity 0.5s ease;
  margin-top: 6px;
}
#waveform-canvas.visible { opacity: 1; }

.call-controls {
  width: 100%;
  max-width: 320px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}
.ctrl-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.ctrl-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.1s ease;
}
.ctrl-btn:active { transform: scale(0.93); }
.ctrl-btn-secondary { background: var(--call-bg-dark-2); }
.ctrl-btn-secondary svg { color: white; }
.ctrl-btn-secondary.active { background: white; }
.ctrl-btn-secondary.active svg { color: var(--call-bg-dark); }
.ctrl-btn-end {
  background: var(--call-red);
  width: 70px;
  height: 70px;
}
.ctrl-btn-end svg { color: white; transform: rotate(135deg); }
.ctrl-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
  text-align: center;
}

/* ─── SKIP button (canto superior direito, discreto) ── */
.skip-btn {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 300;
  background: rgba(255,255,255,0.08);
  color: var(--gold-500);
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid rgba(197, 160, 40, 0.55);
  border-radius: var(--r-pill);
  padding: 5px 12px;
  cursor: pointer;
  display: none; /* JS faz toggle conforme SKIP_ENABLED */
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}
.skip-btn:hover { background: rgba(197, 160, 40, 0.18); }
.skip-btn:active { transform: scale(0.94); }

/* ─── MEDIÇÃO (modal sobre call) ─────────────────────────────────── */

.measure-modal .modal {
  max-width: 420px;
  background: var(--white);
}
.measure-h {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.measure-sub {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-bottom: 16px;
}

.measure-block {
  border: 1px solid var(--gray-200);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 10px;
  background: var(--white);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.measure-block.selected {
  border-color: var(--gold-500);
  background: var(--gold-50);
  box-shadow: 0 0 0 3px rgba(197, 160, 40, 0.12);
}
.measure-block.not-selected {
  background: var(--gray-50);
  opacity: 0.78;
}
.measure-block-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.measure-block-label .selected-tag {
  display: none;
  color: var(--gold-600);
  font-size: 0.7rem;
}
.measure-block.selected .selected-tag { display: inline; }

.measure-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.measure-input {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.measure-input label {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 500;
}
.measure-input input {
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  padding: 10px 8px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r-sm);
  outline: none;
  width: 100%;
  background: white;
  color: var(--text);
  transition: border-color 0.15s ease;
  -moz-appearance: textfield;
}
.measure-input input::-webkit-outer-spin-button,
.measure-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.measure-input input:focus {
  border-color: var(--gold-500);
}
.measure-input .unit {
  font-size: 0.7rem;
  color: var(--gray-500);
  text-align: center;
  letter-spacing: 0.04em;
}

.measure-table-wrap {
  margin-top: 14px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--gray-200);
}
.measure-table-wrap img {
  width: 100%;
  height: auto;
  display: block;
}
.measure-table-caption {
  font-size: 0.7rem;
  color: var(--gray-500);
  text-align: center;
  padding: 8px 10px;
  background: var(--gray-50);
  line-height: 1.45;
}

.measure-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.measure-actions.single { grid-template-columns: 1fr; }

/* ─── QUIZ MODAL ─────────────────────────────────────────────────── */

.quiz-modal .modal {
  max-width: 480px;
  background: linear-gradient(180deg, #FFFCF0 0%, #FFFFFF 100%);
  border-top: 4px solid var(--gold-500);
}
.quiz-h {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}
.quiz-sub {
  font-size: 0.9rem;
  color: var(--gray-600);
  text-align: center;
  margin-bottom: 22px;
}
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.quiz-option {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 18px 12px;
  border-radius: var(--r-md);
  border: 2px solid var(--gold-300);
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.1s ease, color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 64px;
}
.quiz-option:hover {
  background: var(--gold-50);
  border-color: var(--gold-500);
}
.quiz-option:active { transform: scale(0.97); }
.quiz-option.correct {
  background: #DCFCE7;
  border-color: #16A34A;
  color: #166534;
  animation: pop 0.4s ease;
}
.quiz-option.wrong {
  background: #FEE2E2;
  border-color: #DC2626;
  color: #991B1B;
  animation: shake 0.4s ease;
}
.quiz-option:disabled { cursor: default; }

@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

/* ─── ENDED screen ───────────────────────────────────────────────── */

#screen-result {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 110;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.result-card {
  background: var(--call-bg-dark-2);
  border-radius: 22px;
  padding: 36px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  color: white;
}
.result-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: rgba(255,59,48,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.result-icon svg { color: var(--call-red); transform: rotate(135deg); }
.result-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.result-duration {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 22px;
  font-variant-numeric: tabular-nums;
}
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── LEGAL pages (politica + termos) ────────────────────────────── */

.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.legal-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--gold-600);
  margin-bottom: 24px;
  text-decoration: none;
}
.legal-back:hover { text-decoration: underline; }
.legal-page h1 {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: -0.025em;
  margin-bottom: 8px;
}
.legal-page .updated {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-bottom: 28px;
}
.legal-page h2 {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  margin-top: 28px;
  margin-bottom: 10px;
  color: var(--gray-900);
}
.legal-page p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--gray-700);
  margin-bottom: 12px;
}
.legal-page ul {
  margin: 8px 0 14px 24px;
}
.legal-page li {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.legal-page strong { color: var(--text); }

/* ─── safe area iOS notch ────────────────────────────────────────── */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #screen-call {
    padding-top: max(56px, env(safe-area-inset-top));
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }
  #screen-landing {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
}

/* ─── desktop refinements ────────────────────────────────────────── */

@media (min-width: 720px) {
  .landing-hero {
    padding: 56px 24px 40px;
    gap: 28px;
  }
  .hero-avatar { width: 220px; height: 220px; }
  .hero-cta { padding: 18px 48px; font-size: 1.05rem; min-width: 260px; }
}

@media (min-width: 480px) {
  #screen-call {
    padding-left: 0;
    padding-right: 0;
  }
  .call-top, .call-controls { padding: 0 16px; }
}
