/* ============================================
   BINGO DE IMÁGENES - ESTILOS PRINCIPALES
   ============================================ */

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

:root {
    --primary: #667eea;
    --secondary: #764ba2;
    --accent: #f093fb;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #ef4444;
    --dark: #1a1a2e;
    --light: #ffffff;
    --gray: #6b7280;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--dark) 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: var(--light);
    overflow-x: hidden;
}

/* HEADER */
.header {
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 30px rgba(102, 126, 234, 0.4);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

.header h1 {
    font-size: 3rem;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
    letter-spacing: 4px;
    position: relative;
    z-index: 1;
}

.header .subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-top: 5px;
}

/* NAVEGACIÓN */
.nav-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    background: rgba(0,0,0,0.3);
}

.nav-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.nav-btn.secondary {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 2px solid var(--primary);
}

.nav-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

/* CONTENEDOR PRINCIPAL */
.main-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 30px;
    display: grid;
    grid-template-columns: minmax(500px, 1fr) minmax(400px, 600px);
    gap: 30px;
    align-items: start;
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
    }
}

/* PANEL PRINCIPAL */
.main-panel {
    background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border-radius: 30px;
    padding: 40px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* CONTADOR */
.counter-display {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.counter-box {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 20px 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.counter-box .number {
    font-size: 3rem;
    font-weight: bold;
}

.counter-box .label {
    font-size: 0.9rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* IMAGEN ACTUAL */
.current-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 40px 0;
}

.current-image-wrapper {
    width: 320px;
    height: 320px;
    border-radius: 30px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    padding: 8px;
    box-shadow:
        0 0 60px rgba(240, 147, 251, 0.4),
        0 20px 60px rgba(0,0,0,0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 60px rgba(240, 147, 251, 0.4), 0 20px 60px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 80px rgba(240, 147, 251, 0.6), 0 20px 60px rgba(0,0,0,0.3); }
}

.current-image {
    width: 100%;
    height: 100%;
    border-radius: 24px;
    background: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.current-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: all 0.5s ease;
}

.current-image.new-image img {
    animation: imageReveal 0.8s ease-out;
}

@keyframes imageReveal {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.current-image-number {
    display: none; /* Oculto para vista pública */
}

.current-image-name {
    margin-top: 20px;
    font-size: 2rem;
    font-weight: bold;
    text-align: center;
    color: var(--accent);
    text-shadow: 0 0 20px rgba(240, 147, 251, 0.5);
}

.waiting-message {
    color: var(--gray);
    font-size: 1.5rem;
    text-align: center;
}

/* BOTÓN LLAMAR */
.call-button-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

.call-button {
    padding: 25px 80px;
    font-size: 1.8rem;
    font-weight: bold;
    border: none;
    border-radius: 60px;
    background: linear-gradient(135deg, var(--success), #22c55e);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 3px;
    box-shadow:
        0 10px 40px rgba(74, 222, 128, 0.4),
        inset 0 -4px 0 rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

.call-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.call-button:hover::before {
    left: 100%;
}

.call-button:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow:
        0 20px 60px rgba(74, 222, 128, 0.5),
        inset 0 -4px 0 rgba(0,0,0,0.2);
}

.call-button:active {
    transform: translateY(2px);
    box-shadow:
        0 5px 20px rgba(74, 222, 128, 0.4),
        inset 0 4px 0 rgba(0,0,0,0.2);
}

.call-button:disabled {
    background: var(--gray);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* BOTÓN REINICIAR */
.reset-button {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
}

.reset-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4);
}

/* PANEL LATERAL - HISTORIAL */
.history-panel {
    background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border-radius: 30px;
    padding: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    /* Sin límite de altura - mostrar todo */
    height: fit-content;
}

.history-panel h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--accent);
    font-size: 1.5rem;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.history-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255,255,255,0.1);
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    min-width: 0;
}

.history-item:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

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

.history-item .order-number {
    position: absolute;
    top: 2px;
    left: 2px;
    background: var(--primary);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: bold;
}

.history-item.new {
    animation: historyPop 0.5s ease-out;
}

@keyframes historyPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ============================================
   PÁGINA DE CARTONES
   ============================================ */

.cards-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px;
}

.cards-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.cards-controls input {
    padding: 15px 25px;
    border: 2px solid var(--primary);
    border-radius: 50px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1rem;
    width: 150px;
    text-align: center;
}

.cards-controls input::placeholder {
    color: rgba(255,255,255,0.5);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
}

.bingo-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    color: var(--dark);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.bingo-card-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary);
}

.bingo-card-header h3 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 5px;
}

.bingo-card-header .card-number {
    font-size: 0.9rem;
    color: var(--gray);
}

.bingo-card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.bingo-card-cell {
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #e5e7eb;
    position: relative;
    transition: all 0.3s ease;
}

.bingo-card-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bingo-card-cell .cell-number {
    display: none; /* Oculto para vista pública */
}

.bingo-card-cell .cell-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 20px 5px 5px;
    font-size: 0.6rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.bingo-card-cell:hover .cell-name {
    opacity: 1;
}

/* IMPRESIÓN */
@media print {
    body {
        background: white !important;
    }

    .header, .nav-buttons, .cards-controls {
        display: none !important;
    }

    .bingo-card {
        break-inside: avoid;
        box-shadow: none;
        border: 2px solid #000;
        margin-bottom: 20px;
    }

    .cards-grid {
        display: block;
    }
}

/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: linear-gradient(145deg, #2a2a4a, #1a1a2e);
    border-radius: 30px;
    padding: 40px;
    max-width: 500px;
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal h2 {
    color: var(--warning);
    margin-bottom: 20px;
    font-size: 2rem;
}

.modal p {
    margin-bottom: 30px;
    color: rgba(255,255,255,0.8);
    font-size: 1.1rem;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-btn {
    padding: 15px 40px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn.confirm {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
}

.modal-btn.cancel {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 2px solid var(--gray);
}

.modal-btn:hover {
    transform: translateY(-3px);
}

/* ESTADO VACÍO */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state .icon {
    font-size: 5rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--warning);
}

.empty-state p {
    color: var(--gray);
    max-width: 400px;
    margin: 0 auto;
}

/* CONFETI */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confetti-fall 3s ease-out forwards;
    z-index: 1000;
    pointer-events: none;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ANIMACIÓN DE COMPLETADO */
.game-complete {
    animation: rainbow-border 2s linear infinite;
}

@keyframes rainbow-border {
    0% { border-color: var(--primary); }
    25% { border-color: var(--accent); }
    50% { border-color: var(--success); }
    75% { border-color: var(--warning); }
    100% { border-color: var(--primary); }
}

/* RESPONSIVE */
@media (max-width: 1400px) {
    .history-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
    }

    .history-grid {
        grid-template-columns: repeat(10, 1fr);
    }

    .history-panel {
        order: 2;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .main-container {
        padding: 15px;
    }

    .main-panel {
        padding: 20px;
    }

    .current-image-wrapper {
        width: 250px;
        height: 250px;
    }

    .call-button {
        padding: 20px 50px;
        font-size: 1.3rem;
    }

    .counter-display {
        flex-direction: column;
        align-items: center;
    }

    .history-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

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

/* TOOLTIP */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    bottom: calc(100% + 10px);
}

/* LOADING SPINNER */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* MODAL DE HISTORIAL COMPLETO (ANCHO) */
.history-modal-wide {
    max-width: 95vw;
    width: 95vw;
    max-height: 90vh;
    text-align: left;
    display: flex;
    flex-direction: column;
}

.history-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255,255,255,0.1);
}

.history-modal-header h2 {
    color: var(--accent);
    margin: 0;
    font-size: 1.8rem;
}

.modal-close-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    font-size: 2rem;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close-btn:hover {
    background: var(--danger);
    transform: scale(1.1);
}

.history-modal-count {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--primary);
}

.history-modal-count span {
    font-weight: bold;
    font-size: 1.5rem;
    color: var(--accent);
}

.history-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    overflow-y: auto;
    flex: 1;
    padding: 10px;
    max-height: calc(90vh - 180px);
}

.history-modal-grid .history-item {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255,255,255,0.1);
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.history-modal-grid .history-item:hover {
    transform: scale(1.08);
    z-index: 10;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    border-color: var(--accent);
}

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

.history-modal-grid .history-item .order-number {
    position: absolute;
    top: 5px;
    left: 5px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    min-width: 28px;
    height: 28px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 0 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.history-modal-grid .history-item .item-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    color: white;
    padding: 25px 8px 8px;
    font-size: 0.75rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.history-modal-grid .history-item:hover .item-name {
    opacity: 1;
}

.history-modal-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
    display: none;
}

.history-modal-empty.show {
    display: block;
}

@media (max-width: 768px) {
    .history-modal-wide {
        padding: 20px;
    }

    .history-modal-header h2 {
        font-size: 1.3rem;
    }

    .history-modal-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 8px;
    }

    .history-modal-grid .history-item .order-number {
        min-width: 22px;
        height: 22px;
        font-size: 0.65rem;
    }
}
