/* ===================================
   DESIGN SYSTEM - GUIA REFERENCIAL
   Modern, Dark Theme with Glassmorphism
   =================================== */

/* CSS Variables */
:root {
  /* S1 Saúde Brand Colors */
  --primary: #E6007E;
  /* Magenta/Pink - buttons, accents */
  --primary-hover: #c90070;
  --primary-light: rgba(230, 0, 126, 0.1);

  --secondary: #272A8B;
  /* Dark Blue - text, headers */
  --secondary-hover: #1e2070;

  --accent: #00AEEF;
  /* Cyan/Light Blue - highlights */
  --accent-light: rgba(0, 174, 239, 0.1);

  --bg-light: #ffffff;
  --bg-gradient: linear-gradient(135deg, rgba(230, 0, 126, 0.05) 0%, rgba(0, 174, 239, 0.05) 100%);
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: rgba(255, 255, 255, 1);

  --text-primary: #272A8B;
  /* Dark blue for main text */
  --text-secondary: #4a4a6a;
  --text-muted: #7a7a8a;

  --border: rgba(39, 42, 139, 0.15);
  --border-focus: rgba(230, 0, 126, 0.5);

  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(39, 42, 139, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(39, 42, 139, 0.1), 0 2px 4px -2px rgba(39, 42, 139, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(39, 42, 139, 0.15), 0 8px 10px -6px rgba(39, 42, 139, 0.1);
  --shadow-glow: 0 0 20px rgba(230, 0, 126, 0.25);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

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

/* App Layout */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top left, rgba(0, 174, 239, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(230, 0, 126, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.02em;
  margin: 0;
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.header-title:hover {
  opacity: 0.8;
}

.header-logo-link {
  display: flex;
  align-items: center;
  transition: opacity var(--transition-fast);
}

.header-logo-link:hover {
  opacity: 0.85;
}

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

/* Main Content */
.main {
  flex: 1;
  padding: var(--space-xl) var(--space-lg);
}

.container {
  max-width: 800px;
  margin: 0 auto;
}

.title {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--space-xl);
  letter-spacing: 0.05em;
}

/* Step Indicator */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-2xl);
  padding: var(--space-lg);
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.step-circle {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--text-muted);
  transition: all var(--transition-normal);
}

.step.active .step-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: var(--shadow-glow);
}

.step.completed .step-circle {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.step-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--transition-fast);
}

.step.active .step-label,
.step.completed .step-label {
  color: var(--text-primary);
}

.step-line {
  width: 60px;
  height: 2px;
  background: var(--border);
  margin-bottom: 24px;
  transition: background var(--transition-normal);
}

.step-line.active {
  background: linear-gradient(90deg, var(--success), var(--primary));
}

/* Card */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.step-number {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Form Elements */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.input,
.select {
  width: 100%;
  padding: var(--space-md);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input::placeholder {
  color: var(--text-muted);
}

.select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.select option {
  background: white;
  color: var(--text-primary);
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin: var(--space-lg) 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Buttons */
.button-group {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-edit {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-edit:hover {
  background: var(--bg-card);
  color: var(--primary);
  border-color: var(--primary);
}

/* Toggle Switch */
.toggle-container {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  padding: var(--space-md);
  background: var(--accent-light);
  border-radius: var(--radius-md);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  border-radius: var(--radius-full);
  transition: var(--transition-normal);
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  border-radius: 50%;
  transition: var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked+.toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(24px);
}

.toggle-switch input:focus+.toggle-slider {
  box-shadow: 0 0 0 3px rgba(230, 0, 126, 0.2);
}

.toggle-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* Section transitions */
.section-cliente,
.section-anonimo {
  animation: fadeIn var(--transition-normal);
}

/* Badges */
.selected-plan-badge,
.location-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--primary-light);
  border: 1px solid rgba(225, 29, 72, 0.3);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-lg);
}

.badge-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.badge-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
}

.location-badge {
  color: var(--text-primary);
  font-size: 0.875rem;
}

.location-badge svg {
  color: var(--primary);
}

/* Beneficiary Badge */
.beneficiary-badge {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(34, 197, 94, 0.05) 100%);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-full);
}

/* Step 3 Badges Container */
.step3-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: var(--space-lg);
}

.step3-badges .location-badge,
.step3-badges .selected-plan-badge,
.step3-badges .beneficiary-badge {
  margin-bottom: 0;
}

.beneficiary-icon {
  font-size: 1rem;
}

.beneficiary-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--success);
}

.beneficiary-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Search Tabs */
.search-tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.tab-btn {
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

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

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn var(--transition-normal);
}

/* Wizard Steps */
.wizard-step {
  display: none;
}

.wizard-step.active {
  display: block;
  animation: slideIn var(--transition-slow);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Results */
.results-container {
  margin-top: var(--space-xl);
  animation: fadeIn var(--transition-normal);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.results-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.results-title span {
  color: var(--primary);
}

.btn-print {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-print:hover {
  background: var(--secondary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-print svg {
  flex-shrink: 0;
}

.results-grid {
  display: grid;
  gap: var(--space-md);
}

/* Provider Card */
.provider-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-fast);
}

.provider-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.provider-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-md);
}

.provider-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.provider-segment {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  background: var(--secondary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
}

.provider-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.provider-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.provider-tag {
  background-color: var(--secondary);
  color: white;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.provider-info-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.provider-info-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Multiple Addresses */
.provider-address {
  padding: var(--space-sm) 0;
}

.provider-address.multiple {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.provider-address.multiple:last-child {
  border-bottom: none;
}

.address-number {
  font-weight: 600;
  color: var(--primary);
  min-width: 20px;
}

.address-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: var(--space-md);
}

.btn-copy:hover {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

/* Botão de cópia pequeno individual */
.btn-copy-small {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  margin-left: var(--space-sm);
}

.btn-copy-small:hover {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  border: 1px solid var(--border);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-lg);
  color: white;
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all var(--transition-normal);
  z-index: 1000;
}

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

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

.toast.info {
  background: var(--secondary);
  border-color: var(--secondary);
  color: white;
}

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

/* Footer */
.footer {
  padding: var(--space-lg) var(--space-xl);
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer strong {
  color: var(--primary);
}

.footer-apps {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.footer-apps-label {
  font-weight: 500;
  color: var(--text-secondary);
}

.app-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--secondary);
  color: white;
  transition: all var(--transition-fast);
}

.app-link:hover {
  background: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: var(--space-md);
  }

  .step-indicator {
    transform: scale(0.85);
  }

  .step-line {
    width: 30px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .button-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .search-tabs {
    flex-direction: column;
  }

  .tab-btn {
    width: 100%;
    text-align: center;
  }

  .card-header-row {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .title {
    font-size: 1.25rem;
  }

  .card {
    padding: var(--space-lg);
  }

  .step-circle {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
}

/* Autocomplete */
.autocomplete-container {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  border: 1px solid var(--border-color);
  border-top: none;
  max-height: 200px;
  overflow-y: auto;
  background: white;
  z-index: 99;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.autocomplete-item {
  padding: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border-light);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background-color: var(--background-color);
  color: var(--primary-color);
}

.autocomplete-item strong {
  color: var(--primary-color);
  font-weight: 600;
}

/* Contact Actions */
.address-link,
.phone-link {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  /* Evita pulo no layout */
  transition: all var(--transition-fast);
}

.address-link:hover,
.phone-link:hover {
  color: var(--primary);
  border-bottom-color: rgba(230, 0, 126, 0.2);
  cursor: pointer;
}

/* Loading Spinner */
.loading-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border: 3px solid rgba(230, 0, 126, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Tags de Procedimentos (Busca Específica) */
.provider-tag.procedure-tag {
  background-color: #673ab7;
  /* Deep Purple */
  color: white;
  border: 1px solid #512da8;
  font-weight: 500;
}

.provider-procedures {
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}