/* ═══════════════════════════════════════
   PACIENTES — CSS
   ═══════════════════════════════════════ */

/* ── Toolbar ── */
.pac-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}
.pac-search-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--neutral-900);
  border: var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 var(--sp-3);
  height: 38px;
  flex: 1;
  max-width: 380px;
  transition: border-color var(--t-fast);
}
.pac-search-wrap:focus-within { border-color: var(--brand-accent); }
.pac-search-wrap svg { color: var(--neutral-500); flex-shrink: 0; }
.pac-search-input {
  background: none; border: none; outline: none;
  color: var(--neutral-100); font-family: var(--font-body);
  font-size: var(--text-sm); width: 100%;
}
.pac-search-input::placeholder { color: var(--neutral-600); }

/* ── Sin tenant banner ── */
.pac-no-tenant {
  background: var(--neutral-900);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-8);
  text-align: center;
}
.pac-no-tenant h3 { font-size: var(--text-md); color: var(--neutral-200); margin-bottom: var(--sp-2); }
.pac-no-tenant p  { font-size: var(--text-sm); color: var(--neutral-500); margin-bottom: var(--sp-4); }
.pac-no-tenant code {
  display: inline-block;
  background: var(--neutral-800);
  color: var(--brand-accent);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  margin-top: var(--sp-2);
}

/* ── Table ── */
.pac-table-wrap {
  background: var(--neutral-900);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.pac-table { width: 100%; border-collapse: collapse; }
.pac-th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  background: var(--neutral-850);
  color: var(--neutral-500);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  border-bottom: var(--border-subtle);
  white-space: nowrap;
}
.pac-th.sortable { cursor: pointer; user-select: none; }
.pac-th.sortable:hover { color: var(--neutral-300); }
.pac-tr { transition: background var(--t-fast); cursor: pointer; }
.pac-tr:hover { background: var(--neutral-850); }
.pac-td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: var(--border-subtle);
  vertical-align: middle;
  color: var(--neutral-200);
  font-size: var(--text-sm);
}
.pac-tr:last-child .pac-td { border-bottom: none; }

.pac-avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-full);
  background: var(--neutral-800);
  border: var(--border-subtle);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: 700;
  color: var(--brand-accent); flex-shrink: 0; overflow: hidden;
}
.pac-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pac-name-cell { display: flex; align-items: center; gap: var(--sp-3); }
.pac-name { font-weight: 500; color: var(--neutral-100); }
.pac-dni  { font-size: var(--text-xs); color: var(--neutral-500); margin-top: 1px; }
.pac-os   { font-size: var(--text-xs); color: var(--neutral-400); }

/* ── Pagination ── */
.pac-pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-5);
  border-top: var(--border-subtle);
  background: var(--neutral-850);
}
.pac-pagination-info { font-size: var(--text-xs); color: var(--neutral-500); }
.pac-pagination-btns { display: flex; gap: var(--sp-1); }
.pac-page-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-md);
  border: var(--border-subtle);
  background: transparent;
  color: var(--neutral-400);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--t-fast);
  display: flex; align-items: center; justify-content: center;
}
.pac-page-btn:hover:not(:disabled) { background: var(--neutral-800); color: var(--neutral-200); }
.pac-page-btn.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.pac-page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ═══════════════════════════════════════
   DRAWER LATERAL — Ficha del paciente
   ═══════════════════════════════════════ */

.pac-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 100;
  animation: fadeIn .15s ease both;
  /* NO backdrop-filter para no cortar el drawer */
}
.pac-drawer {
  position: fixed;
  top: 0; bottom: 0; right: 0;
  /* Ancho máximo para que las tabs queden visibles sin scroll horizontal */
  width: min(900px, calc(100vw - var(--sidebar-w, 220px) - 16px));
  background: var(--neutral-900);
  border-left: var(--border-default);
  display: flex;
  flex-direction: column;
  z-index: 101;
  animation: slideInRight .22s ease both;
  box-shadow: -12px 0 60px rgba(0,0,0,.6);
}
@keyframes slideInRight {
  from { transform: translateX(48px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* Header — altura fija, no crece */
.drawer-header {
  padding: var(--sp-4) var(--sp-6);
  border-bottom: var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  background: var(--neutral-850);
  min-height: 60px;
}
.drawer-title { font-family: var(--font-display); font-size: var(--text-md); color: var(--neutral-50); }
.drawer-close {
  background: none; border: none; cursor: pointer;
  color: var(--neutral-500); font-size: 20px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: all var(--t-fast); line-height: 1;
}
.drawer-close:hover { background: var(--neutral-800); color: var(--neutral-200); }

/* Tabs — altura fija */
.drawer-tabs {
  display: flex;
  border-bottom: var(--border-subtle);
  background: var(--neutral-850);
  flex-shrink: 0;
  overflow-x: auto;
}
.drawer-tab {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: .04em;
  color: var(--neutral-500); cursor: pointer;
  border: none; background: none; font-family: var(--font-body);
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast); white-space: nowrap;
}
.drawer-tab:hover { color: var(--neutral-200); }
.drawer-tab.active { color: var(--brand-accent); border-bottom-color: var(--brand-accent); }

/* Body — ocupa TODO el espacio restante, scrollea internamente */
.drawer-body {
  flex: 1;
  min-height: 0;        /* ← clave: sin esto el flex item no scrollea */
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-6);
}

/* Footer — altura fija, no crece */
.drawer-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: var(--border-subtle);
  display: flex; align-items: center; justify-content: flex-end;
  gap: var(--sp-3);
  flex-shrink: 0;
  background: var(--neutral-850);
  min-height: 64px;
}

/* ── Inline validation messages ── */
.drawer-form-error {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: rgba(244,63,94,.08);
  border: 1px solid rgba(244,63,94,.25);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: var(--text-sm);
  font-weight: 500;
  animation: fadeIn .15s ease both;
}
.drawer-form-success {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.25);
  border-radius: var(--radius-md);
  color: var(--success);
  font-size: var(--text-sm);
  font-weight: 500;
  animation: fadeIn .15s ease both;
}
/* campo con error */
.field-input.field-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(244,63,94,.1); }

/* ── Ficha: hero card ── */
.pac-hero {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--neutral-850); border: var(--border-subtle);
  border-radius: var(--radius-lg); margin-bottom: var(--sp-5);
}
.pac-hero-avatar {
  width: 68px; height: 68px;
  border-radius: var(--radius-full);
  background: var(--neutral-800); border: 2px solid var(--neutral-700);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
  color: var(--brand-accent); flex-shrink: 0; overflow: hidden;
  cursor: pointer; position: relative;
}
.pac-hero-avatar:hover::after {
  content: '📷';
  position: absolute; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; border-radius: var(--radius-full);
}
.pac-hero-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pac-hero-info { flex: 1; min-width: 0; }
.pac-hero-name { font-family: var(--font-display); font-size: var(--text-lg); color: var(--neutral-50); margin-bottom: var(--sp-1); }
.pac-hero-meta { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.pac-hero-tag  { font-size: var(--text-xs); color: var(--neutral-400); display: flex; align-items: center; gap: 4px; }
.pac-hero-qr   { width: 52px; height: 52px; background: white; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; }

/* ── Form sections ── */
.form-section { margin-bottom: var(--sp-6); }
.form-section-title {
  font-size: var(--text-xs); font-weight: 700; color: var(--neutral-500);
  text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: var(--sp-4); padding-bottom: var(--sp-2);
  border-bottom: var(--border-subtle);
  display: flex; align-items: center; gap: var(--sp-2);
}
.form-section-title span { color: var(--brand-accent); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-4); }

/* ── Tag inputs (alergias, condiciones) ── */
.tag-input-wrap {
  display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center;
  background: var(--neutral-850); border: var(--border-default);
  border-radius: var(--radius-md); padding: var(--sp-2) var(--sp-3);
  min-height: 38px; cursor: text;
  transition: border-color var(--t-fast);
}
.tag-input-wrap:focus-within { border-color: var(--brand-accent); box-shadow: 0 0 0 3px rgba(45,212,191,.1); }
.tag-item {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--neutral-750); border: var(--border-subtle);
  border-radius: var(--radius-full); padding: 2px 10px;
  font-size: var(--text-xs); color: var(--neutral-200);
}
.tag-item.danger { background: rgba(244,63,94,.1); border-color: rgba(244,63,94,.3); color: var(--danger); }
.tag-remove { background: none; border: none; cursor: pointer; color: inherit; opacity: .5; font-size: 11px; padding: 0 0 0 2px; line-height: 1; }
.tag-remove:hover { opacity: 1; }
.tag-input {
  background: none; border: none; outline: none;
  color: var(--neutral-100); font-family: var(--font-body);
  font-size: var(--text-xs); min-width: 100px; flex: 1;
}

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: var(--sp-4); padding: var(--sp-3) 0; border-bottom: var(--border-subtle); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot-col { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 16px; margin-top: 4px; }
.timeline-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.timeline-line { flex: 1; width: 1px; background: var(--neutral-800); margin-top: 4px; min-height: 16px; }
.timeline-content { flex: 1; min-width: 0; }
.timeline-date  { font-size: var(--text-xs); color: var(--neutral-500); margin-bottom: 2px; }
.timeline-title { font-size: var(--text-sm); font-weight: 500; color: var(--neutral-100); margin-bottom: 2px; }
.timeline-sub   { font-size: var(--text-xs); color: var(--neutral-400); }
.timeline-amount { font-size: var(--text-sm); font-weight: 600; color: var(--success); white-space: nowrap; padding-left: var(--sp-3); }

/* ── Consentimientos ── */
.consent-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  background: var(--neutral-850); border: var(--border-subtle);
  border-radius: var(--radius-md); margin-bottom: var(--sp-2);
}
.consent-info { flex: 1; }
.consent-name { font-size: var(--text-sm); font-weight: 500; color: var(--neutral-100); }
.consent-date { font-size: var(--text-xs); color: var(--neutral-500); margin-top: 1px; }
.consent-status { display: flex; align-items: center; gap: var(--sp-2); }

/* ── Alert strips (alergias en hero) ── */
.pac-alert-strip {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-md);
  font-size: var(--text-xs); font-weight: 500; margin-bottom: var(--sp-2);
}
.pac-alert-strip.danger  { background: rgba(244,63,94,.08);  color: var(--danger);  border: 1px solid rgba(244,63,94,.2); }
.pac-alert-strip.warning { background: rgba(245,158,11,.08); color: var(--warning); border: 1px solid rgba(245,158,11,.2); }

/* ── Empty rows ── */
.pac-empty-rows td {
  padding: var(--sp-10); text-align: center;
  color: var(--neutral-600); font-size: var(--text-sm);
}
