/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
    color: #333;
    min-height: 100vh;
    line-height: 1.6;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: 
        radial-gradient(circle at 20px 20px, #ddd 1px, transparent 1px),
        radial-gradient(circle at 40px 40px, #ddd 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 30px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
}

.header-left {
    position: absolute;
    left: 30px;
}

.header-left .title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.header-tabs {
    display: flex;
    gap: 0;
}

.tab {
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
    position: relative;
}

.tab.active {
    background: #007bff;
    color: #fff;
    border: 2px solid #007bff;
}

.tab:hover:not(.active) {
    background: #f8f9fa;
    color: #333;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    padding: 30px;
    overflow-y: auto;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.tool-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-header h2 i {
    color: #ffc107;
}

.tool-description {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.5;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-group label {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

/* Slider Container */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#smoothingSlider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#smoothingSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,123,255,0.3);
}

#smoothingSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0,123,255,0.3);
}

#smoothingValue {
    font-size: 0.9rem;
    color: #007bff;
    font-weight: 600;
    text-align: right;
}

/* Renderer Select */
.renderer-select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.renderer-select:focus {
    outline: none;
    border-color: #007bff;
}

.renderer-select:hover {
    border-color: #007bff;
}

/* Color Picker */
.color-picker-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.color-preview {
    width: 100%;
    height: 120px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: linear-gradient(45deg, #000 0%, #fff 50%, #f00 100%);
    cursor: crosshair;
    transition: border-color 0.3s ease;
    position: relative;
    user-select: none;
}

.color-preview:hover {
    border-color: #007bff;
}

.color-spectrum {
    width: 100%;
    height: 20px;
    border-radius: 10px;
    background: linear-gradient(to right, 
        #ff0000 0%, 
        #ff8000 16.66%, 
        #ffff00 33.33%, 
        #80ff00 50%, 
        #00ff00 66.66%, 
        #00ff80 83.33%, 
        #0000ff 100%);
    position: relative;
    cursor: pointer;
}

.spectrum-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.1s ease;
    user-select: none;
}

.spectrum-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
}

.color-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

#colorInput {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    background: #fff;
}

#colorInput:focus {
    outline: none;
    border-color: #007bff;
}

.color-input-group i {
    color: #666;
    font-size: 0.9rem;
}

.color-swatches {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.swatch {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.swatch:hover {
    border-color: #007bff;
    transform: scale(1.05);
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 600px;
}

.upload-zone {
    width: 100%;
    height: 300px;
    border: 2px dashed #ccc;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
}

.upload-zone:hover {
    border-color: #007bff;
    background: #f8f9ff;
}

.upload-icon {
    font-size: 3rem;
    color: #ccc;
}

.upload-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.upload-formats {
    font-size: 0.9rem;
    color: #666;
}

.render-history {
    font-size: 0.95rem;
    color: #666;
    text-align: center;
}

/* Canvas Container */
.canvas-container {
    display: flex;
    gap: 30px;
    width: 100%;
    max-width: 1000px;
    margin-top: 30px;
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    min-width: 0; /* Allow flex item to shrink */
}

.canvas-wrapper h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

canvas {
    max-width: 100%;
    height: auto;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    object-fit: contain;
    display: block;
}

/* Clear Image Button */
.clear-image-section {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.clear-image-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

.clear-image-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.4);
}

.clear-image-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

/* Download Button */
.download-section {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.download-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #28a745;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

.download-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.4);
}

.download-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 0.95rem;
}

.footer-left i {
    color: #007bff;
}

.generate-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,123,255,0.3);
}

.generate-btn:hover:not(:disabled) {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.4);
}

.generate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Status Message */
.status-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 1000;
    display: inline-block;
    max-width: 300px;
    white-space: nowrap;
}

.close-status-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    font-size: 0.7rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.close-status-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .canvas-container {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }
    
    .header-tabs {
        width: 100%;
        justify-content: center;
    }
    
    .sidebar {
        padding: 20px;
    }
    
    .content-area {
        padding: 20px;
    }
    
    .footer {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }
}

