/* =======================================================
   Adelanto Clínica — Front Desk Stylesheet
   Modern, responsive, accessible, professional
   ======================================================= */

:root {
  --primary: #0f4c81;
  --primary-hover: #0a355c;
  --primary-light: #e6f0fa;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--neutral-50);
  color: var(--neutral-800);
  line-height: 1.5;
  min-height: 100vh;
}

/* Utilities */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* Views */
.view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =======================================================
   LOGIN SCREEN
   ======================================================= */
#login-view {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f2b48 0%, #1e3a8a 100%);
  padding: 1.5rem;
}

.login-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  padding: 2.5rem 2rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-logo-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.login-brand h1 {
  font-size: 1.6rem;
  color: var(--neutral-900);
  font-weight: 700;
}

.login-brand .subtitle {
  color: var(--neutral-500);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.login-footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--neutral-500);
  font-size: 0.8rem;
  border-top: 1px solid var(--neutral-200);
  padding-top: 1rem;
}

/* =======================================================
   HEADER & NAVIGATION
   ======================================================= */
.app-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--neutral-200);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  font-size: 1.8rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--neutral-900);
  display: block;
  line-height: 1.2;
}

.brand-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.header-nav {
  display: flex;
  gap: 0.5rem;
}

.nav-tab {
  background: none;
  border: none;
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--neutral-600);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  background-color: var(--neutral-100);
  color: var(--neutral-900);
}

.nav-tab.active {
  background-color: var(--primary);
  color: #ffffff;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info {
  text-align: right;
}

.user-name {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--neutral-800);
}

.user-role {
  display: block;
  font-size: 0.75rem;
  color: var(--neutral-500);
}

/* =======================================================
   MAIN CONTENT & TOOLBAR
   ======================================================= */
.app-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
  flex: 1;
}

.toolbar {
  background-color: #ffffff;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.toolbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.date-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.date-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--neutral-800);
}

.provider-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.search-box {
  flex: 1;
  max-width: 600px;
}

.search-input {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
}

.search-input:focus,
.date-input:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.15);
}

/* =======================================================
   AGENDA SUMMARY & LIST
   ======================================================= */
.agenda-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0 0.25rem;
}

.agenda-summary h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--neutral-900);
}

.agenda-stats {
  font-size: 0.9rem;
  color: var(--neutral-500);
  font-weight: 500;
}

.agenda-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.appointment-card {
  background: #ffffff;
  border: 1px solid var(--neutral-200);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.1s ease;
}

.appointment-card:hover {
  box-shadow: var(--shadow-md);
}

.appointment-card.status-cancelled {
  border-left-color: var(--neutral-400);
  opacity: 0.65;
  background-color: var(--neutral-50);
}

.appointment-card.status-arrived {
  border-left-color: #8b5cf6;
}

.appointment-card.status-confirmed {
  border-left-color: var(--success);
}

.appt-time-col {
  min-width: 100px;
}

.appt-time {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--neutral-900);
}

.appt-duration {
  font-size: 0.8rem;
  color: var(--neutral-500);
}

.appt-details-col {
  flex: 1;
}

.appt-patient-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--neutral-900);
}

.appt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--neutral-600);
  margin-top: 0.25rem;
}

.appt-notes {
  font-size: 0.85rem;
  color: var(--neutral-500);
  font-style: italic;
  margin-top: 0.35rem;
}

.appt-actions-col {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  line-height: 1.2;
}

.badge-scheduled { background: #e0f2fe; color: #0369a1; }
.badge-arrived { background: #f3e8ff; color: #7e22ce; }
.badge-confirmed { background: #dcfce7; color: #15803d; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }
.badge-no-show { background: #fee2e2; color: #b91c1c; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  background: #ffffff;
  border: 1px dashed var(--neutral-300);
  border-radius: var(--radius-md);
  color: var(--neutral-500);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

/* =======================================================
   TABLES (PACIENTES)
   ======================================================= */
.table-responsive {
  background: #ffffff;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background-color: var(--neutral-50);
  color: var(--neutral-600);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--neutral-200);
}

.data-table td {
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--neutral-100);
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: #fafbfc;
}

.patient-id-badge {
  font-family: monospace;
  font-weight: 600;
  background: var(--neutral-100);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* =======================================================
   BUTTONS & FORMS
   ======================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

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

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

.btn-outline {
  background-color: #ffffff;
  border-color: var(--neutral-300);
  color: var(--neutral-700);
}

.btn-outline:hover {
  background-color: var(--neutral-100);
}

.btn-warning {
  background-color: var(--warning);
  color: #ffffff;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 0.5rem 0.65rem;
  background: #ffffff;
  border: 1px solid var(--neutral-300);
  color: var(--neutral-700);
}

.btn-block {
  width: 100%;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  padding: 0;
  font-size: 0.85rem;
  text-decoration: underline;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--neutral-700);
  margin-bottom: 0.35rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--neutral-900);
  background-color: #ffffff;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.flex-1 { flex: 1; min-width: 120px; }
.flex-2 { flex: 2; min-width: 180px; }
.flex-3 { flex: 3; min-width: 240px; }

/* Alerts */
.alert {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.alert-danger {
  background-color: var(--danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background-color: var(--success-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-warning {
  background-color: var(--warning-light);
  color: #92400e;
  border: 1px solid #fde68a;
}

/* =======================================================
   MODALS
   ======================================================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--neutral-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--neutral-900);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--neutral-400);
  cursor: pointer;
  line-height: 1;
}

.btn-close:hover {
  color: var(--neutral-800);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--neutral-200);
  background-color: var(--neutral-50);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.section-notice {
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.appointment-summary-box {
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.appointment-summary-box p {
  margin-bottom: 0.35rem;
}

/* Duplicate detection list */
.duplicate-list {
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.duplicate-item {
  background: #ffffff;
  border: 1px solid #fde68a;
  border-left: 4px solid var(--warning);
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.duplicate-reason {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 0.35rem;
}

.duplicate-choice-text {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: var(--neutral-800);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  background: #ffffff;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
  width: 100%;
  z-index: 1100;
}

.autocomplete-item {
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--neutral-100);
  font-size: 0.9rem;
}

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

.patient-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--primary-light);
  border: 1px solid #bfdbfe;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--primary);
}

/* Responsive */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .header-nav {
    width: 100%;
  }

  .nav-tab {
    flex: 1;
    justify-content: center;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .appointment-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .appt-actions-col {
    width: 100%;
    justify-content: flex-end;
    margin-top: 0.5rem;
    border-top: 1px solid var(--neutral-100);
    padding-top: 0.5rem;
  }
}
