:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: var(--bg-secondary);
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    border-radius: 20px;
    font-size: 14px;
    color: var(--success);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    gap: 10px;
    background: var(--bg-secondary);
    padding: 10px;
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Info Banner */
.info-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    background: rgba(102, 126, 234, 0.1);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.info-banner svg {
    flex-shrink: 0;
    color: var(--primary);
}

.color-grid-simple {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.control-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 12px;
}

/* Main Content */
.main-content {
    display: grid;
    gap: 30px;
}

/* Controls Panel */
.controls-panel {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    box-shadow: 0 4px 6px var(--shadow);
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.select-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.select-input:hover {
    border-color: var(--primary);
}

.select-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Mode Switch */
.mode-switch {
    display: flex;
    gap: 10px;
    grid-column: 1 / -1;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-color: var(--primary);
}

/* Button Group */
.button-group {
    display: flex;
    gap: 10px;
}

.option-btn {
    flex: 1;
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.option-btn.active {
    background: rgba(102, 126, 234, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

/* Color Grid */
.color-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.color-box {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.color-box:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px var(--shadow);
}

.color-box.active {
    border-color: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.3);
}

.color-picker {
    width: 100%;
    height: 50px;
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: pointer;
}

/* Sliders */
.slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    cursor: pointer;
    border: none;
}

/* Upload Area */
.upload-area {
    background: var(--bg-secondary);
    border: 3px dashed var(--border);
    border-radius: 16px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.upload-area.drag-over {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.02);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 20px;
}

.upload-area h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.upload-info {
    display: flex;
    justify-content: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Preview Area */
.preview-area {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.preview-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.preview-box {
    display: flex;
    flex-direction: column;
}

.preview-box h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: var(--text-secondary);
}

.image-container {
    position: relative;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container img,
.image-container canvas {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    position: relative;
    z-index: 2;
}

.checkerboard {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(45deg, #2d3748 25%, transparent 25%),
        linear-gradient(-45deg, #2d3748 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2d3748 75%),
        linear-gradient(-45deg, transparent 75%, #2d3748 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    z-index: 1;
}

.image-info {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 3;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 20px;
    color: var(--text-secondary);
}

.preview-arrow {
    display: flex;
    align-items: center;
    color: var(--primary);
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

/* Batch Area */
.batch-area {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.batch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.batch-item {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 15px;
    position: relative;
}

.batch-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.batch-item-info {
    font-size: 12px;
    color: var(--text-secondary);
}

.batch-item-status {
    margin-top: 10px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    text-align: center;
    font-weight: 500;
}

.batch-item-status.processing {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.batch-item-status.completed {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.batch-item-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.batch-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Stats Footer */
.stats-footer {
    display: flex;
    justify-content: space-around;
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 16px;
    margin-top: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.status-ready {
    color: var(--success) !important;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-secondary);
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--primary); }

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

    .preview-arrow {
        transform: rotate(90deg);
        margin: 20px 0;
    }
}

@media (max-width: 768px) {
    .controls-panel {
        grid-template-columns: 1fr;
    }

    .batch-grid {
        grid-template-columns: 1fr;
    }

    .stats-footer {
        flex-direction: column;
        gap: 20px;
    }
}
