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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background: #667eea; /* Фоллбэк */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    background: white; /* Фоллбэк для старых браузеров */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); /* Safari */
    padding: 20px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    position: -webkit-sticky; /* Safari */
    top: 0;
    z-index: 100;
}

.header h1 {
    text-align: center;
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 2.5rem;
    font-weight: 300;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.auto-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.folder-info {
    font-weight: 500;
    color: #4a5568;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}

.refresh-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.refresh-btn:active {
    transform: translateY(0);
}

.stats {
    display: flex;
    gap: 20px;
    font-weight: 500;
    color: #4a5568;
}

.main {
    padding: 40px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: white;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    margin: 20px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.gallery {
    display: grid;
    display: -ms-grid; /* IE 10-11 */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    -ms-grid-columns: 1fr 20px 1fr 20px 1fr 20px 1fr; /* IE 10-11 фоллбэк */
    gap: 20px;
    grid-gap: 20px; /* Старый синтаксис */
    margin-bottom: 40px;
}

/* Фоллбэк для браузеров без поддержки Grid */
@supports not (display: grid) {
    .gallery {
        display: flex;
        flex-wrap: wrap;
        margin: -15px;
    }

    .animation-pair {
        flex: 1 1 400px;
        margin: 15px;
        min-width: 400px;
    }
}

.animation-pair,
.animation-item-single {
    background: white; /* Фоллбэк */
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); /* Safari */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    -webkit-transition: transform 0.3s ease, box-shadow 0.3s ease; /* Safari */
    cursor: pointer;
}

.animation-item-single {
    text-align: center;
    padding: 15px;
}

.animation-pair:hover,
.animation-item-single:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.pair-header,
.animation-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.pair-header h3,
.animation-header h3 {
    color: #4a5568;
    font-size: 1.1rem;
    margin-bottom: 5px;
    word-break: break-word;
}

.pair-header .folder-path,
.animation-header .folder-path {
    color: #718096;
    font-size: 0.8rem;
    font-style: italic;
    margin-bottom: 5px;
}

.file-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
}

.file-type.json {
    background: #e6fffa;
    color: #234e52;
    border: 1px solid #81e6d9;
}

.file-type.lottie {
    background: #fef5e7;
    color: #744210;
    border: 1px solid #f6ad55;
}

.animations-container {
    display: grid;
    display: -ms-grid; /* IE 10-11 */
    grid-template-columns: 1fr 1fr;
    -ms-grid-columns: 1fr 20px 1fr; /* IE 10-11 */
    gap: 20px;
    grid-gap: 20px; /* Старый синтаксис */
}

/* Фоллбэк для браузеров без Grid */
@supports not (display: grid) {
    .animations-container {
        display: flex;
        justify-content: space-between;
    }

    .animation-item {
        flex: 1;
        margin: 0 10px;
    }
}

.animation-item {
    text-align: center;
}

.animation-preview {
    width: 180px;
    height: 180px;
    margin: 0 auto 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.animation-item-single .animation-preview {
    width: 200px;
    height: 200px;
}

.animation-preview > *,
.animation-preview canvas,
.animation-preview svg,
.animation-preview dotlottie-player {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    display: block !important;
}

.animation-preview {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.animation-preview:hover {
    transform: scale(1.05);
}

.animation-preview canvas,
.animation-preview svg,
.animation-preview dotlottie-player {
    max-width: 100%;
    max-height: 100%;
}

.placeholder,
.error-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #a0aec0;
    font-size: 0.9rem;
    text-align: center;
}

.error-placeholder {
    color: #e53e3e;
    font-size: 0.8rem;
}

.animation-info h4 {
    color: #4a5568;
    margin-bottom: 8px;
    font-size: 1rem;
}

.file-size {
    color: #718096;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.file-name {
    color: #a0aec0;
    font-size: 0.8rem;
    word-break: break-all;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
}

.pagination button {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #4a5568;
    transition: all 0.3s ease;
}

.pagination button:hover:not(:disabled) {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pagination button:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none;
    background: #e2e8f0 !important;
    color: #a0aec0 !important;
}

#pageInfo {
    color: white;
    font-weight: 500;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

/* Modal styles */
.modal,
.animation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

.modal-content,
.modal-content-large {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 1001;
}

.modal-content-large {
    max-width: 80vw;
    max-height: 80vh;
    min-width: 600px;
    min-height: 500px;
}

.close,
.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #718096;
    background: none;
    border: none;
    padding: 5px;
    line-height: 1;
}

.close:hover,
.close-btn:hover {
    color: #4a5568;
    background: #f7fafc;
    border-radius: 50%;
}

.modal-body {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    align-items: start;
}

.animation-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.modal-animation {
    width: 250px;
    height: 250px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7fafc;
}

.animation-info h3 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.file-details {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.file-detail {
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
}

.file-detail h4 {
    color: #4a5568;
    margin-bottom: 10px;
}

.file-detail p {
    color: #718096;
    margin-bottom: 5px;
}

/* Стили для увеличенной анимации */
.modal-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.modal-header h2 {
    color: #4a5568;
    font-size: 1.5rem;
    margin: 0;
    word-break: break-word;
}

.modal-body-large {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    align-items: start;
}

.animation-preview-large {
    width: 100%;
    height: 400px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.animation-preview-large > *,
.animation-preview-large canvas,
.animation-preview-large svg,
.animation-preview-large dotlottie-player {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
}

.animation-details {
    background: #f7fafc;
    padding: 20px;
    border-radius: 12px;
}

.animation-details p {
    margin-bottom: 10px;
    color: #4a5568;
}

.animation-details strong {
    color: #2d3748;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.success-notification {
    animation: slideIn 0.3s ease;
}

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

    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .auto-info {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .gallery {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 10px;
    }

    .animation-pair {
        padding: 15px;
    }

    .animations-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .animation-preview {
        width: 120px;
        height: 120px;
    }

    .modal-body {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .modal-content {
        margin: 20px;
        padding: 20px;
    }

    .pagination {
        flex-direction: column;
        gap: 15px;
    }

    .pagination button {
        padding: 15px 20px;
        font-size: 1.1rem;
    }

    .modal-content-large {
        max-width: 95vw;
        max-height: 95vh;
        min-width: auto;
        padding: 20px;
    }

    .modal-body-large {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .animation-preview-large {
        height: 300px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 15px;
    }

    .header h1 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }

    .main {
        padding: 20px 10px;
    }

    .animation-pair {
        padding: 12px;
    }

    .animation-preview {
        width: 100px;
        height: 100px;
    }

    .pair-header h3 {
        font-size: 1rem;
    }

    .stats {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}
