/* ============================================
   MÄRKA - Mängukaartide generaator stiilid
   ============================================ */

/* Sammude konteinerid */
.step-container {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Kaardi kuju valik */
.card-shape-btn {
    transition: all 0.2s ease;
}

.card-shape-btn.is-selected {
    background-color: var(--accent-color, #00d1b2) !important;
    border-color: var(--accent-color, #00d1b2) !important;
    color: white !important;
}

.card-shape-btn:not(.is-selected):hover {
    background-color: var(--bg-hover, #f5f5f5);
}

/* Drop Zone */
.drop-zone {
    border: 3px dashed var(--border-color, #dbdbdb);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--bg-secondary, #ffffff);
    cursor: pointer;
}

.drop-zone:hover {
    border-color: var(--accent-color, #00d1b2);
    background: var(--bg-hover, #f9f9f9);
}

.drop-zone.drag-over {
    border-color: var(--accent-color, #00d1b2);
    background: rgba(0, 209, 178, 0.1);
    transform: scale(1.01);
}

.drop-zone-content {
    pointer-events: none;
}

.drop-zone-content .button {
    pointer-events: auto;
}

/* Piltide ruudustik */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
}

.image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-card, 0 2px 4px rgba(0,0,0,0.1));
    background: var(--bg-card, white);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover, 0 4px 8px rgba(0,0,0,0.15));
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.image-item .delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 56, 96, 0.9);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.image-item:hover .delete-btn {
    opacity: 1;
}

.image-item .delete-btn:hover {
    background: #ff3860;
    transform: scale(1.1);
}

.image-item .image-number {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Üleliigsed pildid (ei kasutata kaartidel) */
.image-item.is-excess {
    opacity: 0.4;
    filter: grayscale(50%);
}

.image-item.is-excess::after {
    content: 'Ei kasutata';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
}

.image-item.is-excess .image-number {
    background: rgba(180, 0, 0, 0.8);
}

.image-item.is-excess:hover {
    opacity: 0.7;
}

/* Kaartide eelvaade */
.cards-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    padding: 1rem;
    background: var(--bg-hover, #f9f9f9);
    border-radius: 12px;
    max-height: 70vh;
    overflow-y: auto;
}

.card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.card-number {
    font-size: 0.85rem;
    color: var(--text-muted, #7a7a7a);
    font-weight: 500;
}

/* Mängukaart */
.game-card {
    position: relative;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.game-card.circle {
    border-radius: 50%;
}

.game-card.square {
    border-radius: 8px;
}

/* Kaardi sümbol */
.card-symbol {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-symbol img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Progress modal */
.modal .box {
    min-width: 300px;
    background: var(--bg-card, white);
    color: var(--text-primary, #363636);
}

.progress-text {
    margin-top: 1rem;
    color: var(--text-secondary, #4a4a4a);
}

/* Regenereerimise animatsioon */
.cards-preview.regenerating {
    animation: regenerate 0.3s ease;
}

@keyframes regenerate {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}

/* ============================================
   TUME TEEMA (Dark Mode)
   ============================================ */

[data-theme="dark"] .drop-zone {
    border-color: var(--border-color);
    background: var(--bg-card);
}

[data-theme="dark"] .drop-zone:hover {
    border-color: var(--accent-color);
    background: var(--bg-hover);
}

[data-theme="dark"] .drop-zone.drag-over {
    background: rgba(34, 211, 238, 0.1);
}

[data-theme="dark"] .image-item {
    background: var(--bg-card);
}

[data-theme="dark"] .cards-preview {
    background: var(--bg-secondary);
}

[data-theme="dark"] .game-card {
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Kaardi number eelvaates */
[data-theme="dark"] .card-number {
    color: var(--text-secondary, #a1a1aa);
}

/* Genereeritud kaartide arv */
#generatedCardCount {
    color: var(--accent-color, #00d1b2);
}

[data-theme="dark"] #generatedCardCount {
    color: var(--accent-color, #22d3ee);
}

[data-theme="dark"] .card-shape-btn:not(.is-selected) {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .card-shape-btn:not(.is-selected):hover {
    background-color: var(--bg-hover);
}

/* ============================================
   RESPONSIIVSUS (Mobiil)
   ============================================ */

@media screen and (max-width: 768px) {
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 0.75rem;
    }
    
    .drop-zone {
        padding: 2rem 1rem;
    }
    
    .cards-preview {
        gap: 1rem;
        padding: 0.75rem;
        max-height: 60vh;
    }
    
    .game-card {
        max-width: calc(45vw - 1rem);
        max-height: calc(45vw - 1rem);
    }
    
    /* Nuppude paigutus mobiilis */
    .buttons.is-flex-wrap-wrap {
        justify-content: center;
    }
    
    .buttons.is-flex-wrap-wrap .button {
        flex: 1 1 auto;
        min-width: 140px;
    }
    
    /* Flexbox paigutus mobiilis vertikaalne */
    .is-flex-direction-column-mobile {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .is-flex-direction-column-mobile > div {
        text-align: center;
    }
    
    .is-flex-direction-column-mobile .button {
        width: 100%;
    }
    
    /* Kaardi kuju nupud mobiilis */
    .is-centered-mobile {
        justify-content: center;
    }
    
    /* Info sektsiooni tekst */
    #infoBox .content {
        font-size: 0.95rem;
    }
    
    /* Pealkirjad väiksemad mobiilis */
    .title.is-2 {
        font-size: 1.75rem;
    }
    
    .subtitle.is-5 {
        font-size: 1rem;
    }
    
    /* Level elemendid üksteise all */
    .level {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    
    .level-left,
    .level-right {
        justify-content: center;
        text-align: center;
    }
}

@media screen and (max-width: 480px) {
    .image-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .game-card {
        max-width: calc(50vw - 1.5rem);
        max-height: calc(50vw - 1.5rem);
    }
    
    /* Väiksemad nupud */
    .button.is-medium {
        font-size: 0.9rem;
        padding: 0.5em 1em;
    }
    
    .buttons.is-flex-wrap-wrap .button {
        min-width: 120px;
        font-size: 0.85rem;
    }
}

/* ============================================
   PRINT STIILID
   ============================================ */

@media print {
    .section > .container > .box:last-child,
    .buttons,
    .level,
    nav,
    .notification,
    #infoBox {
        display: none !important;
    }
    
    .cards-preview {
        max-height: none;
        overflow: visible;
        background: none;
        padding: 0;
    }
    
    .game-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .card-wrapper {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ============================================
   BULMA ÜLEKIRJUTUSED
   ============================================ */

.notification.is-info.is-light {
    background-color: #f0f9ff;
    color: #0c4a6e;
}

/* Progress bar animation */
.progress::-webkit-progress-value {
    transition: width 0.3s ease;
}

/* Info box styling */
.box .content ol {
    margin-left: 1.5rem;
}

.box .content ol li {
    margin-bottom: 0.5rem;
}

/* Mobiilil kustuta nupp alati nähtav */
@media (hover: none) and (pointer: coarse) {
    .image-item .delete-btn {
        opacity: 0.8;
    }
}
