/* ==========================================================================
   Design System & Tokens - Mobile-First Patient Registration
   ========================================================================== */
:root {
  --bg-gradient-1: #FAF6F3;
  --bg-gradient-2: #F3EAE3;
  --bg-gradient-3: #EBF4F2;
  
  --ink-primary: #1C1917;
  --ink-secondary: #57534E;
  --ink-muted: #78716C;
  
  --panel-bg: rgba(255, 255, 255, 0.94);
  --panel-border: rgba(214, 200, 190, 0.65);
  --panel-shadow: 0 20px 40px -15px rgba(60, 40, 35, 0.08), 0 0 1px rgba(0, 0, 0, 0.1);
  
  --brand-accent: #9E4A62;
  --brand-accent-hover: #833B50;
  --brand-gold: #B28348;
  --mint-accent: #267A70;
  --mint-light: #EBF7F5;
  --whatsapp-green: #25D366;
  --whatsapp-hover: #1EBE5B;
  
  --input-bg: #FCFBF9;
  --input-border: #E5DDD7;
  --input-focus: #9E4A62;
  
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --danger-border: #FCA5A5;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --font-main: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  color: var(--ink-primary);
  font-family: var(--font-main);
  background: 
    radial-gradient(circle at 10% 20%, rgba(178, 131, 72, 0.08), transparent 400px),
    radial-gradient(circle at 90% 80%, rgba(38, 122, 112, 0.08), transparent 400px),
    linear-gradient(160deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 50%, var(--bg-gradient-3) 100%);
  background-attachment: fixed;
  padding-bottom: 40px;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Header Top Nav (Recepção / Admin)
   ========================================================================== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(229, 221, 215, 0.7);
  padding: 10px 16px;
}

.top-nav-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.clinic-badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-gold);
}

.admin-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(158, 74, 98, 0.08);
  color: var(--brand-accent);
  border: 1px solid rgba(158, 74, 98, 0.2);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.admin-trigger-btn:hover, .admin-trigger-btn:active {
  background: var(--brand-accent);
  color: #ffffff;
}

/* ==========================================================================
   Main Shell Layout (Mobile-First Centered Container)
   ========================================================================== */
.page-shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 30px;
}

.card-container {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
  padding: 24px 20px;
}

/* ==========================================================================
   Header & Intro Section
   ========================================================================== */
.intro {
  text-align: center;
  margin-bottom: 24px;
}

.intro[hidden] {
  display: none;
}

.brand-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.brand-logo {
  width: 160px;
  height: auto;
  object-fit: contain;
}

h1 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--ink-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.intro-copy {
  font-size: 0.9rem;
  color: var(--ink-secondary);
  line-height: 1.45;
}

/* ==========================================================================
   Appointment Summary Badge
   ========================================================================== */
.appointment-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--mint-light);
  border: 1.5px solid rgba(38, 122, 112, 0.25);
  border-radius: var(--radius-md);
  text-align: left;
  animation: fadeIn 0.4s ease-out;
}

.appointment-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(38, 122, 112, 0.12);
  color: var(--mint-accent);
  flex-shrink: 0;
}

.appointment-details {
  display: flex;
  flex-direction: column;
}

.appointment-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mint-accent);
}

.appointment-value {
  font-size: 0.98rem;
  font-weight: 800;
  color: #114B44;
}

/* ==========================================================================
   Success Screen (Exibida após o envio com sucesso)
   ========================================================================== */
.success-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 10px 10px;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.success-screen[hidden] {
  display: none;
}

.success-icon-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--mint-light);
  color: var(--mint-accent);
  margin-bottom: 18px;
  box-shadow: 0 10px 25px rgba(38, 122, 112, 0.18);
}

.success-screen h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ink-primary);
  margin-bottom: 8px;
  line-height: 1.25;
}

.success-desc {
  font-size: 0.92rem;
  color: var(--ink-secondary);
  line-height: 1.5;
  margin-bottom: 18px;
}

.success-appointment-box {
  width: 100%;
  background: var(--mint-light);
  border: 2px solid var(--mint-accent);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 18px;
}

.success-appointment-box .box-tag {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mint-accent);
}

.success-appointment-box strong {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0E4942;
}

.success-subtext {
  font-size: 0.85rem;
  color: var(--ink-muted);
  line-height: 1.45;
  margin-bottom: 14px;
}

/* ==========================================================================
   Form Fields & Grid
   ========================================================================== */
.form-panel {
  width: 100%;
}

.form-panel[hidden] {
  display: none;
}

form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-primary);
}

input[type="text"],
input[type="tel"],
input[type="date"],
input[type="time"],
textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  color: var(--ink-primary);
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition-fast);
  -webkit-appearance: none;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-muted);
  opacity: 0.7;
}

input:focus,
textarea:focus {
  border-color: var(--input-focus);
  background: #ffffff;
  box-shadow: 0 0 0 3.5px rgba(158, 74, 98, 0.14);
}

input[readonly] {
  cursor: default;
  color: var(--ink-secondary);
  background: #F4F8F7;
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.error-message {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--danger);
  min-height: 14px;
}

.privacy-field {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--ink-secondary);
  font-size: 0.84rem;
  line-height: 1.45;
  cursor: pointer;
}

.privacy-field input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--brand-accent);
  flex: 0 0 auto;
}

.privacy-field.has-error {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.privacy-error {
  margin-top: -8px;
}

.honeypot-field {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.unavailable-message {
  margin-top: 12px;
}

.success-close-button {
  margin-top: 10px;
  background: var(--mint-accent);
  box-shadow: 0 8px 20px rgba(38, 122, 112, 0.25);
}

/* Section Divider */
.section-divider {
  display: flex;
  align-items: center;
  margin: 10px 0 2px;
}

.section-divider span {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-gold);
  background: rgba(178, 131, 72, 0.08);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   Submit Button & Actions
   ========================================================================== */
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand-accent) 0%, var(--brand-accent-hover) 100%);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(158, 74, 98, 0.28);
  transition: var(--transition-fast);
}

.submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(158, 74, 98, 0.35);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
  transform: none;
}

.button-loader {
  display: none;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.submit-btn.is-loading .button-label {
  display: none;
}

.submit-btn.is-loading .button-loader {
  display: block;
}

/* Status Feedback Messages */
.status-message {
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  border-radius: var(--radius-md);
  padding: 0;
  min-height: 20px;
}

.status-message.error {
  padding: 12px;
  background: var(--danger-bg);
  border: 1.5px solid var(--danger-border);
  color: var(--danger);
}

/* ==========================================================================
   Admin Modal (Link Generator)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(28, 25, 23, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.25s ease-out;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--input-border);
  background: var(--bg-gradient-1);
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink-primary);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  background: rgba(0,0,0,0.05);
  color: var(--ink-primary);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  line-height: 1.45;
}

.modal-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.generated-link-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-gradient-1);
  border: 1.5px dashed var(--brand-accent);
  border-radius: var(--radius-md);
  padding: 14px;
}

.box-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--brand-accent);
}

#generatedUrlInput {
  font-size: 0.82rem;
  background: #ffffff;
  border: 1px solid var(--input-border);
  color: var(--ink-secondary);
}

.modal-actions-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-primary, .btn-secondary, .btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition-fast);
}

.btn-primary {
  background: var(--brand-accent);
  color: #ffffff;
  width: 100%;
}
.btn-primary:hover {
  background: var(--brand-accent-hover);
}

.btn-secondary {
  background: rgba(28, 25, 23, 0.06);
  color: var(--ink-primary);
}
.btn-secondary:hover {
  background: rgba(28, 25, 23, 0.12);
}

.btn-whatsapp {
  background: var(--whatsapp-green);
  color: #ffffff;
}
.btn-whatsapp:hover {
  background: var(--whatsapp-hover);
}

.copy-feedback {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--mint-accent);
  text-align: center;
  min-height: 16px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--input-border);
  background: var(--bg-gradient-1);
}

/* ==========================================================================
   Animations & Responsive Breakpoints
   ========================================================================== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

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

/* Desktop layout extension for wider screens */
@media (min-width: 640px) {
  .page-shell {
    max-width: 540px;
    padding-top: 36px;
  }
  
  .card-container {
    padding: 32px 28px;
  }
  
  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .field-full {
    grid-column: 1 / -1;
  }

  .section-divider {
    grid-column: 1 / -1;
  }

  .modal-actions-row {
    flex-direction: row;
  }
  .modal-actions-row button {
    flex: 1;
  }
}
