/* Estilos para el grid de documentos */
.insamar-documents-grid {
    display: grid;
    gap: 20px;
    margin: 20px 0;
}

.insamar-documents-grid[data-columns="2"] {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.insamar-documents-grid[data-columns="3"] {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.insamar-documents-grid[data-columns="4"] {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid-item {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.grid-item.has-documents:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.grid-item-link {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

.grid-item-link:hover {
    text-decoration: none;
    color: inherit;
}

.grid-item-content {
    padding: 0;
}

.grid-item-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.grid-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grid-item-info {
    padding: 20px;
}

.grid-item-title {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.grid-item-excerpt {
    color: #666;
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 15px;
}

.documents-count {
    color: #007cba;
    font-weight: 600;
    font-size: 0.9em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.documents-count::before {
    content: "📄";
    font-size: 1.1em;
}

/* Enlace de documentos (antes era botón) */
.documents-btn {
    display: inline-block;
    text-decoration: none;
    color: #007cba;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.documents-btn:hover {
    color: #005a87;
    text-decoration: none;
}

/* Para uso como overlay absoluto */
.documents-btn.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.documents-btn.overlay:hover {
    opacity: 1;
    color: white;
}

/* Para uso como badge en esquina */
.documents-btn.badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #007cba;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8em;
    z-index: 10;
}

.documents-btn.badge:hover {
    background: #005a87;
    color: white;
}

/* Para uso como icono simple */
.documents-btn.icon-only {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #007cba;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    text-indent: -9999px;
    position: relative;
}

.documents-btn.icon-only::before {
    content: "📄";
    text-indent: 0;
    position: absolute;
}

.documents-btn.icon-only:hover {
    background: #005a87;
    color: white;
}

.no-documents-text {
    color: #999;
    font-style: italic;
    font-size: 0.9em;
}

.grid-item.no-documents {
    opacity: 0.6;
    cursor: not-allowed;
}

.grid-item.has-documents {
    cursor: pointer;
}

.grid-item.no-documents .grid-item-content {
    position: relative;
}

/* Estilos del modal */
.documents-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.documents-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close-modal {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.documents-list {
    display: grid;
    gap: 15px;
}

.document-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #f9f9f9;
    transition: background 0.3s ease;
}

.document-item:hover {
    background: #f0f0f0;
}

.document-info {
    flex: 1;
}

.document-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.document-name {
    font-size: 0.85em;
    color: #666;
}

.document-actions {
    display: flex;
    gap: 10px;
}

.view-document-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.3s ease;
}

.view-document-btn:hover {
    background: #218838;
    color: white;
    text-decoration: none;
}

.pdf-icon {
    width: 16px;
    height: 16px;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .insamar-documents-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .modal-header, .modal-body {
        padding: 15px;
    }
    
    .document-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .document-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
