/* Reset and Base Styles */
body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* Popup Styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
}

.popup-logo {
    max-height: 60px;
    width: auto;
    margin-left: 10px;
}

.popup .close-btn {
    background-color: #0077b6;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    cursor: pointer;
    display: block;
    margin: 0 0 20px auto; /* Push to right */
}

.popup-title {
    font-size: 18px;
    font-weight: bold;
}

.close-btn {
    background-color: #0077b6;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    cursor: pointer;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
}

.terms-checkbox {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.terms-link {
    color: #8b104e;
    text-decoration: none;
}

.submit-container {
    display: flex;
    justify-content: center;
}

.submit-btn {
    background-color: #8b104e;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 12px 20px;
    cursor: pointer;
    font-weight: bold;
}

.submit-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Error message */
.error-message {
    background-color: #ffeeee;
    color: #cc0000;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
    border-left: 4px solid #cc0000;
}

/* Tables and Lists */
.estudios-container {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
}

.estudios-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    position: relative;
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
}

.results-logo {
    max-height: 60px;
    width: auto;
    margin-bottom: 10px;
}

.estudios-content {
    margin-top: 20px;
    overflow-x: auto;
    width: 100%;
    box-sizing: border-box;
}

.welcome-message {
    font-size: 18px;
    margin: 10px 0;
    flex-grow: 1;
    text-align: center;
}

.estudios-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Ensure table doesn't get too compressed */
}

.estudios-table th {
    background-color: #f5f5f5;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #ddd;
}

.estudios-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

/* Action buttons */
.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 3px;
    font-weight: bold;
    display: inline-block;
    width: auto;
}

.view-btn {
    background-color: #0077b6;
    color: white;
}

.download-btn {
    background-color: #8b104e;
    color: white;
}

/* Logo Styles */
.logo-container {
    text-align: center;
    margin-bottom: 20px;
}

.header-logo {
    max-height: 60px;
    width: auto;
}

/* Viewer page adjustments */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 10px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.pdf-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

#pdfContainer {
    width: 100%;
    height: calc(100vh - 200px);
    overflow: auto;
    border: 1px solid #ccc;
    margin-top: 20px;
    position: relative;
    background-color: #f5f5f5;
}

.pdf-viewer {
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.pdf-viewer canvas {
    max-width: 100%;
    height: auto;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    background-color: rgba(255,255,255,0.8);
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
    display: none;
}

.btn {
    background-color: #0077b6;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #005a8c;
}

.page-info {
    margin: 0 10px;
    font-size: 14px;
    color: #666;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
        margin: 0;
        box-sizing: border-box;
    }

    .container {
        padding: 0;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .estudios-container {
        padding: 15px;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .estudios-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 15px;
        margin-bottom: 20px;
        width: 100%;
        display: flex !important;
        background-color: white;
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        box-sizing: border-box;
    }

    .estudios-header .results-logo {
        max-height: 50px;
        width: auto;
        margin-bottom: 10px;
        display: block !important;
    }

    .estudios-header .welcome-message {
        font-size: 16px;
        margin: 10px 0;
        color: #333;
        display: block !important;
        width: 100%;
    }

    .estudios-header .close-btn {
        margin-top: 10px;
        padding: 8px 20px;
        display: block !important;
        width: auto;
    }

    .estudios-content {
        margin-top: 15px;
        width: 100%;
        box-sizing: border-box;
    }

    /* Ocultar la vista de escritorio en dispositivos móviles */
    .desktop-view {
        display: none !important;
    }
    
    /* Mostrar el contenedor de tarjetas */
    .mobile-cards-container {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    /* Estilo para cada tarjeta de estudio */
    .estudio-card {
        background-color: white;
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        margin-bottom: 15px;
        padding: 15px;
        position: relative;
    }
    
    /* Título de la tarjeta (tipo de estudio) */
    .estudio-card-title {
        font-weight: bold;
        font-size: 16px;
        margin-bottom: 10px;
        color: #0077b6;
    }
    
    /* Detalles del estudio */
    .estudio-card-details {
        margin-bottom: 12px;
    }
    
    .estudio-card-row {
        display: flex;
        margin-bottom: 5px;
    }
    
    .estudio-card-label {
        font-weight: bold;
        width: 90px;
        color: #666;
    }
    
    .estudio-card-value {
        flex: 1;
    }
    
    /* Botones de acción */
    .estudio-card-actions {
        display: flex;
        gap: 8px;
        margin-top: 15px;
    }
    
    .action-btn {
        flex: 1;
        justify-content: center;
        padding: 12px;
        border-radius: 6px;
    }
    
    /* Estilos para mostrar u ocultar la descripción */
    .estudio-card-description {
        margin-top: 10px;
        border-top: 1px dashed #eee;
        padding-top: 10px;
        font-size: 14px;
        color: #666;
        display: none;
    }
    
    .description-toggle {
        color: #0077b6;
        text-decoration: underline;
        cursor: pointer;
        display: inline-block;
        margin-top: 5px;
        font-size: 13px;
    }

    .toolbar {
        flex-direction: column;
        align-items: center;
    }
    
    .pdf-controls {
        margin-bottom: 10px;
        justify-content: center;
    }
    
    #pdfContainer {
        height: calc(100vh - 250px);
    }
}

/* Para pantallas de escritorio, ocultar tarjetas y mostrar tabla */
@media (min-width: 769px) {
    .mobile-cards-container {
        display: none !important;
    }
    
    .desktop-view {
        display: block !important;
    }
    
    .table-responsive {
        display: block;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .estudios-container {
        padding: 10px;
    }
    
    .form-input, .submit-btn {
        padding: 10px;
    }
    
    .estudios-table {
        font-size: 14px;
    }
    
    .estudios-table th, .estudios-table td {
        padding: 8px;
    }
}

/* Mejoras específicas para móviles */
@media (max-width: 768px) {
    /* Modificar el comportamiento de la tabla */
    .estudios-table {
        width: 100%;
        min-width: initial; /* Quitar el min-width para móviles */
    }

    /* Ocultar la columna de descripción en móviles */
    .estudios-table th:nth-child(3),
    .estudios-table td:nth-child(3) {
        display: none;
    }

    /* Hacer los botones de acción más compactos con iconos */
    .action-btn {
        width: auto;
        margin: 3px;
        padding: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Mostrar solo iconos en móviles */
    .action-btn .btn-text {
        display: none;
    }
    
    .action-btn .btn-icon {
        display: inline-block;
        width: 20px;
        height: 20px;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
    }
    
    /* Cuando hay espacio, agrandar botones y mostrar texto junto a iconos */
    @media (min-width: 480px) and (max-width: 768px) {
        .action-btn {
            padding: 8px 10px;
        }
        
        .action-btn .btn-text {
            display: inline-block;
            margin-left: 5px;
        }
    }
}