* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', serif;
    background: url('https://pub-da18fca09c2747d284650d55b5760e9e.r2.dev/fondodepantalla/background.jpg') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    overflow-x: auto;
}

.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    min-height: 100vh;
}

/* Título Principal */
.main-title {
    text-align: center;
    color: #d4af37;
    font-size: clamp(1.8rem, 4vw, 3rem);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    margin-bottom: 30px;
    line-height: 1.3;
    border-bottom: 3px solid #8b0000;
    padding-bottom: 20px;
}

/* Sección Superior - Carrusel e Imágenes Laterales */
.top-section {
    display: flex;
    justify-content: center;
    align-items: stretch;
    margin-bottom: 40px;
    gap: 20px;
    min-height: 400px;
}

/* Columnas Laterales */
.side-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 150px;
}

.side-link {
    flex: 1;
    border: 3px solid #d4af37;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.side-link:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.4);
}

.side-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Carrusel Central */
.carousel-container {
    flex: 1;
    max-width: 800px;
    position: relative;
    border: 3px solid #d4af37;
    border-radius: 15px;
    overflow: hidden;
    background: #000;
}

.carousel {
    width: 100%;
    height: 400px;
    position: relative;
    overflow: hidden;
}

.carousel img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.carousel img.active {
    opacity: 1;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.7);
    color: #d4af37;
    border: 2px solid #d4af37;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    transition: all 0.3s ease;
    z-index: 10;
}

.carousel-nav:hover {
    background: #d4af37;
    color: #000;
    transform: translateY(-50%) scale(1.1);
}

.carousel-nav.prev {
    left: 15px;
}

.carousel-nav.next {
    right: 15px;
}

/* Calendario de Eventos */
.calendar-section {
    margin-bottom: 40px;
    background: rgba(0,0,0,0.8);
    border: 2px solid #d4af37;
    border-radius: 15px;
    padding: 25px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-title {
    color: #d4af37;
    font-size: 1.8rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.calendar-controls {
    display: flex;
    gap: 15px;
}

.calendar-btn {
    background: linear-gradient(45deg, #8b0000, #d4af37);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    font-size: 14px;
}

.calendar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.4);
}

.calendar-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    overflow-x: auto;
    padding: 10px 0;
    touch-action: pan-x;
}

.month-calendar {
    min-width: 350px;
    background: rgba(255,255,255,0.95);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.month-title {
    text-align: center;
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: #8b0000;
    font-weight: bold;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-bottom: 10px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s ease;
    position: relative;
}

.calendar-day.header {
    background: #8b0000;
    color: white;
    cursor: default;
    font-size: 12px;
}

.calendar-day.normal {
    background: white;
    color: #333;
    border: 1px solid #ddd;
}

.calendar-day.event-single {
    background: #ffeb3b;
    color: #333;
    border: 2px solid #ffc107;
}

.calendar-day.event-multiple {
    background: #ff9800;
    color: white;
    border: 2px solid #f57c00;
}

.calendar-day:not(.header):hover {
    transform: scale(1.1);
    z-index: 5;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

/* COMIENZO DE LA ZONA DE ESTILOS DEL GRID */

/* 1. Ajuste y Centrado de la Cuadrícula */
#links-grid {
    width: 100%; 
    max-width: none;
    margin-left: auto; 
    margin-right: auto;
    padding-left: 0; 
    padding-right: 0;
}

/* 2. Estilos de la imagen y el título (cambios anteriores) */
.grid-item .link {
    display: flex;
    flex-direction: column; 
    height: 100%; 
    width: 100%;
    box-sizing: border-box; 
    overflow: hidden;
}

.grid-item .link img {
    width: 100%;
    height: calc(100% - 25px); /* Altura de la imagen - Altura del título */
    object-fit: cover; 
    border-radius: 5px 5px 0 0; 
}

.grid-item .link .link-title {
    height: 25px;
    min-height: 25px;
    line-height: 25px;
    text-align: center;
}

/* FIN DE LA ZONA DE ESTILOS DEL GRID */

/* Grid de Enlaces Inferior */
.links-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 15px;
    max-width: 1200px;
    margin: 0 auto;
}

/* 1. Contenedor del enlace: Asegura un tamaño definido y usa Flexbox para organizar imagen y título */
.grid-item .link {
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    width: 100%;
    box-sizing: border-box; 
    overflow: hidden; 
}

.grid-item.link {
    background: linear-gradient(135deg, #8b0000, #d4af37);
    border: 3px solid #d4af37;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.grid-item.link:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.4);
}

/* 2. Imagen: Llenar el ancho y alto disponible (restante después del título) */
.grid-item .link img {
    width: 100%; 
    height: calc(100% - 25px); 
    object-fit: cover; 
    border-radius: 5px 5px 0 0; 
}

/* 3. Título: Define el espacio inferior que debe quedar libre */
.grid-item .link .link-title {
    height: 25px; 
    min-height: 25px;
    line-height: 25px; 
    text-align: center;
    background-color: rgba(0, 0, 0, 0.5); 
    color: white;
    width: 100%;
}

.grid-item.empty {
    background: transparent;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.95);
    color: #d4af37;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    max-width: 300px;
    border: 2px solid #d4af37;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tooltip.show {
    opacity: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
    margin: 5% auto;
    padding: 0;
    border: 3px solid #d4af37;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-header {
    background: linear-gradient(45deg, #8b0000, #d4af37);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.4rem;
    font-weight: bold;
}

.modal-controls {
    display: flex;
    gap: 10px;
}

.modal-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.modal-btn.close {
    background: #dc3545;
    color: white;
}

.modal-btn.minimize {
    background: #ffc107;
    color: #333;
}

.modal-btn.maximize {
    background: #28a745;
    color: white;
}

.modal-btn:hover {
    transform: scale(1.1);
}

.modal-body {
    padding: 25px;
    color: #d4af37;
    line-height: 1.6;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-body h3 {
    color: #d4af37;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.modal-body p {
    margin-bottom: 12px;
}

.modal-body strong {
    color: #fff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-container {
        padding: 10px;
    }

    .top-section {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .side-column {
        flex-direction: row;
        width: 100%;
        max-width: 400px;
    }

    .calendar-container {
        flex-direction: column;
    }

    .month-calendar {
        min-width: 100%;
    }

    .links-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    .carousel {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .links-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.6s ease-out;
}

/* Estados de carga */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    color: #d4af37;
    font-size: 1.2rem;
}

.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #d4af37;
    border-top: 3px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 15px;
}

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

/* Estilos para el intercambio de elementos del grid */
.grid-item.link.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    z-index: 1000;
    transition: none;
}

.grid-item.drop-target {
    background: rgba(0, 255, 0, 0.2) !important;
    border: 3px dashed #00ff00 !important;
    animation: dropPulse 1s infinite;
    transform: scale(1.05);
}

@keyframes dropPulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(0, 255, 0, 0.7);
        border-color: #00ff00;
    }
    50% { 
        box-shadow: 0 0 0 15px rgba(0, 255, 0, 0);
        border-color: #66ff66;
    }
}

/* Feedback de intercambio */
.swap-feedback {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.9);
    color: #00ff00;
    padding: 15px 25px;
    border-radius: 10px;
    border: 2px solid #00ff00;
    z-index: 3000;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s ease;
}

.swap-feedback.show {
    opacity: 1;
    transform: translateX(0);
}

/* Mejorar el cursor durante el arrastre */
.grid-item.link[draggable="true"] {
    cursor: grab;
}

.grid-item.link[draggable="true"]:active {
    cursor: grabbing;
}

/* Efecto hover mejorado para elementos arrastrables */
.grid-item.link:hover:not(.dragging) {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.4);
}

/* 3. Agregar CSS para el botón de reset */
.reset-feedback {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.9);
    color: #ff6b6b;
    padding: 15px 25px;
    border-radius: 10px;
    border: 2px solid #ff6b6b;
    z-index: 3000;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transform: translateX(-100px);
    transition: all 0.3s ease;
}

.reset-feedback.show {
    opacity: 1;
    transform: translateX(0);
}