/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #10b981;
    --error-color: #ef4444;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border-color: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(180deg, var(--surface) 0%, transparent 100%);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.mode-btn svg {
    width: 24px;
    height: 24px;
}

.mode-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Mode Sections */
.mode-section {
    display: none;
}

.mode-section.active {
    display: block;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.upload-area svg {
    width: 48px;
    height: 48px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.upload-area p {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.browse-link {
    color: var(--primary-color);
    text-decoration: underline;
}

.file-types {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Editor */
.editor {
    margin-top: 1.5rem;
}

.editor.hidden {
    display: none;
}

/* Video Preview */
.preview-container {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

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

/* Trim Controls */
.trim-controls {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.trim-controls h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.time-range {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.time-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.time-input-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 50px;
}

.time-input-group input {
    width: 80px;
    padding: 0.5rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.time-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.duration-display {
    font-weight: 600;
    color: var(--primary-color);
}

/* Range Slider */
.range-slider-container {
    padding: 0.5rem 0;
}

.range-slider {
    position: relative;
    height: 8px;
    background: var(--background);
    border-radius: 4px;
    margin: 1rem 0;
}

.range-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-color);
    border-radius: 4px;
}

.range-selected {
    position: absolute;
    top: 0;
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
}

.range-handle {
    position: absolute;
    top: 50%;
    width: 20px;
    height: 20px;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    transition: box-shadow var(--transition);
}

.range-handle:hover,
.range-handle:active {
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3);
}

.range-handle:active {
    cursor: grabbing;
}

/* Images Preview */
.images-preview-container {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.images-preview-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

#image-count {
    font-weight: 400;
    color: var(--text-secondary);
}

.images-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--background);
}

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

.image-item .order-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

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

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

.image-item .remove-btn svg {
    width: 14px;
    height: 14px;
}

/* Drag and Drop for reordering */
.image-item.dragging {
    opacity: 0.5;
}

.image-item.drag-over {
    border: 2px solid var(--primary-color);
}

/* Settings Panel */
.settings-panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.settings-panel.hidden {
    display: none;
}

.settings-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.setting-group {
    margin-bottom: 1.25rem;
}

.setting-group:last-of-type {
    margin-bottom: 1.5rem;
}

.setting-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.setting-control input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    cursor: pointer;
}

.setting-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: box-shadow var(--transition);
}

.setting-control input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3);
}

.setting-control select {
    flex: 1;
    padding: 0.5rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.setting-value {
    min-width: 80px;
    text-align: right;
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.btn svg {
    width: 20px;
    height: 20px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

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

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

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal {
    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;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #a855f7);
    width: 0%;
    transition: width 0.3s ease;
}

#progress-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Result Section */
.result-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    text-align: center;
}

.result-section.hidden {
    display: none;
}

.result-section h3 {
    color: var(--success-color);
    margin-bottom: 1rem;
}

.result-preview {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    max-height: 400px;
    overflow: hidden;
}

.result-preview img {
    max-width: 100%;
    max-height: 350px;
    border-radius: var(--radius-sm);
}

.result-info {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface);
    margin-top: auto;
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .mode-selector {
        flex-direction: column;
        gap: 0.75rem;
    }

    .mode-btn {
        padding: 0.875rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .upload-area svg {
        width: 40px;
        height: 40px;
    }

    .time-range {
        flex-direction: column;
        gap: 1rem;
    }

    .images-preview {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .result-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .main-content {
        padding: 0 0.75rem 1.5rem;
    }

    .trim-controls,
    .settings-panel,
    .images-preview-container {
        padding: 1rem;
    }

    .setting-control {
        flex-wrap: wrap;
    }

    .setting-value {
        width: 100%;
        text-align: left;
        margin-top: 0.25rem;
    }
}

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

.mode-section.active,
.editor:not(.hidden),
.settings-panel:not(.hidden),
.result-section:not(.hidden) {
    animation: fadeIn 0.3s ease;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Focus Styles */
input:focus,
select:focus,
button:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Hidden utility */
.hidden {
    display: none !important;
}
