/* Modern Design System */
:root {
    --bg-color: #cd5c5c;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --accent-color: #cd5c5c;
    /* Match background */
    --accent-hover: #b91c1c;
    --success-color: #059669;
    --border-color: #e5e7eb;
    --gradient-bg: radial-gradient(circle at top right, #ff8fa3, #cd5c5c 40%);
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.2);
    --font-main: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    background-image: var(--gradient-bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
    color: white;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 0.5rem;
    color: white;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: white;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
}

/* Upload Section */
.upload-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeInUp 0.8s ease-out;
}

.drop-zone {
    width: 100%;
    max-width: 600px;
    height: 300px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: white;
    background: #ffffff;
    transform: translateY(-2px);
}

.drop-content {
    text-align: center;
    color: var(--text-secondary);
}

.drop-content svg {
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.drop-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Editor Layout */
.editor-section {
    flex: 1;
    animation: fadeIn 0.5s ease-out;
}

.editor-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
}

@media (max-width: 900px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

/* Panels */
.images-panel,
.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.images-panel {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    height: fit-content;
}

.badge {
    background: var(--border-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Scrollbar */
.image-grid::-webkit-scrollbar {
    width: 6px;
}

.image-grid::-webkit-scrollbar-track {
    background: transparent;
}

.image-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
    background: #f3f4f6;
}

.image-item:hover {
    transform: scale(1.02);
    border-color: var(--accent-color);
}

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

.image-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

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

/* Settings Card */
.settings-panel>div {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.range-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    appearance: none;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
}

.range-value {
    min-width: 50px;
    text-align: right;
    font-family: monospace;
    font-size: 1rem;
}

.help-text {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.5rem;
    font-family: var(--font-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
}

.btn-text:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
}

.btn-success {
    background: var(--success-color);
    color: white;
    text-decoration: none;
}

.btn-success:hover {
    background: #059669;
}

.btn-full {
    width: 100%;
}

/* Result Section */
.result-card {
    margin-top: 2rem;
    animation: fadeIn 0.5s ease-out;
}

.preview-container {
    position: relative;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
}

#gifPreview {
    max-width: 100%;
    max-height: 400px;
    display: block;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

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

.spinner-large {
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 5px solid var(--accent-color);
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

footer {
    text-align: center;
    margin-top: auto;
    padding-top: 2rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

[hidden] {
    display: none !important;
}