/* ========================================
   Estilos compartidos para Documentos
   - Orden de Servicios / Recibo de Caja (OSC)
   - Facturas
   ======================================== */

/* Contenedor principal */
.osc-container {
    max-width: 1200px;
    margin: 0 auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #ffffff;
}

/* Encabezado del documento */
.osc-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 4px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.osc-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    display: inline-block;
}

.osc-subtitle {
    font-size: 11px;
    opacity: 0.9;
    margin: 0 0 0 15px;
    display: inline-block;
}

.osc-number {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: #3498db;
}

.osc-number-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    margin-right: 5px;
}

/* Secciones del documento */
.osc-section {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.osc-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 2px solid #3498db;
}

.osc-section-compact {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 6px;
}

/* Información del documento */
.osc-info-item {
    margin-bottom: 4px;
}

.osc-info-label {
    font-size: 9px;
    font-weight: 600;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: block;
    margin-bottom: 2px;
}

.osc-info-value {
    font-size: 12px;
    color: #2c3e50;
    font-weight: 500;
    padding: 3px 6px;
    background-color: white;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
}

.osc-patient-name {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #2c3e50 !important;
    background-color: #e3f2fd !important;
    border-left: 4px solid #2196f3 !important;
}

/* Sección de totales */
.osc-totals-section {
    background: linear-gradient(135deg, #ecf0f1 0%, #d5dbdb 100%);
    border-radius: 4px;
    padding: 8px 10px;
    margin-top: 6px;
}

.osc-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.osc-total-row:last-child {
    border-bottom: none;
    padding-top: 6px;
    margin-top: 4px;
    border-top: 2px solid #2c3e50;
}

.osc-total-label {
    font-size: 11px;
    font-weight: 600;
    color: #2c3e50;
}

.osc-total-value {
    font-size: 14px;
    font-weight: 700;
    color: #27ae60;
}

.osc-total-final {
    font-size: 16px !important;
    color: #e74c3c !important;
}

/* Estados del documento */
.osc-estado {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.osc-estado-activo {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.osc-estado-anulado {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.osc-fecha {
    font-size: 10px;
    color: #7f8c8d;
    font-weight: 500;
}

/* Estilos para las tablas de detalle */
.osc-detalle-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 6px;
    overflow: hidden;
}

.osc-detalle-table thead tr {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    color: white;
}

.osc-detalle-table th {
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid #3498db;
}

.osc-detalle-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #ecf0f1;
    font-size: 11px;
    color: #2c3e50;
}

.osc-detalle-table tbody tr:hover {
    background-color: #f8f9fa;
}

.osc-detalle-table tbody tr:last-child td {
    border-bottom: none;
}

.osc-detalle-total-row {
    background-color: #ecf0f1 !important;
    font-weight: 600;
}

/* Estilos para impresión */
@media print {
    .osc-header {
        background: #2c3e50 !important;
        -webkit-print-color-adjust: exact;
    }
    .osc-detalle-table thead tr {
        background: #34495e !important;
        -webkit-print-color-adjust: exact;
    }
}

/* ========================================
   Estilos para Spinners y Overlays
   ======================================== */
#spinnerOverlay, .spinnerOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9999;
}

#spinnerBox, .spinnerBox {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 8px;
    padding: 28px 36px;
    text-align: center;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    color: #333;
}

#spinnerWheel, .spinnerWheel {
    width: 42px;
    height: 42px;
    border: 5px solid #ddd;
    border-top-color: #337ab7;
    border-radius: 50%;
    margin: 0 auto 14px auto;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Estilos para Modal de Resultados
   ======================================== */
#resultOverlay, .resultOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
}

#resultBox, .resultBox {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 10px;
    padding: 28px 32px;
    width: 480px;
    max-width: 95vw;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.3);
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    color: #333;
}

.rb-icon {
    font-size: 38px;
    text-align: center;
    margin-bottom: 8px;
}

.rb-title {
    font-size: 17px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 16px;
}

.rb-title.ok {
    color: #2e7d32;
}

.rb-title.err {
    color: #c62828;
}

.rb-label {
    font-size: 11px;
    color: #777;
    margin-bottom: 3px;
    margin-top: 12px;
}

.rb-url-row {
    display: flex;
    gap: 6px;
}

.rb-url-row input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 12px;
    color: #1a73e8;
    background: #f5f5f5;
    outline: none;
}

.rb-url-row button {
    padding: 7px 14px;
    background: #1976d2;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.rb-url-row button:active {
    background: #1255a0;
}

.rb-extra {
    font-size: 11px;
    color: #b71c1c;
    margin-top: 10px;
    word-break: break-all;
}

.rb-close {
    display: block;
    margin: 20px auto 0;
    padding: 8px 32px;
    background: #455a64;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.rb-close:hover {
    background: #263238;
}

/* ========================================
   Estilos para Formularios de Búsqueda
   ======================================== */
.search-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 14px;
    border-radius: 6px 6px 0 0;
    margin: -12px -16px 10px -16px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.search-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.search-field {
    flex: 1;
    min-width: 120px;
}

.search-field label {
    display: block;
    font-size: 9px;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
    line-height: 1.2;
}

.search-field input[type="text"],
.search-field select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 12px;
    background-color: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-field input[type="text"]:focus,
.search-field select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-field input[readonly] {
    background-color: #edf2f7;
    color: #4a5568;
    font-weight: 600;
}

/* ========================================
   Estilos para Tablas de Resultados Mejoradas
   ======================================== */
.results-container {
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.results-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-scrollable {
    overflow: auto;
    max-height: 500px;
}

.lab-results-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

.lab-results-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.lab-results-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 11px;
    color: #2d3748;
}

.lab-results-table tr:hover {
    background-color: #f7fafc;
}

.lab-results-table tr:last-child td {
    border-bottom: none;
}

.action-buttons {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.action-buttons img {
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.action-buttons img:hover {
    transform: scale(1.1);
    opacity: 0.8;
}
