/* ==========================================================================
   Plataforma RX - Módulo de Estudios Radiológicos (Recortes, Resultados, Historiales)
   ========================================================================== */

/* Cabecera de Página y Contenedores */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Tabs de Navegación */
.tabs, .tabs-container {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.4rem;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.65rem 1.4rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(93, 93, 93, 0.25);
}
[data-theme="dark"] .tab-btn.active {
    color: #121212;
}

.badge-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
}

.tab-btn:not(.active) .badge-count {
    background: var(--bg-main);
    color: var(--text-muted);
}

/* Barra de Búsqueda de Estudios */
.search-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    background: var(--bg-card);
    padding: 0.65rem 0.85rem;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.search-bar .search-input {
    flex: 1;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-bar .search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(242, 216, 32, 0.2);
}

/* Grilla y Tarjetas de Estudios */
.grid-estudios {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.25rem;
}

.card-estudio {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

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

.card-header-info {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
}

.paciente-nombre {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.paciente-doc {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.estudio-nombre {
    font-size: 0.95rem;
    font-weight: 600;
    color: #8b5cf6;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(139, 92, 246, 0.08);
    padding: 4px 10px;
    border-radius: 8px;
    width: fit-content;
}

/* Badges de Pago y Estado */
.badge-urgente {
    background: var(--color-danger);
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-pago {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
}

.badge-pago-pagado { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-pago-pendiente { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-pago-cortesia { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-pago-repeticion { background: rgba(59, 130, 246, 0.15); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); }

/* Secciones Internas de Tarjeta */
.card-sections {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.info-group {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
}

.info-group-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-primary);
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
}

.info-grid > div {
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.info-item-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
}
.info-item-sub strong {
    color: var(--text-main);
}

/* Selección Directa de Archivo y Contenedor Vacío */
.file-select-box {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--bg-main);
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 0.25rem;
}
.file-select-box:hover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
}
.file-select-input { display: none; }
.file-select-text {
    font-size: 0.88rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px dashed var(--border-color);
    grid-column: 1 / -1;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ==========================================================================
   Portal Público de Resultados & Visores PACS (resultados.php)
   ========================================================================== */
.landing-header {
    position: sticky;
    top: 0; left: 0; width: 100%; height: 80px;
    z-index: 1000;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5%;
    box-sizing: border-box;
}
.header-logo img { height: 48px; width: auto; display: block; }
.header-nav { display: flex; align-items: center; gap: 1.5rem; }
.nav-link-landing {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.nav-link-landing:hover { color: var(--text-main); }

.search-box-dark {
    background: #131c2e;
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    max-width: 480px;
    margin: 20px auto 40px auto;
    text-align: center;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6), 0 0 30px rgba(37, 99, 235, 0.15);
}

.patient-card-dark, .estudio-card-dark {
    background: #131c2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.landing-footer {
    background: #070a12;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 3rem 5% 2rem 5%;
    text-align: center;
    margin-top: auto;
}

/* PACS Visor Modals (2D & 3D) */
.viewer-modal { background: #0b0f19 !important; }
.viewer-modal .viewer-header {
    position: absolute; top: 0; left: 0; width: 100%; height: 70px; z-index: 2010;
    padding: 0 24px; background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); display: flex; justify-content: space-between; align-items: center; gap: 15px; color: #fff;
}
.viewer-brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.viewer-brand-logo { height: 44px; max-height: 44px; width: auto; object-fit: contain; }
.viewer-brand-title { font-size: 0.95rem; font-weight: 600; color: #cbd5e1; border-left: 1px solid rgba(255, 255, 255, 0.2); padding-left: 12px; }
.viewer-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.viewer-modal .control-group { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: #cbd5e1; background: rgba(255, 255, 255, 0.06); padding: 4px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.1); }
.viewer-modal .control-group label { margin: 0; color: #94a3b8; font-size: 0.8rem; }
.viewer-modal .control-group input[type="range"] { width: 85px; height: 4px; accent-color: #3b82f6; cursor: pointer; }
.viewer-modal .btn-tool { background: rgba(255, 255, 255, 0.08); color: #f1f5f9; border: 1px solid rgba(255, 255, 255, 0.15); padding: 6px 12px; border-radius: 6px; font-size: 0.85rem; cursor: pointer; }
.viewer-modal .btn-tool.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.viewer-modal .btn-reset { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.viewer-modal .viewer-close { font-size: 2.2rem; cursor: pointer; color: #94a3b8; margin-left: 10px; }
.viewer-modal .viewer-close:hover { color: #ef4444; }
.viewer-modal .viewer-container { padding-top: 70px; background: #0b0f19; height: 100vh; width: 100vw; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
#viewerImage { max-width: 90%; max-height: 85vh; object-fit: contain; cursor: grab; }
#viewerImage:active { cursor: grabbing; }

@keyframes indeterminateProgress {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0%); }
    100% { transform: translateX(100%); }
}

/* Portal de Doctores y Autenticación Dark (doctores.php) */
.user-name-badge-dark {
    font-weight: 600;
    font-size: 0.9rem;
    color: #f8fafc;
    background: rgba(2, 132, 199, 0.15);
    border: 1px solid rgba(2, 132, 199, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-profile-doctor-dark {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 10px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-profile-doctor-dark:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.btn-logout-doctor-dark {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    text-decoration: none;
    transition: all 0.2s ease;
}
.btn-logout-doctor-dark:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.auth-container-dark {
    background: #131c2e;
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 24px;
    padding: 2.8rem 2.2rem;
    max-width: 480px;
    margin: 20px auto 40px auto;
    text-align: center;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6), 0 0 30px rgba(2, 132, 199, 0.15);
}
.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(2, 132, 199, 0.15);
    border: 1px solid rgba(2, 132, 199, 0.3);
    color: #06b6d4;
    padding: 0.4rem 1.2rem;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}
.auth-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: #f8fafc;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #ffffff 30%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.auth-desc {
    color: #94a3b8;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.75rem;
}
.auth-tabs-dark {
    display: flex;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 4px;
    margin-bottom: 24px;
    gap: 4px;
}
.auth-tab-dark {
    flex: 1;
    padding: 8px 6px;
    text-decoration: none;
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 10px;
    transition: all 0.2s ease;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    line-height: 1.2;
    box-sizing: border-box;
}
.auth-tab-dark.active {
    background: linear-gradient(135deg, #0284c7, #06b6d4);
    color: white;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.form-label-dark {
    font-weight: 600;
    font-size: 0.9rem;
    color: #94a3b8;
    display: block;
    margin-bottom: 0.5rem;
    text-align: left;
}
.form-input-dark {
    width: 100%;
    box-sizing: border-box;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 0.8rem 1.1rem;
    font-size: 1rem;
    color: #f8fafc;
    transition: all 0.2s ease;
}
.form-input-dark:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
}
.btn-main-doctor {
    width: 100%;
    background: linear-gradient(135deg, #0284c7, #06b6d4);
    color: white;
    padding: 0.9rem 1.8rem;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(6, 182, 212, 0.35);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 1rem;
}
.btn-main-doctor:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(2, 132, 199, 0.45);
}

.result-info-box-dark {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 14px;
    padding: 20px;
    text-align: left;
    margin-bottom: 20px;
}
.result-info-title-dark {
    color: #34d399;
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 8px;
}
.result-user-highlight-dark {
    background: rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
    font-family: monospace;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: 8px;
    display: inline-block;
    margin-top: 6px;
    letter-spacing: 0.5px;
}

.patient-badge-dark {
    background: rgba(2, 132, 199, 0.15);
    border: 1px solid rgba(2, 132, 199, 0.3);
    color: #38bdf8;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 8px;
}
.btn-pdf {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.45);
    color: #fff;
}

.modal-card-dark {
    background: #131c2e;
    border-radius: 24px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
}
.modal-header-dark {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 16px;
}
.modal-title-dark {
    font-size: 1.3rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}
.modal-close-dark {
    font-size: 1.8rem;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    transition: color 0.2s ease;
}
.modal-close-dark:hover {
    color: #ef4444;
}

@media (max-width: 900px) {
    .header-nav { gap: 0.75rem; }
    .user-name-badge-dark { display: none; }
}



/* Carga de Estudios Externos (estudios_externos.php) */
.refresh-status { font-size: 0.85rem; color: #64748b; background: var(--bg-main); padding: 0.25rem 0.75rem; border-radius: 99px; border: 1px solid var(--border-color); }
.badge.pendiente { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge.completado { background: rgba(16, 185, 129, 0.15); color: #10b981; }

.upload-section { margin-left: 2rem; text-align: center; width: 260px; }
.file-input { display: none; }
.btn-upload { background: #8b5cf6; color: #ffffff !important; border: none; padding: 0.75rem 1rem; border-radius: 8px; font-weight: 600; cursor: pointer; width: 100%; transition: all 0.2s; display: inline-block; margin-bottom: 0.5rem; text-align: center; box-shadow: 0 2px 4px rgba(139, 92, 246, 0.25); }
.btn-upload:hover { background: #7c3aed; color: #ffffff !important; transform: translateY(-1px); }
.file-name-display { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; word-break: break-all; min-height: 1.2em; }
.btn-submit { background: var(--color-success); color: white; border: none; padding: 0.75rem 1rem; border-radius: 8px; font-weight: 600; cursor: pointer; width: 100%; transition: transform 0.1s; display: none; }
.btn-submit:active { transform: scale(0.95); }
.btn-view { background: var(--color-success); color: white; border: none; padding: 0.75rem 1rem; border-radius: 8px; font-weight: 600; text-decoration: none; display: inline-block; width: 100%; text-align: center; border-radius: 8px; }




