/* ═══════════════════════════════════════════════════════════
   PAINEL DE AGENDAMENTOS — Estilos
   Tema escuro (padrão) + tema claro via data-theme="light"
   Acento principal: #491e9c
   ═══════════════════════════════════════════════════════════ */

/* ─── Reset & Base ──────────────────────────────────────── */

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

/* ─── Variáveis — Tema Escuro ───────────────────────────── */

:root,
[data-theme="dark"] {
  --color-bg:           #090710;
  --color-surface:      #13101f;
  --color-surface-2:    #1a1528;
  --color-border:       rgba(73, 30, 156, 0.2);
  --color-border-hover: rgba(73, 30, 156, 0.45);
  --color-primary:      #491e9c;
  --color-primary-rgb:  73, 30, 156;
  --color-primary-soft: #5c2fc4;
  --color-primary-glow: rgba(73, 30, 156, 0.15);
  --color-accent:       #8257e6;
  --color-text:         #e4ddf1;
  --color-text-muted:   #9688b0;
  --color-text-dim:     #6e5f8a;
  --color-danger:       #e54560;
  --color-danger-soft:  rgba(229, 69, 96, 0.12);
  --color-success:      #34d399;
  --color-success-soft: rgba(52, 211, 153, 0.12);
  --color-warning:      #fbbf24;
  --color-input-bg:     #0f0c1a;
  --color-input-border: #2a2240;
  --color-input-focus:  #491e9c;
  --shadow-sm:          0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:          0 4px 16px rgba(0,0,0,0.5);
  --shadow-glow:        0 0 40px rgba(73, 30, 156, 0.12);
  --radius-sm:          8px;
  --radius-md:          14px;
  --radius-lg:          20px;
  --font-display:       'Outfit', sans-serif;
  --font-body:          'Nunito Sans', sans-serif;
}

/* ─── Variáveis — Tema Claro ────────────────────────────── */

[data-theme="light"] {
  --color-bg:           #f4f0fa;
  --color-surface:      #ffffff;
  --color-surface-2:    #f0ecf7;
  --color-border:       rgba(73, 30, 156, 0.12);
  --color-border-hover: rgba(73, 30, 156, 0.3);
  --color-primary-glow: rgba(73, 30, 156, 0.06);
  --color-text:         #1c1230;
  --color-text-muted:   #5e5077;
  --color-text-dim:     #8a7da3;
  --color-danger-soft:  rgba(229, 69, 96, 0.08);
  --color-success-soft: rgba(52, 211, 153, 0.10);
  --color-input-bg:     #f8f5ff;
  --color-input-border: #d4cce6;
  --color-shadow-sm:    0 1px 3px rgba(73, 30, 156, 0.06);
  --shadow-md:          0 4px 20px rgba(73, 30, 156, 0.08);
  --shadow-glow:        0 0 40px rgba(73, 30, 156, 0.05);
}

/* ─── Base ──────────────────────────────────────────────── */

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.35s ease, color 0.35s ease;
}

/* Textura sutil de fundo */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 50% 0%, rgba(var(--color-primary-rgb), 0.07), transparent),
    radial-gradient(ellipse 400px 300px at 80% 80%, rgba(var(--color-primary-rgb), 0.04), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ─── Botão de Tema ─────────────────────────────────────── */

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}

.theme-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-soft);
  transform: scale(1.08);
}

.theme-icon {
  width: 18px;
  height: 18px;
}

/* ─── Layout ────────────────────────────────────────────── */

.container {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

/* ─── Header ────────────────────────────────────────────── */

.header {
  text-align: center;
  margin-bottom: 2rem;
  position: relative;
}

.header-glow {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 80px;
  background: radial-gradient(ellipse, rgba(var(--color-primary-rgb), 0.2), transparent 70%);
  pointer-events: none;
}

.header-title {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary-soft));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-sub {
  font-size: 0.92rem;
  color: var(--color-text-muted);
  margin-top: 0.35rem;
}

/* ─── Card / Form ───────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow-glow);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.form-card {
  animation: fadeSlideUp 0.5s ease both;
}

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

/* ─── Campos ────────────────────────────────────────────── */

.field-group {
  margin-bottom: 1.35rem;
}

.field-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.field-input {
  width: 100%;
  padding: 0.72rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-text);
  background: var(--color-input-bg);
  border: 1.5px solid var(--color-input-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-input::placeholder {
  color: var(--color-text-dim);
  opacity: 0.6;
}

.field-input:focus {
  border-color: var(--color-input-focus);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

.field-input.field-error-state {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(229, 69, 96, 0.1);
}

.field-error {
  display: block;
  font-size: 0.78rem;
  color: var(--color-danger);
  margin-top: 0.3rem;
  min-height: 1rem;
}

.field-row {
  display: flex;
  gap: 0.85rem;
}

.field-ddd {
  flex: 0 0 110px;
}

.field-phone {
  flex: 1;
}

/* ─── Checkbox Salvar Dados ─────────────────────────────── */

.field-checkbox {
  margin-bottom: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.checkbox-custom {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--color-input-border);
  border-radius: 4px;
  background: var(--color-input-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin-top: 1px;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -1px;
}

.checkbox-label input[type="checkbox"]:focus-visible + .checkbox-custom {
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

.checkbox-text {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* ─── Botões ────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-soft));
  color: #fff;
  box-shadow: 0 2px 12px rgba(var(--color-primary-rgb), 0.3);
  margin-top: 0.5rem;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(var(--color-primary-rgb), 0.45);
}

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-outline {
  padding: 0.55rem 1rem;
  background: transparent;
  color: var(--color-text-muted);
  border: 1.5px solid var(--color-border);
}

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

.btn-danger {
  padding: 0.55rem 1rem;
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.1);
}

.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm {
  font-size: 0.82rem;
  padding: 0.5rem 0.9rem;
}

.btn-reschedule {
  padding: 0.55rem 1rem;
  background: var(--color-primary-glow);
  color: var(--color-accent);
  border: 1.5px solid var(--color-border);
}

.btn-reschedule:hover {
  border-color: var(--color-accent);
  background: rgba(var(--color-primary-rgb), 0.12);
}

.btn-cancel-card {
  padding: 0.55rem 1rem;
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border: 1.5px solid transparent;
}

.btn-cancel-card:hover {
  border-color: var(--color-danger);
}

/* ─── Spinner ───────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ─── Resultados ────────────────────────────────────────── */

.results-section {
  animation: fadeSlideUp 0.4s ease both;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.results-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* ─── Card de Agendamento ───────────────────────────────── */

.ag-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, transform 0.15s ease;
  animation: fadeSlideUp 0.4s ease both;
}

.ag-card:hover {
  border-color: var(--color-border-hover);
}

.ag-card.cancelled {
  opacity: 0.4;
  pointer-events: none;
}

.ag-status-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  margin-bottom: 0.65rem;
}

.badge-confirmado {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.badge-pendente {
  background: rgba(251, 191, 36, 0.12);
  color: var(--color-warning);
}

.badge-default {
  background: var(--color-primary-glow);
  color: var(--color-accent);
}

.ag-datetime {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}

.ag-detail {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.1rem;
}

.ag-detail strong {
  color: var(--color-text);
  font-weight: 600;
}

.ag-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.ag-actions-blocked {
  gap: 0;
}

.ag-blocked-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-warning);
  background: rgba(251, 191, 36, 0.08);
  border-left: 3px solid var(--color-warning);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.4;
}

.ag-blocked-notice svg {
  flex-shrink: 0;
}

/* ─── Tab Toggle ────────────────────────────────────────── */

.tab-toggle {
  display: flex;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 1.25rem;
}

.tab-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover:not(.active) {
  color: var(--color-text);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-soft));
  color: #fff;
  box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.3);
}

/* ─── Periodicidade ─────────────────────────────────────── */

.periodicidade-section {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.periodicidade-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.84rem;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.periodicidade-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.periodicidade-content {
  flex: 1;
}

.periodicidade-servico {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}

.periodicidade-info {
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.periodicidade-disponivel {
  color: var(--color-success);
  font-weight: 600;
}

.periodicidade-indisponivel {
  color: var(--color-warning);
  font-weight: 600;
}

/* ─── Card Passado (sem ações) ──────────────────────────── */

.ag-card.ag-card-past {
  opacity: 0.85;
}

.ag-card.ag-card-past .ag-status-badge-inline {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.55rem;
  border-radius: 99px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.badge-finalizado {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.badge-nao-compareceu {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.badge-confirmado-past {
  background: rgba(var(--color-primary-rgb), 0.1);
  color: var(--color-accent);
}

/* ─── Empty State ───────────────────────────────────────── */

.results-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--color-text-dim);
}

.empty-icon {
  color: var(--color-text-dim);
  opacity: 0.4;
  margin-bottom: 0.75rem;
}

/* ─── Modal ─────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: scaleIn 0.25s ease;
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.modal-text {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 0.65rem;
  justify-content: center;
}

.link-success-icon {
  color: var(--color-success);
  margin-bottom: 0.75rem;
}

.info-modal-icon {
  color: var(--color-warning);
  margin-bottom: 0.75rem;
}

.info-highlight {
  background: rgba(251, 191, 36, 0.10);
  border-left: 3px solid var(--color-warning);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-warning);
  line-height: 1.5;
  text-align: left;
}

/* ─── Toast / Mensagem Inline ───────────────────────────── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.2rem;
  font-size: 0.85rem;
  font-family: var(--font-body);
  box-shadow: var(--shadow-md);
  z-index: 300;
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-error {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.toast.toast-success {
  border-color: var(--color-success);
  color: var(--color-success);
}

/* ─── Footer ────────────────────────────────────────────── */

.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.75rem;
  color: var(--color-text-dim);
}

/* ─── Responsivo ────────────────────────────────────────── */

@media (max-width: 480px) {
  .container {
    padding: 1.5rem 1rem 2.5rem;
  }
  .card {
    padding: 1.5rem 1.25rem;
  }
  .header-title {
    font-size: 1.5rem;
  }
  .field-row {
    flex-direction: column;
    gap: 0;
  }
  .field-ddd {
    flex: 1;
  }
  .modal-card {
    padding: 1.5rem 1.25rem;
  }
}
/* ─── Aviso: atendimento é pelo aplicativo ──────────────── */
/* Cores fixas (não dependem do tema) para manter o contraste
   igual no modo claro e escuro. Troca de cor a cada 0,8s —
   abaixo do limite de 3 piscadas/s (WCAG 2.3.1). */

.app-alert {
  margin: 0 0.25rem 1.75rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-md);
  border: 3px solid currentColor;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  animation:
    appAlertColors 2.4s linear infinite,
    appAlertPulse 1.2s ease-in-out infinite alternate;
  will-change: transform;
}

.app-alert-text {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.4;
}

@keyframes appAlertColors {
  0%, 30%   { background: #e54560; color: #ffffff; }
  33%, 63%  { background: #fbbf24; color: #1c1230; }
  66%, 96%  { background: #491e9c; color: #ffffff; }
  100%      { background: #e54560; color: #ffffff; }
}

@keyframes appAlertPulse {
  from { transform: scale(0.96); }
  to   { transform: scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .app-alert {
    animation: appAlertColors 4.8s linear infinite;
  }
}

/* ─── Card: consulta em andamento ───────────────────────── */

.ag-card.ag-card-live {
  border: 2px solid var(--color-success);
  box-shadow: 0 0 0 4px var(--color-success-soft);
}

.ag-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  margin-bottom: 0.65rem;
  background: var(--color-success-soft);
  color: var(--color-success);
}

.ag-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  animation: liveDot 1.2s ease-in-out infinite;
}

@keyframes liveDot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

.ag-live-notice {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.86rem;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-success);
  background: var(--color-success-soft);
  border-left: 3px solid var(--color-success);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .app-alert {
    padding: 0.9rem 1rem;
  }
  .app-alert-text {
    font-size: 0.95rem;
  }
}
