* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --background: #0f0f23;
    --surface: #1a1a2e;
    --surface-light: #16213e;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --accent: #10b981;
    --error: #ef4444;
    --glass-bg: rgba(26, 26, 46, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.app {
    display: grid;
    grid-template-columns: 300px 1fr 320px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "header header header"
        "sidebar canvas controls";
    min-height: 100vh;
    gap: 1rem;
    padding: 1rem;
}

/* Header */
.header {
    grid-area: header;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-toggle {
    background: var(--surface-light);
    border: none;
    border-radius: 8px;
    padding: 0.5rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--primary-color);
    transform: scale(1.05);
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    overflow-y: auto;
}

.upload-area {
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    padding: 2rem 1rem;
    text-align: center;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.upload-text {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.file-input {
    display: none;
}

.btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--surface);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* Canvas Area */
.canvas-area {
    grid-area: canvas;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.canvas-container {
    position: relative;
    max-width: 100%;
    max-height: 70vh;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

#mainCanvas {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    border-radius: 12px;
}

.canvas-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.canvas-container:hover .canvas-overlay {
    opacity: 1;
}

.placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

/* Controls Panel */
.controls {
    grid-area: controls;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    overflow-y: auto;
}

.control-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-btn {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.75rem 0.5rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    text-align: center;
}

.filter-btn:hover {
    background: var(--surface-light);
    transform: scale(1.02);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.slider-container {
    margin-bottom: 1.5rem;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.slider {
    width: 100%;
    height: 6px;
    background: var(--surface);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.processing {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    z-index: 100;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--surface);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.comparison-slider {
    position: relative;
    margin: 1rem 0;
}

.comparison-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.before-after {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.image-preview {
    flex: 1;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.image-label {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .app {
        grid-template-columns: 280px 1fr 280px;
    }
}

@media (max-width: 768px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "canvas"
            "controls"
            "sidebar";
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .header {
        padding: 1rem;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }
}

/* Light theme */
.light-theme {
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-light: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.1);
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
