/* ==========================================================================
   AgendaRx Premium Stylesheet (Modern, Mobile-First, Accessible)
   ========================================================================== */

/* Custom Fonts & Reset */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Color Palette (Deep Cobalt & Mint Green) */
  --primary-hsl: 222, 89%, 25%;
  --primary: hsl(var(--primary-hsl));
  --primary-light: hsl(222, 89%, 95%);
  --primary-medium: hsl(222, 89%, 60%);
  --secondary: hsl(152, 60%, 45%);
  --secondary-light: hsl(152, 60%, 94%);
  --accent: hsl(200, 95%, 45%);
  
  /* Neutral Grays */
  --bg-app: #f4f6fc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  
  /* Status Colors */
  --color-success: #10b981;
  --color-success-bg: #ecfdf5;
  --color-warning: #f59e0b;
  --color-warning-bg: #fffbeb;
  --color-danger: #ef4444;
  --color-danger-bg: #fef2f2;
  
  /* Shadows and Borders */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 15px -3px rgba(30, 41, 59, 0.05), 0 4px 6px -2px rgba(30, 41, 59, 0.02);
  --shadow-lg: 0 20px 25px -5px rgba(30, 41, 59, 0.1), 0 10px 10px -5px rgba(30, 41, 59, 0.04);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Dark Mode Theme Variables */
body.dark-mode {
  --bg-app: #0f172a;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --primary-light: rgba(59, 130, 246, 0.1);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Main Layout Wrapper */
.app-container {
  max-width: 480px; /* Mobile first cap */
  width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.03);
}

/* Desktop layout expander */
@media (min-width: 992px) {
  .app-container {
    max-width: 960px;
    margin: 40px auto;
    min-height: calc(100vh - 80px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
}

/* Header styling */
header {
  padding: 20px 24px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.15);
}

.logo-text {
  font-weight: 700;
  font-size: 1.3rem;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  background-color: var(--primary-light);
  transform: scale(1.05);
}

/* App Screens / Views */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.screen.hidden {
  display: none !important;
}

/* Onboarding / RUT input Card */
.auth-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  margin: auto 0;
  text-align: center;
  animation: slideUp 0.4s ease-out;
}

.auth-header img {
  width: 80px;
  margin-bottom: 16px;
}

.auth-card h2 {
  font-weight: 700;
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.auth-card p {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

/* Custom form components */
.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  position: relative;
}

.input-wrapper i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 14px 16px 14px 44px;
  font-family: var(--font-family);
  font-size: 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background-color: var(--bg-app);
  color: var(--text-main);
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-medium);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background-color: var(--bg-card);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-medium));
  color: white;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

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

.btn-secondary {
  background-color: var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--text-muted);
  color: white;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Quick register UI */
.register-container {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  animation: fadeIn 0.3s ease-out;
}

.register-container h3 {
  margin-bottom: 16px;
  font-weight: 700;
}

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

/* Step tracker indicator */
.steps-indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  position: relative;
}

.steps-line {
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 2px;
  background-color: var(--border);
  z-index: 1;
}

.steps-line-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 100%;
  background-color: var(--accent);
  transition: width 0.3s ease;
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--bg-app);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  z-index: 2;
  transition: var(--transition);
}

.step-dot.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}

.step-dot.completed {
  background-color: var(--secondary);
  border-color: var(--secondary);
  color: white;
}

/* Exam Selector & Upload */
.exam-search-wrapper {
  position: relative;
}

.predictive-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 20;
  max-height: 200px;
  overflow-y: auto;
}

.predictive-item {
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

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

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

.selected-exam-card {
  background-color: var(--primary-light);
  border: 1.5px solid var(--primary-medium);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* File Upload Area */
.file-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  background-color: var(--bg-card);
  transition: var(--transition);
}

.file-upload-zone:hover {
  border-color: var(--primary-medium);
  background-color: var(--primary-light);
}

.file-upload-zone i {
  font-size: 2.2rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Branch selectors */
.branch-card {
  background-color: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 16px;
}

.branch-card:hover {
  border-color: var(--primary-medium);
}

.branch-card.selected {
  border-color: var(--primary-medium);
  background-color: var(--primary-light);
}

.radio-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.branch-card.selected .radio-circle {
  border-color: var(--primary-medium);
}

.branch-card.selected .radio-circle::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--primary-medium);
}

/* Calendar & Timeslots */
.calendar-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 16px;
  scrollbar-width: thin;
}

.calendar-day-btn {
  flex: 0 0 calc(25% - 6px);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.calendar-day-btn:hover {
  border-color: var(--primary-medium);
}

.calendar-day-btn.selected {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}

.time-slots-container h4 {
  font-size: 0.9rem;
  margin: 16px 0 8px;
  color: var(--text-muted);
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.slot-btn {
  background-color: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.slot-btn:hover {
  border-color: var(--primary-medium);
}

.slot-btn.selected {
  background-color: var(--primary-medium);
  border-color: var(--primary-medium);
  color: white;
}

/* Summary Box */
.summary-box {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.summary-row:last-child {
  margin-bottom: 0;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.preparation-alert {
  background-color: var(--color-warning-bg);
  border-left: 4px solid var(--color-warning);
  color: #92400e;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

/* Patient Portal Styles */
.patient-profile-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--primary);
  color: white;
  padding: 20px 24px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.patient-info h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.patient-info p {
  opacity: 0.8;
  font-size: 0.85rem;
}

.result-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.exam-status-tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-listo {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.tag-proceso {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* Spinner / Loader */
.loader-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--primary-medium);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}


/* Animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

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

/* Grid & Utilities */
.text-center { text-align: center; }
.mb-3 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 8px; }
.hidden { display: none !important; }

/* Dávila Redesign Custom Styles */
.search-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-medium));
  color: white;
  padding: 30px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.search-toggle-container {
  display: flex;
  background: var(--bg-app);
  border-radius: 30px;
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.search-toggle-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 25px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

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

.doctor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: var(--transition);
}

.doctor-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-medium);
}

.doctor-info-row {
  display: flex;
  gap: 16px;
  align-items: center;
}

.doctor-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--primary);
  border: 2px solid var(--border);
}

.carousel-container {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: thin;
}

.carousel-day-col {
  min-width: 90px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.carousel-day-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: center;
  padding-bottom: 4px;
}

.slot-time-btn {
  width: 90%;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.slot-time-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.badge-prevision {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* Captcha Widget styling */
.captcha-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.captcha-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.captcha-checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.captcha-checkbox.verified {
  border-color: var(--color-success);
  background-color: var(--color-success);
  color: white;
}

.captcha-text {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
  user-select: none;
}

.captcha-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 700;
}

.captcha-logo i {
  font-size: 1.1rem;
  color: var(--primary-medium);
  margin-bottom: 2px;
}

/* 3-Column Specialists Profiles Grid Layout on Desktop */
#specialist-profiles-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 992px) {
  #specialist-profiles-container {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  
  /* Make sure profile card contents stack nicely when narrow in grid column */
  .specialist-profile-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
}
