/* ============================================================================
 * Componentes de UI del sistema de diseño — SIEMPRE cargado (no es lazy).
 * Define la FORMA de cada componente (botones, modal, tabla, badges...)
 * usando exclusivamente variables --*  (colores, radios, sombras, tipografía).
 * El archivo de tema activo (ver ThemeService) sólo define el VALOR de esas
 * variables — nunca duplica estas reglas. Cambiar de tema no vuelve a
 * descargar esto, sólo re-resuelve los var() ya pintados.
 *
 * Alcance: interfaces de Usuario (gestión) y Paciente únicamente. No se
 * importa en la landing ni en el sitio administrador (proyectos aparte).
 * ========================================================================= */

.themed {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
}

.themed h1, .themed h2, .themed h3, .themed h4, .themed h5, .themed h6 {
  font-family: var(--font-heading);
}

/* ---------- superficies ---------- */
.panel, .surface {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.surface-alt { background: var(--bg-surface-alt); }

/* ---------- botones ---------- */
.btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  text-transform: var(--ui-text-transform, none);
  letter-spacing: var(--ui-tracking, normal);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled, .btn-disabled {
  background: var(--bg-surface-alt); color: var(--text-muted);
  cursor: not-allowed; border-color: var(--border); transform: none;
}
.btn-primary { background: var(--accent); color: #ffffff; border-color: var(--btn-primary-border, transparent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--accent2); color: #ffffff; border-color: var(--btn-primary-border, transparent); }
.btn-secondary:hover:not(:disabled) { background: var(--accent2-hover); }
.btn-outline { background: transparent; color: var(--text-primary); border-color: var(--border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--bg-surface-alt); }
.btn-ghost { background: transparent; color: var(--accent2); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--accent2-light); color: var(--accent2-hover); }
.btn-danger { background: var(--danger); color: #ffffff; border-color: var(--btn-primary-border, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--danger-text); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 13px 26px; font-size: 14px; }
.btn-icon {
  width: 38px; height: 38px; padding: 0; justify-content: center;
  border-radius: var(--radius-md); background: var(--bg-surface-alt); color: var(--text-primary);
  border: 1px solid var(--btn-icon-border, transparent);
}
.btn-icon:hover:not(:disabled) { background: var(--accent-light); color: var(--accent-text); }

/* ---------- formularios ---------- */
.field { margin-bottom: 20px; }
.field label, .field-label {
  display: block; font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  text-transform: var(--ui-text-transform, none); letter-spacing: var(--ui-tracking, normal);
  color: var(--text-primary); margin-bottom: 6px;
}
.field .help { font-family: var(--font-ui); font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.field .error-text { font-family: var(--font-ui); font-size: 12px; color: var(--danger-text); margin-top: 6px; }
.input, textarea.input, select.input,
.themed input[type="text"], .themed input[type="email"], .themed input[type="password"],
.themed input[type="number"], .themed input[type="date"], .themed input[type="tel"],
.themed input[type="search"], .themed textarea, .themed select {
  width: 100%; font-family: var(--font-body); font-size: 14px; color: var(--text-primary);
  background: var(--field-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:hover { border-color: var(--border-strong); }
.input:focus, .themed input:focus, .themed textarea:focus, .themed select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.input.error { border-color: var(--danger); }
.input.error:focus { box-shadow: 0 0 0 3px var(--danger-light); }

.check-row, .radio-row { display: flex; align-items: center; gap: 10px; font-family: var(--font-ui); font-size: 13px; }
.check-row input, .radio-row input { accent-color: var(--accent); }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--switch-off-bg, var(--border-strong));
  border: var(--switch-border, none); border-radius: var(--radius-pill); transition: 0.15s ease; cursor: pointer;
}
.switch .track::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 2px;
  background: var(--switch-thumb, #ffffff); border-radius: var(--switch-thumb-radius, 50%); transition: 0.15s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(18px); }

.file-drop {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md);
  padding: 28px; text-align: center; color: var(--text-secondary); font-family: var(--font-ui); font-size: 13px;
  background: var(--bg-surface-alt);
}

/* ---------- listas ---------- */
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain > li {
  padding: 12px 0; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-primary);
}
.list-plain > li:first-child { border-top: none; }
.list-check > li { display: flex; gap: 10px; align-items: flex-start; }
.list-check svg { flex-shrink: 0; margin-top: 2px; color: var(--accent); }

.nav-list { list-style: none; margin: 0; padding: 0; font-family: var(--font-ui); }
.nav-list li a, .nav-list li button, .nav-list > a, .nav-list > button {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 4px;
  width: 100%; text-align: left; border: none; background: none; cursor: pointer;
  border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; font-size: 13px;
  font-family: var(--font-ui);
  text-transform: var(--ui-text-transform, none); letter-spacing: var(--ui-tracking, normal);
}
.nav-list li a:hover, .nav-list li button:hover, .nav-list > a:hover, .nav-list > button:hover {
  background: var(--bg-surface-alt); color: var(--text-primary);
}
.nav-list li a.active, .nav-list li button.active, .nav-list > a.active, .nav-list > button.active {
  background: var(--accent-light); color: var(--accent-text); font-weight: 600;
}

.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-list li {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border);
}
.contact-list li:first-child { border-top: none; }
.avatar {
  width: 38px; height: 38px; border-radius: var(--avatar-radius, 50%); background: var(--accent-light);
  color: var(--accent-text); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-size: 13px; font-weight: 700; flex-shrink: 0;
  border: var(--avatar-border, none);
}
.contact-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.contact-sub { font-family: var(--font-ui); font-size: 11px; color: var(--text-muted); }

/* ---------- tabla ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; font-family: var(--font-ui); font-size: 11px; font-weight: 700; color: var(--text-secondary);
  text-transform: var(--ui-text-transform, uppercase); letter-spacing: var(--ui-tracking, 0.04em);
  padding: 10px 14px; border-bottom: 1px solid var(--border-strong);
}
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); color: var(--text-primary); }
.data-table tbody tr:hover { background: var(--bg-surface-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  text-transform: var(--ui-text-transform, none); letter-spacing: var(--ui-tracking, normal);
  padding: 4px 11px; border-radius: var(--radius-pill); border: var(--badge-border, none);
}
.badge-success { background: var(--success-light); color: var(--success-text); border-color: var(--success-text); }
.badge-warning { background: var(--warning-light); color: var(--warning-text); border-color: var(--warning-text); }
.badge-danger { background: var(--danger-light); color: var(--danger-text); border-color: var(--danger-text); }
.badge-info { background: var(--info-light); color: var(--info-text); border-color: var(--info-text); }
.badge-neutral { background: var(--bg-surface-alt); color: var(--text-secondary); border-color: var(--text-secondary); }

/* ---------- alertas ---------- */
.alert {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-md);
  border-left: 3px solid transparent; font-size: 14px; margin-bottom: 12px; background: var(--bg-surface-alt);
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert strong { display: block; font-family: var(--font-ui); font-size: 13px; margin-bottom: 2px; }
.alert p { margin: 0; font-size: 13px; font-family: var(--font-ui); opacity: 0.9; }
.alert-success { border-color: var(--success); } .alert-success strong { color: var(--success-text); }
.alert-warning { border-color: var(--warning); } .alert-warning strong { color: var(--warning-text); }
.alert-danger  { border-color: var(--danger);  } .alert-danger  strong { color: var(--danger-text);  }
.alert-info    { border-color: var(--info);    } .alert-info    strong { color: var(--info-text);    }

/* ---------- tarjetas ---------- */
.card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow-sm);
}
.card h4 { margin: 0 0 6px; font-family: var(--font-heading); font-weight: 600; font-size: 16px; }
.card p { margin: 0; font-size: 13px; color: var(--text-secondary); font-family: var(--font-ui); }
.stat-card { background: var(--bg-surface-alt); border-radius: var(--radius-md); padding: 16px; }
.stat-card .label { font-family: var(--font-ui); font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.stat-card .value { font-family: var(--font-heading); font-size: 26px; font-weight: 700; color: var(--text-primary); }

/* ---------- tabs ---------- */
.tabs-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab-btn {
  background: none; border: none; padding: 10px 16px; font-family: var(--font-ui); font-size: 13px;
  text-transform: var(--ui-text-transform, none); letter-spacing: var(--ui-tracking, normal);
  color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 700; }

/* ---------- navegación / paginación / progreso ---------- */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-family: var(--font-ui); font-size: 12px; color: var(--text-muted); }
.breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-text); }
.breadcrumb .current { color: var(--text-primary); font-weight: 700; }

.pagination { display: flex; align-items: center; gap: 6px; }
.page-btn {
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-secondary); font-family: var(--font-ui); font-size: 12px; cursor: pointer;
}
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:hover:not(.active) { border-color: var(--border-strong); }

.progress { height: 8px; border-radius: var(--radius-pill); background: var(--bg-surface-alt); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: var(--radius-pill); }

/* ---------- tooltip ---------- */
.tooltip-wrap { position: relative; display: inline-block; }
.tooltip-wrap .tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--tooltip-bg); color: var(--tooltip-text); font-family: var(--font-ui); font-size: 11px; padding: 6px 10px;
  border-radius: var(--radius-sm); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
.tooltip-wrap:hover .tip { opacity: 1; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: 50;
}
.modal-box {
  background: var(--bg-surface); border-radius: var(--radius-lg); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.modal-box h3, .modal-box h4 {
  font-family: var(--font-heading); font-weight: 600; margin: 0 0 10px; color: var(--text-primary);
}
.modal-box p { font-size: 14px; color: var(--text-secondary); font-family: var(--font-ui); margin: 0 0 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.divider { height: 1px; background: var(--border); border: none; margin: 24px 0; }
