:root {
    --primary-color: #8b5cf6;
    /* Violeta más vibrante */
    --primary-hover: #7c3aed;
    --secondary-color: #ec4899;
    /* Rosa neón */
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-color: #020617;
    /* Slate 950 - Muy oscuro */
    --card-bg: rgba(30, 41, 59, 0.7);
    /* Slate 800 con transparencia */
    --text-color: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(148, 163, 184, 0.2);
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    --glow: 0 0 20px rgba(139, 92, 246, 0.3);
}

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

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.15) 0px, transparent 50%);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header Compacto */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 1.2rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    border-radius: 12px;
}

header h1 {
    font-size: 1.1rem;
    background: linear-gradient(135deg, #c084fc, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-left: 1rem;
}

/* Cards con Glassmorphism */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: var(--shadow), var(--glow);
}

.card h2 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Layout */
.main-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.controls-column {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding-right: 0.5rem;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(15, 23, 42, 0.3);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(139, 92, 246, 0.1);
}

/* Inputs & Controls */
.config-item {
    margin-bottom: 1rem;
}

.config-item label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.value-display {
    color: var(--primary-color);
    font-weight: 700;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

select {
    width: 100%;
    padding: 0.6rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.9rem;
}

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

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--text-secondary);
}

/* Video Preview */
.video-container,
.preview-container {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#previewCanvas,
#previewVideo,
#videoPreview {
    max-width: 100%;
    max-height: 600px;
    image-rendering: pixelated;
    width: auto;
    /* Mantener aspect ratio */
    height: auto;
    /* Mantener aspect ratio */
    transform-origin: center center;
    /* Zoom desde el centro */
    transition: transform 0.1s ease-out;
    /* Suavizar zoom */
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
}

#zoomLevelDisplay {
    font-size: 0.8rem;
    min-width: 45px;
    text-align: center;
    font-family: monospace;
}

/* Cursor states for panning */
.preview-container {
    cursor: grab;
}

.preview-container.grabbing {
    cursor: grabbing;
}

.preview-container.eyedropper-active {
    cursor: crosshair !important;
}

/* Palette */
.palette-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 4px;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.color-item {
    aspect-ratio: 1;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.1s;
}

.color-item:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .controls-column {
        position: static;
        max-height: none;
    }
}

/* Timeline Slider Styles */
.timeline-container {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.timeline-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.timeline-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c084fc, #f472b6);
    cursor: pointer;
    transition: transform 0.2s;
}

.timeline-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.timeline-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c084fc, #f472b6);
    cursor: pointer;
    border: none;
    transition: transform 0.2s;
}

.timeline-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow);
    animation: slideUp 0.3s ease;
}

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

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

.modal-header {
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.25rem;
}

footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-input {
    width: 100%;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.modal-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Custom Checkbox Styles */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #c084fc, #f472b6);
    border-color: #c084fc;
}

input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

input[type="checkbox"]:hover {
    border-color: var(--primary-color);
}

/* Checkbox Labels - Align to left */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-start;
}

/* Custom Radio Button Styles */
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

input[type="radio"]:checked {
    border-color: #c084fc;
    background: rgba(192, 132, 252, 0.2);
}

input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c084fc, #f472b6);
}

input[type="radio"]:hover {
    border-color: var(--primary-color);
}

/* Orientation Radio Labels - Align Left */
.orientation-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-start;
    text-align: left;
}

/* Color Input Styling */
input[type="color"] {
    width: 50px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.2s;
}

input[type="color"]:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

/* Text Input for Color Hex */
input[type="text"]#colorHex {
    flex: 1;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    transition: all 0.2s;
}

input[type="text"]#colorHex:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Add Color Button */
#addColorBtn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* Palette Display Empty State - Centered */
.palette-display .empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem 1rem;
    font-size: 0.9rem;
}

/* Palette Display - Show Colors */
.palette-display.has-colors {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    padding: 0.75rem;
}

.color-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    position: relative;
    transition: all 0.2s;
}

.color-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.color-swatch {
    width: 100%;
    height: 40px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.color-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    word-break: break-all;
    text-align: center;
}

.color-remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.color-remove:hover {
    background: #ef4444;
    transform: scale(1.1);
}

/* Eyedropper Active State */
.btn.active {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Highlighted Color in Palette */
.color-item.highlighted {
    border-color: #10b981;
    border-width: 3px;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.4), 0 0 20px rgba(16, 185, 129, 0.6);
    animation: pulse 0.8s ease-in-out infinite;
    z-index: 10;
    position: relative;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.4), 0 0 20px rgba(16, 185, 129, 0.6);
    }

    50% {
        transform: scale(1.08);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.6), 0 0 30px rgba(16, 185, 129, 0.8);
    }
}

/* Dithering Preview - Centered */
.dithering-preview {
    margin: 0.75rem auto;
    display: block;
}

/* Radio Group - Align labels to left */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-group label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-start;
    text-align: left;
}

/* Palette Display - Fix empty state centering */
.palette-display {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.palette-display .empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem 1rem;
    font-size: 0.9rem;
    width: 100%;
}

/* Palette Controls - Better spacing */
.palette-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Video Placeholder */
.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    color: var(--text-secondary);
    gap: 1rem;
    pointer-events: none;
}

.video-placeholder svg {
    opacity: 0.5;
}

.video-placeholder p {
    margin: 0;
    font-size: 1rem;
}

/* Hide video controls when no video loaded */
video:not([src]) {
    display: none;
}

/* Preview Placeholder */
.preview-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    gap: 1rem;
    pointer-events: none;
}

.preview-placeholder svg {
    opacity: 0.5;
}

.preview-placeholder p {
    margin: 0;
    font-size: 1rem;
}