/* ========================================
   CATEGORY PAGE STYLES
   ======================================== */

/* Category Header */
.gfb-category-header {
    display: flex;
    align-items: center;
    gap: var(--gfb-space-6);
    margin-bottom: var(--gfb-space-8);
    padding: var(--gfb-space-6);
    background: var(--gfb-card);
    border: 1px solid var(--gfb-gray-800);
    border-radius: var(--gfb-radius-2xl);
}

.gfb-category-header-icon {
    font-size: 4rem;
    line-height: 1;
}

.gfb-category-header-content {
    flex: 1;
}

.gfb-category-title {
    font-family: var(--gfb-font-heading);
    font-size: var(--gfb-text-4xl);
    font-weight: 800;
    margin-bottom: var(--gfb-space-2);
}

.gfb-category-desc {
    color: var(--gfb-gray-400);
    font-size: var(--gfb-text-lg);
}

/* Casino Gold Header */
.gfb-category-header-gold {
    border-color: rgba(255, 215, 0, 0.3);
    background: linear-gradient(135deg, var(--gfb-card) 0%, rgba(255, 215, 0, 0.05) 100%);
}

.gfb-category-header-gold .gfb-category-title {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Category Search */
.gfb-category-search {
    display: flex;
    gap: var(--gfb-space-3);
    margin-bottom: var(--gfb-space-8);
    max-width: 600px;
}

.gfb-category-search .gfb-input {
    flex: 1;
}

.gfb-category-search .gfb-btn {
    white-space: nowrap;
}

/* Category GIF Grid */
.gfb-category-gif-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--gfb-space-4);
    margin-bottom: var(--gfb-space-8);
}

.gfb-category-gif-item {
    position: relative;
    aspect-ratio: 1;
    background: var(--gfb-card);
    border: 1px solid var(--gfb-gray-800);
    border-radius: var(--gfb-radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--gfb-transition-fast);
}

.gfb-category-gif-item:hover {
    border-color: var(--gfb-primary);
    transform: scale(1.02);
}

/* GIF Image with Fade-In */
.gfb-category-gif-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gfb-category-gif-img.loaded {
    opacity: 1;
}

/* ========================================
   SKELETON LOADING
   ======================================== */

/* Skeleton State */
.gfb-category-gif-item.skeleton {
    cursor: default;
    pointer-events: none;
}

.gfb-category-gif-item.skeleton:hover {
    transform: none;
    border-color: var(--gfb-gray-800);
}

/* Skeleton Shimmer Animation */
.gfb-skeleton-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        var(--gfb-gray-800) 0%,
        var(--gfb-gray-700) 20%,
        var(--gfb-gray-600) 40%,
        var(--gfb-gray-700) 60%,
        var(--gfb-gray-800) 80%,
        var(--gfb-gray-800) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Hide shimmer when loaded */
.gfb-category-gif-item:not(.skeleton) .gfb-skeleton-shimmer {
    display: none;
}

/* Error State */
.gfb-category-gif-item.error {
    background: var(--gfb-gray-900);
}

.gfb-category-gif-item.error .gfb-category-gif-img {
    opacity: 0.5;
    object-fit: none;
    padding: 25%;
}

.gfb-category-gif-item.error .gfb-category-gif-overlay {
    display: none;
}

/* ========================================
   GIF OVERLAY & ACTIONS
   ======================================== */

.gfb-category-gif-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gfb-space-3);
    opacity: 0;
    transition: opacity var(--gfb-transition-fast);
}

.gfb-category-gif-item:hover .gfb-category-gif-overlay {
    opacity: 1;
}

.gfb-gif-action-btn {
    width: 44px;
    height: 44px;
    background: var(--gfb-gray-800);
    border: 1px solid var(--gfb-gray-700);
    border-radius: var(--gfb-radius-md);
    color: var(--gfb-white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--gfb-transition-fast);
}

.gfb-gif-action-btn:hover {
    background: var(--gfb-primary);
    border-color: var(--gfb-primary);
    transform: scale(1.1);
}

/* Success State (Copy) */
.gfb-gif-action-btn.success {
    background: var(--gfb-success);
    border-color: var(--gfb-success);
}

/* Loading State (Download) */
.gfb-gif-action-btn.loading {
    pointer-events: none;
    position: relative;
}

.gfb-gif-action-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: var(--gfb-white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.gfb-gif-action-btn.loading svg {
    opacity: 0;
}

/* ========================================
   LOADING INDICATOR
   ======================================== */

.gfb-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gfb-space-3);
    padding: var(--gfb-space-8);
    color: var(--gfb-gray-400);
}

.gfb-loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gfb-gray-700);
    border-top-color: var(--gfb-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========================================
   LOAD MORE & INFINITE SCROLL
   ======================================== */

.gfb-load-more-container {
    display: flex;
    justify-content: center;
    margin-bottom: var(--gfb-space-8);
}

/* Infinite Scroll Indicator */
.gfb-infinite-loading {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gfb-space-2);
    padding: var(--gfb-space-6);
    color: var(--gfb-gray-400);
    font-size: var(--gfb-text-sm);
}

/* ========================================
   ERROR HANDLING
   ======================================== */

.gfb-no-results,
.gfb-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--gfb-space-8);
    color: var(--gfb-gray-400);
}

.gfb-error {
    color: var(--gfb-error);
}

.gfb-error-container {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gfb-space-4);
    padding: var(--gfb-space-8);
}

.gfb-retry-btn {
    min-width: 150px;
}

/* ========================================
   MODAL ENHANCEMENTS
   ======================================== */

.gfb-modal.loading .gfb-modal-content img {
    opacity: 0;
}

.gfb-modal.loading .gfb-modal-content::before {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 4px solid var(--gfb-gray-700);
    border-top-color: var(--gfb-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ========================================
   RELATED CATEGORIES
   ======================================== */

.gfb-related-categories {
    margin-top: var(--gfb-space-12);
    padding-top: var(--gfb-space-8);
    border-top: 1px solid var(--gfb-gray-800);
}

.gfb-related-categories .gfb-section-title {
    margin-bottom: var(--gfb-space-6);
}

.gfb-related-categories .gfb-gif-categories {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gfb-space-3);
    justify-content: center;
}

.gfb-related-categories .gfb-gif-category {
    min-width: 100px;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .gfb-category-header {
        flex-direction: column;
        text-align: center;
    }

    .gfb-category-header-icon {
        font-size: 3rem;
    }

    .gfb-category-title {
        font-size: var(--gfb-text-2xl);
    }

    .gfb-category-desc {
        font-size: var(--gfb-text-base);
    }

    .gfb-category-search {
        flex-direction: column;
        max-width: 100%;
    }

    .gfb-category-gif-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: var(--gfb-space-2);
    }

    /* Touch-friendly overlay (always visible on mobile) */
    .gfb-category-gif-overlay {
        opacity: 0;
        background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
        align-items: flex-end;
        padding-bottom: var(--gfb-space-2);
    }

    .gfb-category-gif-item:active .gfb-category-gif-overlay {
        opacity: 1;
    }

    .gfb-gif-action-btn {
        width: 36px;
        height: 36px;
    }

    .gfb-related-categories .gfb-gif-categories {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
    }

    .gfb-related-categories .gfb-gif-category {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .gfb-category-gif-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .gfb-related-categories .gfb-gif-categories {
        grid-template-columns: repeat(3, 1fr);
    }

    .gfb-gif-action-btn {
        width: 32px;
        height: 32px;
    }

    .gfb-gif-action-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .gfb-skeleton-shimmer {
        animation: none;
        background: var(--gfb-gray-700);
    }

    .gfb-loading-spinner,
    .gfb-gif-action-btn.loading::after {
        animation: none;
    }

    .gfb-category-gif-img {
        transition: none;
    }

    .gfb-category-gif-item {
        transition: none;
    }
}

/* ========================================
   GIF TEXT OVERLAY EDITOR
   ======================================== */

.gfb-editor-modal .gfb-modal-backdrop {
    background: rgba(0, 0, 0, 0.9);
}

.gfb-editor-container {
    position: relative;
    width: 90vw;
    max-width: 900px;
    max-height: 90vh;
    background: var(--gfb-card);
    border: 1px solid var(--gfb-gray-800);
    border-radius: var(--gfb-radius-2xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gfb-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--gfb-space-4) var(--gfb-space-6);
    border-bottom: 1px solid var(--gfb-gray-800);
}

.gfb-editor-title {
    font-family: var(--gfb-font-heading);
    font-size: var(--gfb-text-xl);
    font-weight: 700;
}

.gfb-editor-content {
    display: grid;
    grid-template-columns: 1fr 320px;
    flex: 1;
    overflow: hidden;
}

/* Editor Preview */
.gfb-editor-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--gfb-space-6);
    background: var(--gfb-gray-900);
    overflow: hidden;
}

.gfb-editor-canvas-container {
    position: relative;
    max-width: 100%;
    max-height: 60vh;
}

.gfb-editor-canvas-container img {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: var(--gfb-radius-md);
}

/* Text Overlays */
.gfb-editor-text-top,
.gfb-editor-text-bottom {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
    word-wrap: break-word;
    padding: 0 10px;
    pointer-events: none;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
}

.gfb-editor-text-top {
    top: 10px;
}

.gfb-editor-text-bottom {
    bottom: 10px;
}

/* Editor Controls */
.gfb-editor-controls {
    padding: var(--gfb-space-6);
    display: flex;
    flex-direction: column;
    gap: var(--gfb-space-4);
    overflow-y: auto;
    border-left: 1px solid var(--gfb-gray-800);
}

.gfb-editor-color-row,
.gfb-editor-position-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gfb-space-4);
}

.gfb-editor-position-row {
    margin-top: calc(-1 * var(--gfb-space-2));
    margin-bottom: var(--gfb-space-2);
}

.gfb-editor-position-row .gfb-label {
    font-size: var(--gfb-text-xs);
    color: var(--gfb-gray-400);
}

.gfb-editor-position-row .gfb-range {
    height: 6px;
}

.gfb-editor-controls .gfb-color-input {
    width: 100%;
    height: 44px;
    padding: 4px;
    background: var(--gfb-gray-800);
    border: 1px solid var(--gfb-gray-700);
    border-radius: var(--gfb-radius-md);
    cursor: pointer;
}

.gfb-editor-controls .gfb-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.gfb-editor-controls .gfb-color-input::-webkit-color-swatch {
    border: none;
    border-radius: var(--gfb-radius-sm);
}

.gfb-editor-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gfb-space-3);
    margin-top: auto;
    padding-top: var(--gfb-space-4);
    border-top: 1px solid var(--gfb-gray-800);
}

.gfb-editor-hint {
    font-size: var(--gfb-text-xs);
    color: var(--gfb-gray-500);
    text-align: center;
}

/* Progress Bar */
.gfb-editor-progress {
    width: 100%;
    height: 6px;
    background: var(--gfb-gray-800);
    border-radius: 3px;
    overflow: hidden;
    margin-top: var(--gfb-space-2);
}

.gfb-editor-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gfb-primary), var(--gfb-accent));
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

/* Spinner Animation für Download Button */
.gfb-spinner {
    animation: spin 1s linear infinite;
}

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

/* Download Button Loading State */
#gfb-editor-download.loading {
    opacity: 0.8;
    cursor: wait;
}

/* Edit Button in Overlay */
.gfb-gif-edit {
    background: var(--gfb-accent);
    border-color: var(--gfb-accent);
    color: var(--gfb-dark);
}

.gfb-gif-edit:hover {
    background: var(--gfb-accent-hover);
    border-color: var(--gfb-accent-hover);
}

/* Responsive Editor */
@media (max-width: 768px) {
    .gfb-editor-container {
        width: 95vw;
        max-height: 95vh;
    }

    .gfb-editor-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .gfb-editor-preview {
        padding: var(--gfb-space-4);
        max-height: 40vh;
    }

    .gfb-editor-canvas-container {
        max-height: 35vh;
    }

    .gfb-editor-canvas-container img {
        max-height: 35vh;
    }

    .gfb-editor-controls {
        border-left: none;
        border-top: 1px solid var(--gfb-gray-800);
        padding: var(--gfb-space-4);
        max-height: 50vh;
    }

    .gfb-editor-actions {
        grid-template-columns: 1fr;
    }
}
