/* ── MUNDO LATERO 🌎🥫 — SISTEMA DE DISEÑO PREMIUM ── */

:root {
    /* Paleta de colores premium (Verdes curados, crema y acentos) */
    --color-primary: #1a3a2a;      /* Verde profundo */
    --color-primary-light: #2b5c43;/* Verde intermedio */
    --color-accent: #d4a017;       /* Dorado mate */
    --color-bg: #fdfbf7;           /* Crema claro */
    --color-surface: #ffffff;      /* Blanco */
    --color-ink: #1a231d;          /* Tinta oscura */
    --color-muted: #5e6f65;        /* Gris verdoso */
    --color-border: #e2e8e4;       /* Borde suave */
    --color-highlight: #4caf50;    /* Verde vivo */
    --color-error: #c62828;        /* Rojo */
    
    /* Tipografía */
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Efectos */
    --shadow-sm: 0 2px 8px rgba(26,58,42,0.06);
    --shadow-md: 0 8px 24px rgba(26,58,42,0.08);
    --shadow-lg: 0 16px 40px rgba(26,58,42,0.14);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset e Inicialización ────────────────────────────────────────────────── */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Hero / Header Section ──────────────────────────────────────────────────── */
.hero {
    position: relative;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: #fff;
    padding: 50px 20px;
    text-align: center;
    overflow: hidden;
}

.hero-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.3;
}

.hero-content {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    z-index: 2;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 6vw, 3.8rem);
    font-weight: 900;
    letter-spacing: -1px;
    margin-bottom: 6px;
    text-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

.hero-subtitle {
    font-size: clamp(1rem, 3vw, 1.25rem);
    color: #b9d7c6;
    margin-bottom: 20px;
}

.hero-subtitle strong {
    color: #fff;
    border-bottom: 2px solid var(--color-accent);
}

/* Widget de Última Carga */
.last-can-widget {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.12);
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 0.88rem;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--color-highlight);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(76,175,80,0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(76,175,80,0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(76,175,80,0); }
}

/* ── Layout Principal ──────────────────────────────────────────────────────── */
.museum {
    max-width: 1240px;
    margin: 0 auto;
    padding: 30px 16px 120px;
}

/* ── Pestañas de Navegación ─────────────────────────────────────────────────── */
.tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 15px;
}

.tab-btn {
    border: 0;
    background: transparent;
    color: var(--color-muted);
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--color-primary);
    background-color: rgba(26,58,42,0.05);
}

.tab-btn.active {
    color: #fff;
    background-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.tab-btn-admin {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px dashed var(--color-border);
    color: var(--color-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: bold;
    cursor: pointer;
    margin-left: auto;
    transition: var(--transition);
}

.tab-btn-admin:hover {
    background: var(--color-error);
    color: #fff;
    border-color: var(--color-error);
}

/* ── Filtros y Búsqueda ─────────────────────────────────────────────────────── */
.filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
    background: var(--color-surface);
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.search-box {
    position: relative;
    flex: 2;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    outline: none;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26,58,42,0.1);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-muted);
    font-size: 1.1rem;
}

.selects-group {
    display: flex;
    flex: 3;
    gap: 8px;
    min-width: 300px;
}

.selects-group select {
    flex: 1;
    padding: 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    outline: none;
    background-color: #fff;
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    z-index: 10;
}

.selects-group select:focus {
    border-color: var(--color-primary);
}

/* Chips de Filtro Rápido */
.quick-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-muted);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.chip:hover {
    border-color: var(--color-primary-light);
    color: var(--color-primary-light);
}

.chip.active {
    background: var(--color-primary-light);
    border-color: var(--color-primary-light);
    color: #fff;
}

/* Botón Exportar */
.btn {
    border: 0;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-export {
    background: #2e7d32;
    color: #fff;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 1;
}

.btn-export:hover {
    background: #1b5e20;
    transform: translateY(-1px);
}

.actions-group {
    display: flex;
    justify-content: flex-end;
    flex: 1;
    min-width: 220px;
}
@media (max-width: 768px) {
    .actions-group {
        width: 100%;
        justify-content: center;
        margin-top: 5px;
    }
}

/* ── Resumen Cards (Stats rápidos) ─────────────────────────────────────────── */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.sum-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.sum-card b {
    display: block;
    font-size: 1.8rem;
    font-family: var(--font-display);
    color: var(--color-primary);
    line-height: 1.2;
}

.sum-card small {
    font-size: 0.76rem;
    color: var(--color-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── VISTA 1: ÁLBUM (Cards 3D Flip) ───────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 20px;
}

/* Contenedor Flip 3D */
.flip-container {
    perspective: 1000px;
    height: 350px;
    cursor: pointer;
}

.flip-container:hover .flipper {
    transform: rotateY(180deg);
}

.flipper {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

/* Caras de la Card */
.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.card-back {
    transform: rotateY(180deg);
    background: #fdfdfd;
}

/* Contenido de la Card */
.can-img-wrap {
    flex: 1;
    height: 0;
    background: #f6f8f6;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 12px;
}

.can-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 12px rgba(0,0,0,0.12));
}

.can-num-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--color-primary);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.78rem;
    padding: 3px 9px;
    border-radius: 99px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 5;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 480px) {
    .can-num-badge {
        font-size: 0.68rem;
        padding: 2px 7px;
        top: 6px;
        left: 6px;
    }
}

.can-info {
    padding: 14px;
}

.can-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.can-subtitle {
    font-size: 0.8rem;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-back-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: center;
}

.card-back-info h4 {
    font-family: var(--font-display);
    color: var(--color-primary-light);
    margin-bottom: 8px;
}

.card-back-info p {
    font-size: 0.82rem;
    color: var(--color-ink);
    margin-bottom: 6px;
    border-bottom: 1px dashed var(--color-border);
    padding-bottom: 4px;
}

.card-back-info p strong {
    color: var(--color-muted);
}

/* ── VISTA 2: EXCEL / TABLA ────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    max-height: 70vh; /* Altura maxima de la tabla */
    overflow-y: auto;  /* Habilitar scroll vertical interno */
    position: relative;
}

.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.excel-table th, .excel-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.excel-table th {
    position: sticky;
    top: -1px; /* Congelar arriba */
    z-index: 10;
    background-color: #f5f8f6; /* Fondo solido para el sticky */
    color: var(--color-primary);
    font-family: var(--font-display);
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.excel-table th:hover {
    background-color: #e2ede5;
}

.excel-table th::after {
    content: ' ↕';
    font-size: 0.7rem;
    opacity: 0.5;
}

.excel-table tr:hover td {
    background-color: #fbfdfc;
}

.table-thumb {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
    background: #eee;
}

/* ── VISTA 3: ESTANTERÍA ────────────────────────────────────────────────────── */
.shelves-container {
    background: linear-gradient(to bottom, #2b1d0c, #160e05);
    padding: 30px 16px 10px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 4px solid #3d2a13;
}

.shelf-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    gap: 12px;
    position: relative;
    padding-bottom: 30px;
    margin-bottom: 35px;
}

/* Barda / Baldosa de Madera CSS */
.shelf-row::after {
    content: '';
    position: absolute;
    bottom: 0; left: -16px; right: -16px;
    height: 20px;
    background: linear-gradient(to bottom, #d2a679 0%, #996633 40%, #664422 100%);
    box-shadow: 0 6px 12px rgba(0,0,0,0.6);
    border-radius: 3px;
    border-top: 1px solid #ffcc99;
}

.shelf-can {
    height: 110px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: transform 0.2s;
    z-index: 2;
}

.shelf-can:hover {
    transform: translateY(-8px) scale(1.1);
    z-index: 5;
}

.shelf-can img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(2px 5px 4px rgba(0,0,0,0.5));
}

/* ── VISTA 4: ESTADÍSTICAS ─────────────────────────────────────────────────── */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.stats-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stats-card h3 {
    font-family: var(--font-display);
    color: var(--color-primary);
    margin-bottom: 16px;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 8px;
}

/* Gráfico de Barras */
.bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 30px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.bar-bg {
    height: 12px;
    background: #f0f4f1;
    border-radius: 99px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--color-primary-light);
    border-radius: 99px;
    transition: width 0.8s ease-out;
}

/* ── VISTA 5: JUEGOS ────────────────────────────────────────────────────────── */
.games-hub {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.game-hub-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.game-hub-card:hover {
    transform: translateY(-3px);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.game-hub-card span {
    display: block;
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.game-play-area {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.game-score-board {
    display: flex;
    justify-content: space-around;
    font-weight: 700;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.game-img {
    height: 250px;
    object-fit: contain;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.15));
}

.game-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

/* ── Diálogo Modal Ficha Premium ─────────────────────────────────────────────── */
.premium-modal {
    border: 0;
    border-radius: var(--radius-lg);
    width: min(850px, 95vw);
    box-shadow: var(--shadow-lg);
    outline: none;
    margin: auto;
}

.premium-modal::backdrop {
    background: rgba(14,26,20,0.7);
    backdrop-filter: blur(5px);
}

.modal-card {
    padding: 28px;
    position: relative;
}

.modal-close {
    position: absolute;
    right: 18px;
    top: 18px;
    background: #f0f3f1;
    border: 0;
    font-size: 1.6rem;
    font-weight: 700;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background-color: var(--color-error);
    color: #fff;
}

.detail-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: center;
}

.detail-img-area {
    background: #f5f7f5;
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 380px;
}

.detail-img-area img {
    max-height: 300px;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.15));
}

.btn-toggle-img {
    margin-top: 12px;
    background: var(--color-primary-light);
    color: #fff;
    border: 0;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 600;
}

.detail-info-area h2 {
    font-family: var(--font-display);
    color: var(--color-primary);
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.detail-info-area .detail-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    font-size: 0.85rem;
    border-top: 1px solid var(--color-border);
    padding-top: 14px;
}

.detail-item strong {
    color: var(--color-muted);
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.detail-notes {
    margin-top: 16px;
    background: #fefcf8;
    border-left: 4px solid var(--color-accent);
    padding: 10px 14px;
    font-size: 0.88rem;
    font-style: italic;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ── Spinner e Historial de Carga ────────────────────────────────────────────── */
.loading-state {
    text-align: center;
    padding: 60px 0;
    color: var(--color-muted);
}

.spinner {
    width: 45px;
    height: 45px;
    border: 3.5px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 1s infinite linear;
}

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

/* ── Media Queries ──────────────────────────────────────────────────────────── */
@media (max-width: 850px) {
    .detail-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .detail-img-area {
        height: 280px;
    }
    .detail-img-area img {
        max-height: 210px;
    }
    .selects-group {
        flex-direction: column;
        width: 100%;
    }
    .filters-container {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 580px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .flip-container {
        height: 280px;
    }
    .can-img-wrap {
        height: 180px;
    }
    .can-title {
        font-size: 0.95rem;
    }
    .can-info {
        padding: 8px;
    }
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Carrusel de pestañas deslizable para no perder opciones en el móvil */
    .tabs {
        justify-content: flex-start !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        flex-wrap: nowrap !important;
        padding-bottom: 8px !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important; /* Firefox */
        margin-left: -16px !important;
        margin-right: -16px !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
    .tabs::-webkit-scrollbar {
        display: none !important; /* Chrome/Safari */
    }
    .tab-btn {
        flex-shrink: 0 !important;
        font-size: 0.9rem !important;
        padding: 8px 14px !important;
    }
}