/* 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;
}

.estudios-table th:last-child,
.estudios-table td:last-child {
    min-width: 250px; /* Ensure enough space for both buttons */
    text-align: center;
}

/* Action buttons */
.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 3px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 120px !important; /* Fixed width with !important to ensure it applies everywhere */
    min-width: 120px; /* Ensure minimum width for both buttons */
    text-align: center; /* Center text for consistent appearance */
    box-sizing: border-box; /* Make sure padding is included in width */
}

/* Specific styles for buttons in table cells */
.estudios-table td .action-btn {
    display: inline-block !important;
    width: 120px !important;
    min-width: 120px !important;
    margin: 3px;
    text-align: center;
    box-sizing: border-box;
}

.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;
    }
    
    .estudio-card-actions .action-btn {
        flex: 1;
        justify-content: center;
        padding: 12px;
        border-radius: 6px;
        width: calc(50% - 4px); /* Each button takes up half the space minus half the gap */
        min-width: 0; /* Override min-width for card view */
    }
    
    /* 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);
    }

    .estudios-table td:last-child {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 8px 4px;
        gap: 4px;
    }
    
    .estudio-card-actions {
        flex-wrap: nowrap !important;
        justify-content: center;
    }
    
    a.action-btn.view-btn,
    a.action-btn.download-btn,
    button.action-btn.view-btn,
    button.action-btn.download-btn,
    .estudio-card-actions .action-btn {
        width: 120px !important;
        min-width: 120px !important;
        max-width: 120px !important;
        flex: 0 0 120px !important;
    }

    /* 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;
    }

    /* 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 .btn-text {
            display: inline-block;
            margin-left: 5px;
        }
    }
}

/* 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;
    }

    .action-btn {
        width: 120px !important;
        min-width: 120px;
    }
    
    .estudios-table td .action-btn {
        width: 120px !important;
        display: inline-flex;
        margin: 3px;
    }
}

@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;
    }

    .estudios-table td:last-child {
        padding: 5px;
    }
    
    a.action-btn.view-btn,
    a.action-btn.download-btn,
    button.action-btn.view-btn,
    button.action-btn.download-btn,
    .estudio-card-actions .action-btn {
        width: 100px !important;
        min-width: 100px !important;
        max-width: 100px !important;
        flex: 0 0 100px !important;
        margin: 2px;
        padding: 8px;
    }
}

/* Ajustes específicos para la vista móvil más pequeña */
@media (max-width: 359px) {
    .estudios-table td:last-child {
        padding: 3px;
    }
    
    a.action-btn.view-btn,
    a.action-btn.download-btn,
    button.action-btn.view-btn,
    button.action-btn.download-btn,
    .estudio-card-actions .action-btn {
        width: 80px !important;
        min-width: 80px !important;
        max-width: 80px !important;
        flex: 0 0 80px !important;
        padding: 6px 4px;
        margin: 1px;
        font-size: 13px;
    }
    
    .estudio-card-actions {
        gap: 3px;
    }
}

/* Login Page Styles */
.login-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    max-width: 200px;
    margin: 0 auto 20px;
    display: block;
}

.login-form {
    width: 90%;
    margin: 0 auto;
}

.login-form .form-group {
    margin-bottom: 20px;
    text-align: left;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

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

.login-btn {
    width: 100%;
    padding: 12px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 10px;
}

.login-btn:hover {
    background: #0056b3;
}

/* Studies Page Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logout-btn {
    padding: 8px 16px;
    background: #dc3545;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: #c82333;
}

.filter-container {
    padding: 20px;
    background: #f8f9fa;
    margin-bottom: 20px;
}

.date-filter-form {
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.filter-btn {
    padding: 10px 20px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.filter-btn:hover {
    background: #218838;
}

.estudios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px;
}

.estudio-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.estudio-card-header {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.estudio-card-details {
    padding: 15px;
}

.estudio-card-actions {
    padding: 15px;
    display: flex;
    gap: 8px;
    border-top: 1px solid #ddd;
    justify-content: center; /* Centra los botones */
    flex-wrap: nowrap; /* Previene que los botones se envuelvan */
}

.estudio-card-actions .action-btn {
    flex: 0 0 auto !important; /* No crecer ni encoger */
    justify-content: center;
    padding: 12px;
    border-radius: 6px;
    min-width: 120px !important;
    width: 120px !important;
}

/* Access Options Styles */
.access-options {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.access-option {
    flex: 1;
    min-width: 300px;
    max-width: 500px;
}

.access-option h2 {
    text-align: center;
    color: #333;
    margin-bottom: 15px;
}

.access-option .popup {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.access-option .popup-header {
    text-align: center;
    margin-bottom: 20px;
}

.access-option .popup-title {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

.access-option p {
    text-align: center;
    margin-bottom: 20px;
    color: #666;
}

.access-option .submit-container {
    margin-top: auto;
}

.access-option .submit-btn {
    width: 100%;
    padding: 12px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
    text-decoration: none;
    text-align: center;
    display: block;
}

.access-option .submit-btn:hover {
    background: #0056b3;
}

@media (max-width: 768px) {
    .access-options {
        flex-direction: column;
        align-items: center;
    }
    
    .access-option {
        width: 100%;
        max-width: 100%;
    }
}

/* Registration Page Styles */
.register-container {
    max-width: 500px;
    margin: 50px auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.register-header {
    text-align: center;
    margin-bottom: 30px;
}

.register-logo {
    max-width: 200px;
    margin-bottom: 20px;
}

.register-form .form-group {
    margin-bottom: 20px;
}

.register-form label {
    display: block;
    margin-bottom: 5px;
    color: #333;
}

.register-form input,
.register-form select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.register-form select {
    background-color: white;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

.register-btn {
    flex: 1;
    padding: 12px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.register-btn:hover {
    background: #218838;
}

.back-btn {
    flex: 1;
    padding: 12px;
    background: #6c757d;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 16px;
    text-align: center;
    transition: background 0.3s;
}

.back-btn:hover {
    background: #5a6268;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
    border-left: 4px solid #28a745;
}

/* Estilo para la celda de acciones en la tabla */
.estudios-table td:last-child {
    text-align: center;
    white-space: nowrap; /* Evita que los botones se envuelvan */
    min-width: 260px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

/* Desktop specific styles */
@media (min-width: 769px) {
    .estudios-table td:last-child {
        min-width: 260px; /* Espacio suficiente para dos botones de 120px + márgenes */
        text-align: center;
    }
}

/* Estilo específico para los botones VISUALIZAR y DESCARGA */
a.action-btn.view-btn,
a.action-btn.download-btn,
button.action-btn.view-btn,
button.action-btn.download-btn {
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    flex: 0 0 120px !important;
}

/* Estilo para la celda de acciones en la tabla */
.estudios-table td:last-child {
    text-align: center;
    white-space: nowrap; /* Evita que los botones se envuelvan */
    min-width: 260px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

/* Ajuste para asegurar que los botones permanezcan en línea en la vista de tarjetas */
.estudio-card-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 15px;
    border-top: 1px solid #ddd;
}

.estudio-card-actions .action-btn {
    flex: 0 0 120px !important;
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
}