/* Inter — bundled locally, 3 weights */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./fonts/inter-600.woff2') format('woff2');
}

/* MedicIA — tokens alineados a design/figma-exports/TOKENS.md */
:root {
  /* --- Clinic branding palette (overwritten at runtime by applyClinicTheme) --- */
  --color-primary:       #0F4C81;
  --color-primary-dark:  #0A3560;
  --color-primary-light: #E8F0F9;
  --color-secondary:     #00B4D8;

  /* --- Component tokens — alias the branding palette so all components follow --- */
  --mc-primary: var(--color-primary);
  --mc-primary-hover: var(--color-primary-dark);
  --mc-surface: #ffffff;
  --mc-bg: #F8FAFC;
  --mc-sidebar: #0A1628;
  --mc-sidebar-text: #94a3b8;
  --mc-sidebar-active: #ffffff;
  --mc-text: #0f172a;
  --mc-text-muted: #64748b;
  --mc-border: #e2e8f0;
  --mc-danger: #dc2626;
  --mc-danger-bg: #fef2f2;
  --mc-success: #16a34a;
  --mc-warning: #ca8a04;
  --mc-warning-bg: #fffbeb;
  --mc-radius: 8px;
  --mc-font: 'Inter', system-ui, "Segoe UI", sans-serif;
  --mc-sidebar-width: 240px;
  --mc-header-height: 56px;

  /* Responsive layout tokens */
  --mc-content-max: 1440px;     /* tope para tablas/dashboards */
  --mc-content-narrow: 800px;   /* tope para formularios/settings */
  --mc-space-content: 24px;

  /* Aliases used by some views — defined here so the cards/inputs that
     reference them get a real value instead of falling back to inherited.
     mc-surface-2 must contrast against mc-bg (#F8FAFC) — using slate-100. */
  --mc-surface-2: #f1f5f9;
  --color-text-secondary: #64748b;
  --color-background-secondary: #f1f5f9;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--mc-font);
  font-size: 14px;
  color: var(--mc-text);
  background: var(--mc-bg);
}

#app {
  min-height: 100%;
}

.mc-hidden {
  display: none !important;
}

.mc-patient-tab.mc-active {
  background: var(--mc-primary);
  color: #fff;
  border-color: var(--mc-primary);
}

/* Auth / wizard full-page */
.mc-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--color-primary-light, #e0e7ff) 0%, var(--mc-bg) 45%);
}

.mc-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--mc-surface);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--mc-border);
}

.mc-auth-card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.mc-auth-card .mc-sub {
  color: var(--mc-text-muted);
  margin-bottom: 24px;
  font-size: 0.9rem;
}

/* Shell */
.mc-shell {
  display: flex;
  min-height: 100vh;
}

.mc-sidebar {
  width: var(--mc-sidebar-width);
  background: var(--mc-sidebar);
  color: var(--mc-sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.mc-sidebar-brand {
  padding: 20px 16px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--mc-sidebar-active);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mc-nav {
  padding: 12px 8px;
  flex: 1;
}

.mc-nav a,
.mc-nav button.mc-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: none;
  border-left: 2px solid transparent;
  border-radius: var(--mc-radius);
  background: transparent;
  color: var(--mc-sidebar-text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all 150ms ease;
}

.mc-nav a:hover,
.mc-nav button.mc-nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--mc-sidebar-active);
}

.mc-nav a.mc-active,
.mc-nav button.mc-nav-item.mc-active {
  background: color-mix(in srgb, var(--color-primary) 20%, transparent);
  color: var(--mc-sidebar-active);
  border-left-color: var(--color-secondary);
}

@keyframes mc-view-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mc-view-enter {
  animation: mc-view-enter 180ms ease-out forwards;
}

.mc-sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.mc-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mc-header {
  height: var(--mc-header-height);
  background: var(--mc-surface);
  border-bottom: 1px solid var(--mc-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  -webkit-app-region: drag;
}

.mc-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.mc-header button,
.mc-header a,
.mc-header input,
.mc-header select {
  -webkit-app-region: no-drag;
}

.mc-content {
  flex: 1;
  padding: var(--mc-space-content);
  overflow: auto;
}

/* View wrappers — every view should be wrapped in one of these.
   Centers content on wide screens and constrains form widths sanely. */
.mc-view {
  width: 100%;
  max-width: var(--mc-content-max);
  margin: 0 auto;
}
.mc-view--narrow { max-width: var(--mc-content-narrow); }
.mc-view--wide   { max-width: var(--mc-content-max); }
.mc-view--full   { max-width: none; }

/* Hamburger button — hidden on desktop, shown on mobile via media query */
.mc-hamburger {
  display: none;
  background: transparent;
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--mc-text);
  -webkit-app-region: no-drag;
  padding: 0;
}

.mc-hamburger:hover { background: var(--mc-bg); }

/* Backdrop for the sidebar drawer on mobile */
.mc-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 90;
}

.mc-banner {
  padding: 10px 16px;
  border-radius: var(--mc-radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.mc-banner--warn {
  background: var(--mc-warning-bg);
  color: #854d0e;
  border: 1px solid #fde68a;
}

.mc-banner--error {
  background: var(--mc-danger-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Forms */
.mc-field {
  margin-bottom: 16px;
}

.mc-field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 13px;
}

.mc-input,
.mc-select,
.mc-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  font: inherit;
}

.mc-textarea {
  min-height: 100px;
  resize: vertical;
}

.mc-input:focus,
.mc-select:focus,
.mc-textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--color-primary) 35%, transparent);
  border-color: var(--mc-primary);
}

.mc-error-text {
  color: var(--mc-danger);
  font-size: 12px;
  margin-top: 6px;
}

.mc-field-hint {
  display: block;
  font-size: 12px;
  color: var(--mc-text-muted);
  margin-top: 4px;
}

/* Buttons */
.mc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--mc-radius);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
}

.mc-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mc-btn--primary {
  background: var(--mc-primary);
  color: #fff;
}

.mc-btn--primary:hover:not(:disabled) {
  background: var(--mc-primary-hover);
}

.mc-btn--secondary {
  background: var(--mc-surface);
  color: var(--mc-text);
  border-color: var(--mc-border);
}

.mc-btn--danger {
  background: var(--mc-danger);
  color: #fff;
  border-color: var(--mc-danger);
}

.mc-btn--danger:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
}

.mc-btn--ghost {
  background: transparent;
  color: var(--mc-primary);
}

/* View toggle — Día / Semana */
.mc-view-toggle { }

.mc-view-toggle .mc-btn.active,
.mc-view-toggle .mc-btn--active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.mc-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* Table */
.mc-table-wrap {
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  overflow: auto;
}

.mc-table {
  width: 100%;
  border-collapse: collapse;
}

.mc-table th,
.mc-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--mc-border);
}

.mc-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mc-primary);
  background: var(--color-primary-light);
}

.mc-table tbody tr {
  transition: background 120ms ease;
  cursor: pointer;
}

.mc-table tr:hover td {
  background: color-mix(in srgb, var(--color-primary) 4%, transparent);
}

/* Cards / KPI */
.mc-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.mc-kpi {
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  padding: 16px;
}

.mc-kpi .mc-kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.mc-kpi .mc-kpi-label {
  font-size: 12px;
  color: var(--mc-text-muted);
}

/* Badges */
.mc-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.mc-badge--reserved {
  background: #dbeafe;
  color: #1e40af;
}
.mc-badge--confirmed {
  background: #dcfce7;
  color: #166534;
}
.mc-badge--cancelled {
  background: #fee2e2;
  color: #991b1b;
}
.mc-badge--rescheduled {
  background: #fef3c7;
  color: #92400e;
}
.mc-badge--no_show {
  background: #f3f4f6;
  color: #4b5563;
}
.mc-badge--attended {
  background: #cffafe;
  color: #0e7490;
}

/* Modal */
.mc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.mc-modal {
  background: var(--mc-surface);
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.mc-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--mc-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mc-modal-body {
  padding: 20px;
}

.mc-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--mc-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast */
.mc-toast-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mc-toast {
  padding: 12px 16px;
  background: var(--mc-text);
  color: #fff;
  border-radius: var(--mc-radius);
  font-size: 13px;
  max-width: 360px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.mc-toast--error {
  background: var(--mc-danger);
}

.mc-toast--success {
  background: var(--mc-success);
}

.mc-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--mc-border);
  border-top-color: var(--mc-primary);
  border-radius: 50%;
  animation: mc-spin 0.7s linear infinite;
}

@keyframes mc-spin {
  to {
    transform: rotate(360deg);
  }
}

.mc-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--mc-text-muted);
}

/* Settings sections */
.mc-settings-section {
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}

.mc-settings-section-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--mc-border);
}

.mc-settings-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--mc-text);
  margin: 0 0 2px;
}

.mc-settings-section-desc {
  font-size: 12px;
  color: var(--mc-text-muted);
  margin: 0;
}

.mc-settings-section-body {
  padding: 20px 24px;
}

/* Dropzone */
.mc-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1.5px dashed var(--mc-border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color 150ms, background 150ms;
  font-size: 13px;
  color: var(--mc-text-muted);
}

.mc-dropzone:hover {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 3%, transparent);
}

.mc-dropzone-hint {
  font-size: 11px;
  color: var(--mc-text-muted);
}

/* KPI stat cards */
.mc-stat-card {
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: 12px;
  padding: 20px;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.mc-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.mc-stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.mc-stat-icon--blue   { background: #E8F0F9; color: #0F4C81; }
.mc-stat-icon--green  { background: #F0FDF4; color: #22C55E; }
.mc-stat-icon--purple { background: #F5F3FF; color: #8B5CF6; }
.mc-stat-icon--orange { background: #FFF7ED; color: #F97316; }

.mc-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--mc-text);
  line-height: 1;
  margin-bottom: 4px;
}

.mc-stat-label {
  font-size: 12px;
  color: var(--mc-text-muted);
}

@keyframes mc-card-enter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mc-stat-card                { animation: mc-card-enter 300ms ease-out both; }
.mc-stat-card:nth-child(1)   { animation-delay:   0ms; }
.mc-stat-card:nth-child(2)   { animation-delay:  60ms; }
.mc-stat-card:nth-child(3)   { animation-delay: 120ms; }
.mc-stat-card:nth-child(4)   { animation-delay: 180ms; }

/* Empty states */
.mc-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  gap: 8px;
  text-align: center;
}

.mc-empty-icon { color: #CBD5E1; margin-bottom: 4px; }
.mc-empty-title { font-size: 14px; font-weight: 600; color: var(--mc-text); }
.mc-empty-desc { font-size: 13px; color: var(--mc-text-muted); max-width: 280px; line-height: 1.5; }
.mc-empty-cta { margin-top: 12px; }

/* Underline tabs */
.mc-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--mc-text-muted);
  cursor: pointer;
  transition: color 150ms, border-color 150ms;
}

.mc-tab.active,
.mc-tab[aria-selected="true"] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 500;
  background: none;
}

.mc-tab:hover { color: var(--color-primary); }

/* Toggle switch */
.mc-toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }

.mc-toggle-track {
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: #cbd5e1;
  display: inline-block;
  position: relative;
  transition: background 200ms ease;
  flex-shrink: 0;
}

.mc-toggle-track::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 200ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.mc-toggle-input:checked + .mc-toggle-track { background: var(--color-primary); }
.mc-toggle-input:checked + .mc-toggle-track::after { transform: translateX(16px); }

/* Inline new-patient panel inside appointment modal */
.mc-inline-new-patient {
  border: 1.5px dashed var(--mc-border, #e2e8f0);
  border-radius: 10px;
  padding: 12px;
  margin-top: 6px;
  background: var(--color-background-secondary);
}

.mc-inline-new-patient-header {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 10px;
}

.mc-inline-new-patient-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Conversations layout */
.mc-conv-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 500px;
  overflow: hidden;
}
.mc-conv-tabs {
  padding: 0 16px;
  border-bottom: 1px solid var(--mc-border);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.mc-conv-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.mc-conv-list {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--mc-border);
}
.mc-conv-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ============================================================
   Responsive breakpoints
   ============================================================ */

/* Tablet — sidebar más angosto, padding reducido, KPIs en 2 col */
@media (max-width: 1024px) {
  :root {
    --mc-sidebar-width: 200px;
    --mc-space-content: 16px;
  }
  .mc-kpi-row {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

/* Mobile — sidebar como drawer overlay */
@media (max-width: 768px) {
  :root {
    --mc-space-content: 14px;
  }

  .mc-shell {
    /* Sidebar overlays the main area on mobile */
    position: relative;
  }

  .mc-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 220ms ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }

  .mc-shell[data-sidebar-open="true"] .mc-sidebar {
    transform: translateX(0);
  }

  .mc-shell[data-sidebar-open="true"] .mc-sidebar-backdrop {
    display: block;
  }

  .mc-main {
    width: 100%;
  }

  .mc-hamburger {
    display: inline-flex;
    margin-right: 12px;
  }

  .mc-header {
    padding: 0 12px;
  }
  .mc-header h2 {
    font-size: 1rem;
  }

  /* Tablas con scroll horizontal */
  .mc-table-wrap {
    overflow-x: auto;
  }

  /* KPIs en 1 columna */
  .mc-kpi-row {
    grid-template-columns: 1fr;
  }

  /* Stat cards en 1 columna también */
  .mc-stat-card {
    width: 100%;
  }

  /* Modal full-screen-ish */
  .mc-modal-backdrop {
    padding: 8px;
  }
  .mc-modal {
    max-height: 95vh;
  }

  /* Conversations: stack list + detail vertically */
  .mc-conv-body {
    flex-direction: column;
  }
  .mc-conv-list {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--mc-border);
  }
}

/* Móvil chico — tipografía y padding mínimo */
@media (max-width: 480px) {
  html, body {
    font-size: 13px;
  }
  :root {
    --mc-space-content: 12px;
  }
  .mc-btn {
    padding: 8px 12px;
  }
  .mc-table th,
  .mc-table td {
    padding: 8px 10px;
  }
}
