/* ════════════════════════════════════════════════════════════════════════
   Toma de Muestra (laboratorio) — estilos de pantalla
   Alineado al sistema visual de hospitalizado/css/workspaceClinico.css
   (azul/slate, plano, radio 8px, sombras sutiles). Las variables se
   encapsulan en #moduloLabTomaMuestra para no colisionar globalmente.
   ════════════════════════════════════════════════════════════════════════ */
#moduloLabTomaMuestra {
    --primary-color: #1a6fc4;
    --primary-dark: #145390;
    --primary-soft: #eef5fc;
    --secondary-color: #6b7280;
    --text-main: #1f2937;
    --text-muted: #9ca3af;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --surface-alt: #f9fafb;
    --border: #e5e7eb;
    --border-strong: #cbd5e1;
    --success: #198754;
    --danger: #b91c1c;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 6px 16px -4px rgba(15, 23, 42, 0.18);
    --focus-ring: 0 0 0 3px rgba(26, 111, 196, 0.12);
}

/* ── Banner de Información de Orden ── */
.orden-info-banner {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.orden-codigo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.orden-codigo i {
    font-size: 1.35rem;
}

.orden-detail {
    font-size: 0.9rem;
}

.orden-detail label {
    display: block;
    font-weight: 600;
    opacity: 0.85;
    margin-bottom: 0.25rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.orden-detail span {
    display: block;
    font-weight: 500;
}

/* ── Card de Paciente ── */
.patient-header-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.patient-info-wrapper {
    display: flex;
    align-items: center;
    padding: 1.5rem;
}

.patient-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    margin-right: 1.5rem;
}

.patient-details h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.patient-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--secondary-color);
    align-items: center;
    margin-bottom: 0.5rem;
}

.patient-tutor {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-top: 0.5rem;
}

.patient-tutor i {
    margin-right: 0.25rem;
}

.patient-weight {
    background-color: var(--primary-soft);
    color: var(--primary-color);
    padding: 0.2rem 0.7rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
}

.patient-alert {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 0.2rem 0.7rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Card de Muestra ── */
.sample-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    overflow: hidden;
}

.sample-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.sample-card-body {
    padding: 1rem 1.1rem;
    padding-left: 1.25rem;
}

.sample-card h5 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.35;
    font-size: 0.95rem;
    color: var(--text-main);
}

/* Vista compacta para muestras ya guardadas en lista de trabajo */
.sample-card--guardada {
    background: #f0fdf4;
    border-color: #86efac;
}

.sample-card--guardada .sample-card-body {
    padding: 0.5rem 0.9rem;
}

.sample-card--guardada .form-section {
    display: none;
}

.sample-card--guardada .custom-switch,
.sample-card--guardada .custom-checkbox {
    display: none;
}

.sample-card--guardada h5 {
    font-size: 0.9rem;
    margin-bottom: 0;
}

.sample-card--guardada .d-flex.justify-content-between {
    align-items: center;
    margin-bottom: 4px;
}

/* Tarjeta bloqueada tras guardado inmediato */
.sample-card--bloqueada {
    opacity: 0.65;
    pointer-events: none;
}

/* Acciones en layout compacto (muestra guardada) */
.sample-card__acciones-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: 0;
}

.sample-card__guardada-text {
    color: #065f46;
    font-weight: 700;
    font-size: 0.72rem;
}

/* ── Secciones del formulario ── */
.form-section {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.section-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.section-title i {
    margin-right: 0.5rem;
    color: var(--primary-color);
}

/* ── Checkboxes / switches ── */
.custom-checkbox .custom-control-label {
    font-size: 0.82rem;
    font-weight: 500;
}

/* Header de la card: permite que tipo de muestra, switch y estado bajen de línea */
.sample-card .d-flex.justify-content-between {
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.custom-checkbox .custom-control-label i {
    margin-right: 0.25rem;
}

.custom-control-input:checked~.custom-control-label::before {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.custom-control-input:focus~.custom-control-label::before {
    box-shadow: var(--focus-ring);
}

.custom-switch.custom-switch-lg .custom-control-label {
    padding-left: 2.25rem;
    padding-bottom: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.custom-switch.custom-switch-lg .custom-control-label::before {
    height: 1.4rem;
    width: 2.5rem;
    border-radius: 0.75rem;
}

.custom-switch.custom-switch-lg .custom-control-label::after {
    height: 1.05rem;
    width: 1.05rem;
    border-radius: 50%;
    top: calc(0.25rem + 2px);
    left: calc(-2.25rem + 2px);
}

.custom-switch.custom-switch-lg .custom-control-input:checked~.custom-control-label::after {
    transform: translateX(1.1rem);
}

/* ── Inputs ── */
.form-control-premium {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
    height: auto;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background-color: var(--surface-alt);
}

.form-control-premium:focus {
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
    background-color: #fff;
}

.form-label-premium {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Botones ── */
.btn-action {
    background-color: var(--surface-alt);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.9rem;
    font-weight: 600;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-action:hover {
    background-color: #eef0f3;
    color: var(--primary-color);
    border-color: var(--border-strong);
}

.action-footer {
    margin-top: 2rem;
    text-align: right;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.btn-primary-premium {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    padding: 0.65rem 1.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 6px -1px rgba(20, 83, 144, 0.35);
    transition: all 0.15s ease;
    color: white;
}

.btn-primary-premium:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #0f3f6e 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px -1px rgba(20, 83, 144, 0.45);
    color: white;
}

.btn-primary-premium:focus {
    box-shadow: var(--focus-ring);
    color: white;
}

/* ── Badges ── */
.tube-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}

/* Píldora estado (estilo workspaceClinico) — usada en muestra guardada */
.tm-estado-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #d1fae5;
    color: #065f46;
}

/* Código LAB como píldora monoespaciada */
.badge-lab-code {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: #d1fae5;
    color: #065f46;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ── Lista de exámenes ── */
.exam-list {
    list-style: none;
    padding: 0;
    margin: 0;
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.exam-list li::before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

/* ── Indicador de guardado automático ── */
#autosave-indicator {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--success);
    color: white;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: none;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Responsividad ── */

/* Indicadores de calidad: que envuelvan en vez de desbordar */
.sample-card .d-flex.gap-3 {
    flex-wrap: wrap;
    row-gap: 0.4rem;
}

/* En pantallas anchas, dos muestras por fila para aprovechar el espacio */
@media (min-width: 1400px) {
    #samples-container>[class*="col-"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* En móvil, compactar aún más y dar aire entre campos apilados */
@media (max-width: 575.98px) {
    .sample-card-body {
        padding: 0.85rem 0.9rem;
    }

    .form-section {
        margin-bottom: 0.85rem;
        padding-bottom: 0.6rem;
    }

    .sample-card .row>[class*="col-"] {
        margin-bottom: 0.5rem;
    }

    .action-footer {
        text-align: center;
    }
}
