:root {
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --accent-primary: #3B82F6;
    --accent-secondary: #8B5CF6;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border: #334155;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    position: relative;
    overflow-x: hidden;
}

.background-gradient {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(139, 92, 246, 0.15) 0%, rgba(59, 130, 246, 0.1) 30%, transparent 60%);
    z-index: -1;
    pointer-events: none;
    animation: drift 20s ease-in-out infinite alternate;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1.0); }
    100% { transform: translate(50px, -50px) scale(1.1); }
}

.container {
    width: 100%;
    max-width: 800px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

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

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, #60A5FA, #C084FC);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.btn-secondary {
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

/* Sidebar Styles */
.history-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px;
    height: 100%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 1000;
    padding: 1.5rem;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    animation: sidebarSlideOut 0.3s ease-out forwards;
}

.history-sidebar.active {
    animation: sidebarSlideIn 0.3s ease-out forwards;
}

@keyframes sidebarSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes sidebarSlideOut {
    from { transform: translateX(0); }
    to { transform: translateX(100%); }
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.2s;
}

.history-item:hover {
    transform: scale(1.02);
}

.history-item .item-info {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-item .item-caption {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item .item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-mini {
    padding: 0.4rem 0.8rem;
    background: var(--border);
    border: none;
    color: white;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    flex: 1;
}

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

.btn-mini.remix {
    background: var(--accent-secondary);
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.95rem;
}

input[type="text"] {
    width: 100%;
    padding: 1rem 1.25rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.2s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.styled-select {
    flex: 1;
    padding: 1rem 1.25rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    cursor: pointer;
}

.styled-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Modal specific styles */
.editor-modal {
    border: none;
    border-radius: 16px;
    background: transparent;
    margin: auto;
    padding: 0;
}

.editor-modal::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    width: 600px;
    max-width: 90vw;
    color: var(--text-main);
}

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

.modal-header h3 { margin: 0; }

textarea#jsonEditor {
    width: 100%;
    background: #1e1e1e;
    color: #d4d4d4;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    font-family: monospace;
    font-size: 0.95rem;
    min-height: 250px;
}

textarea#jsonEditor:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.modal-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

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

.file-drop-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.3);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.file-drop-area:hover, .file-drop-area.dragover {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.file-input {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    opacity: 0;
    cursor: pointer;
}

.drop-text {
    color: var(--text-muted);
    font-weight: 500;
    pointer-events: none;
}

.sortable-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.sortable-item, .preview-container {
    width: calc(25% - 0.75rem);
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    cursor: grab;
}

.sortable-item:active {
    cursor: grabbing;
}

.sortable-item img, .preview-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 10;
}

.btn-remove:hover {
    background: #DC2626;
}

.preview-container {
    margin-top: 1rem;
    width: 120px;
    cursor: default;
}

.hidden { display: none !important; }

.count-text {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px rgba(139, 92, 246, 0.8);
}

.btn-primary:disabled {
    background: var(--border);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

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

.progress-section {
    margin-top: 2rem;
    text-align: center;
    padding: 2rem;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    margin: 1rem 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width 0.3s ease;
}

.progress-status {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.results-section h2 {
    text-align: center;
    margin: 2rem 0;
    color: #34D399;
}

.video-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.video-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    text-align: center;
    padding-bottom: 1rem;
}

.video-card h4 {
    padding: 1rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

video {
    width: 100%;
    max-height: 400px;
    background: black;
    object-fit: contain;
}

.btn-download {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: var(--border);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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