/* ===================================
   CONFIG TRATAMIENTO — FULLSCREEN
   =================================== */

/* Buscador de insumo custom */
.ct-insumo-item:hover,
.ct-insumo-item.activo { background: #eff6ff; }
.ct-insumo-item:last-child { border-bottom: none !important; }

:root {
  --ct-primary: #1a6fc4;
  --ct-success: #198754;
  --ct-danger: #dc3545;
  --ct-warning: #f0ad4e;
  --ct-muted: #6c757d;
  --ct-bg: #f4f6f9;
  --ct-card-bg: #ffffff;
  --ct-header: #1c2a3a;
  --ct-border: #dee2e6;
}

/* SweetAlert2 debe quedar sobre el panel fullscreen */
.swal2-container { z-index: 10001 !important; }

/* ── Panel principal ─────────────────────────────────────────────────────── */
#config-tratamiento {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  background: var(--ct-bg);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

#config-tratamiento.ct-activo {
  transform: translateY(0);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.ct-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--ct-header);
  color: #fff;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.ct-header-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.ct-header-paciente {
  font-size: 13px;
  opacity: 0.85;
  white-space: nowrap;
}

.ct-header-peso {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ct-spacer {
  flex: 1;
}

.ct-btn-cerrar {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.ct-btn-cerrar:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Cuerpo scrollable ───────────────────────────────────────────────────── */
.ct-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Tarjeta genérica ────────────────────────────────────────────────────── */
.ct-card {
  background: var(--ct-card-bg);
  border: 1px solid var(--ct-border);
  border-radius: 8px;
  padding: 16px;
}

.ct-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ct-muted);
  margin-bottom: 12px;
}

/* ── Ficha del insumo seleccionado ───────────────────────────────────────── */
#ct-ficha-insumo {
  display: none;
  background: #eef4ff;
  border: 1px solid #bcd0f7;
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 13px;
}

.ct-ficha-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ct-ficha-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ct-ficha-label {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ct-muted);
}

.ct-ficha-valor {
  font-size: 13px;
  font-weight: 600;
  color: #1c2a3a;
}

.ct-badge-multidosis {
  display: inline-block;
  background: #d1ecf1;
  color: #0c5460;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Toggle tipo dosis ───────────────────────────────────────────────────── */
.ct-toggle-dosis {
  display: flex;
  gap: 0;
  border: 1px solid var(--ct-primary);
  border-radius: 6px;
  overflow: hidden;
  width: fit-content;
  margin-bottom: 14px;
}

.ct-toggle-dosis input[type="radio"] {
  display: none;
}

.ct-toggle-dosis label {
  padding: 6px 18px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ct-primary);
  background: #fff;
  transition:
    background 0.15s,
    color 0.15s;
  margin: 0;
  user-select: none;
}

.ct-toggle-dosis input[type="radio"]:checked + label {
  background: var(--ct-primary);
  color: #fff;
}

/* ── Cálculo en tiempo real ──────────────────────────────────────────────── */
#ct-calculo-box {
  background: #fffbea;
  border: 1px solid #ffe082;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

.ct-calculo-formula {
  color: #5f4400;
  font-weight: 500;
}

.ct-calculo-resultado {
  font-size: 15px;
  font-weight: 700;
  color: #1c7a1c;
  margin-top: 4px;
}

/* ── Grid formulario ─────────────────────────────────────────────────────── */
.ct-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.ct-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ct-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ct-muted);
}

.ct-input {
  border: 1px solid var(--ct-border);
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 13px;
  width: 100%;
  background: #fff;
  transition: border-color 0.15s;
}

.ct-input:focus {
  outline: none;
  border-color: var(--ct-primary);
  box-shadow: 0 0 0 2px rgba(26, 111, 196, 0.12);
}

.ct-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
}

/* ── Botón guardar ───────────────────────────────────────────────────────── */
.ct-btn-guardar {
  background: var(--ct-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    opacity 0.2s;
  margin-top: 12px;
}

.ct-btn-guardar:hover {
  background: #155a9e;
}
.ct-btn-guardar:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ct-btn-limpiar {
  background: #fff;
  color: var(--ct-muted);
  border: 1px solid var(--ct-border);
  border-radius: 6px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.ct-btn-limpiar:hover {
  background: #f0f4fa;
  color: #1c2a3a;
}

/* ── Divisor entre zonas ─────────────────────────────────────────────────── */
.ct-divisor {
  border: none;
  border-top: 2px solid var(--ct-border);
  margin: 0;
}

/* ── Calendario horizontal de tratamientos ───────────────────────────────── */
.ct-cal-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border-radius: 7px;
  border: 1px solid var(--ct-border);
}

.ct-cal-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 500px;
}

.ct-cal-tabla thead tr {
  background: #f0f4fa;
  position: sticky;
  top: 0;
  z-index: 2;
}

.ct-cal-th-nombre {
  padding: 7px 12px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--ct-muted);
  text-align: left;
  white-space: nowrap;
  min-width: 160px;
  border-bottom: 2px solid var(--ct-border);
  border-right: 2px solid var(--ct-border);
  position: sticky;
  left: 0;
  background: #f0f4fa;
  z-index: 1;
}

.ct-cal-th-fecha {
  padding: 6px 8px;
  font-weight: 700;
  font-size: 12px;
  text-align: center;
  min-width: 64px;
  border-bottom: 2px solid var(--ct-border);
  border-right: 1px solid var(--ct-border);
  line-height: 1.3;
  color: #1c2a3a;
}

.ct-cal-th-fecha.ct-cal-hoy,
.ct-cal-td.ct-cal-hoy {
  background: #fffbea;
  border-left: 2px solid #f0ad4e;
  border-right: 2px solid #f0ad4e;
}

.ct-cal-th-fecha.ct-cal-hoy {
  color: #856404;
  border-bottom: 2px solid #f0ad4e;
}

.ct-cal-td-nombre {
  padding: 8px 12px;
  border-bottom: 1px solid var(--ct-border);
  border-right: 2px solid var(--ct-border);
  vertical-align: middle;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}

.ct-cal-nombre {
  font-weight: 600;
  color: #1c2a3a;
  font-size: 12px;
  white-space: nowrap;
}

.ct-cal-meta {
  font-size: 10px;
  color: var(--ct-muted);
  margin-top: 2px;
}

.ct-cal-td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--ct-border);
  border-right: 1px solid var(--ct-border);
  vertical-align: top;
  text-align: center;
}

.ct-cal-app {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 600;
  margin: 1px;
  white-space: nowrap;
}

.ct-cal-app.aplicado {
  background: #d4edda;
  color: #155724;
}
.ct-cal-app.sin_aplicar {
  background: #fff3cd;
  color: #856404;
}
.ct-cal-app.anulado {
  background: #f8d7da;
  color: #721c24;
  text-decoration: line-through;
}

/* Fila alterna */
.ct-cal-tabla tbody tr:nth-child(even) .ct-cal-td-nombre,
.ct-cal-tabla tbody tr:nth-child(even) .ct-cal-td {
  background: #fafbfc;
}

/* ── Tabla tratamientos (zona inferior) ──────────────────────────────────── */
.ct-tabla-titulo {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ct-muted);
  margin-bottom: 10px;
}

.ct-trat-item {
  background: var(--ct-card-bg);
  border: 1px solid var(--ct-border);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}

.ct-trat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: #f0f4fa;
  font-size: 13px;
  font-weight: 600;
  flex-wrap: wrap;
}

.ct-trat-nombre {
  flex: 1;
  min-width: 150px;
}

.ct-trat-meta {
  font-size: 11px;
  color: var(--ct-muted);
  font-weight: 400;
}

.ct-planilla-wrap {
  padding: 8px 14px 10px;
  overflow-x: auto;
}

.ct-planilla-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ct-planilla-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 10px;
  min-width: 68px;
  border: 1px solid transparent;
}

.ct-planilla-chip.aplicado {
  background: #d4edda;
  border-color: #c3e6cb;
  color: #155724;
}

.ct-planilla-chip.sin_aplicar {
  background: #fff3cd;
  border-color: #ffeeba;
  color: #856404;
}

.ct-planilla-chip.anulado {
  background: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
  text-decoration: line-through;
}

.ct-chip-fecha {
  font-weight: 700;
  font-size: 10px;
}
.ct-chip-hora {
  font-size: 9px;
  opacity: 0.8;
}
.ct-chip-estado {
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 2px;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.ct-spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  gap: 10px;
  color: var(--ct-muted);
  font-size: 14px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 576px) {
  .ct-form-grid {
    grid-template-columns: 1fr 1fr;
  }
  .ct-header-paciente {
    width: 100%;
    order: 3;
  }
  .ct-body {
    padding: 10px;
  }
  .ct-card {
    padding: 12px;
  }
}

@media (min-width: 1200px) {
  .ct-body {
    padding-left: 5rem;
    padding-right: 5rem;
    margin: 0 auto;
    width: 100%;
  }
}

@media (min-width: 1600px) {
  .ct-body {
    padding-left: 10rem;
    padding-right: 10rem;
  }
}

@media (min-width: 1920px) {
  .ct-body {
    padding-left: 16rem;
    padding-right: 16rem;
  }
}
