/* Wplace Paint Tool - Modern Premium Design */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

/* Modern Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo svg {
    width: 32px;
    height: 32px;
    fill: var(--primary);
}

.logo img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.nav-menu {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-link {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: all var(--transition-base);
    transform: translateX(-50%);
}

.nav-link:hover {
    color: var(--primary);
    background: var(--bg-hover);
}

.nav-link.active {
    color: var(--primary);
    background: var(--bg-active);
}

.nav-link.active::after {
    width: 60%;
}

/* Main Content Area */
.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 2rem;
}

.converter-layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

/* Modern Panel Design */
.panel-card {
    background: white;
    border-radius: var(--radius-2xl);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 10px 40px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all var(--transition-base);
}

.panel-card:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 20px 60px rgba(0, 0, 0, 0.08);
}

/* Left Panel - Controls */
.left-panel {
    height: fit-content;
    position: sticky;
    top: 88px;
}

/* Modern Upload Section */
.upload-section {
    padding: 2rem;
    border-bottom: 1px solid var(--border-light);
}

.upload-box {
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-xl);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    position: relative;
    overflow: hidden;
}

.upload-box::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-slow);
}

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

.upload-box:hover::before {
    opacity: 0.05;
}

.upload-box.drag-over {
    border-color: var(--primary);
    background: var(--bg-active);
    transform: scale(1.02);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--primary);
}

.upload-box h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-box p {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

/* Settings Section */
.settings-section {
    padding: 1.5rem;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title svg {
    width: 16px;
    height: 16px;
}

.setting-group {
    margin-bottom: 1.75rem;
}

.setting-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.setting-value {
    font-weight: 600;
    color: var(--primary);
}

/* Modern Slider */
.slider {
    width: 100%;
    height: 6px;
    border-radius: var(--radius-full);
    background: linear-gradient(to right, var(--gray-200), var(--gray-300));
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    transition: all var(--transition-base);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.5);
}

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

/* Modern Select */
.select-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    background: white;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-base);
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    appearance: none;
}

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

/* Modern Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    gap: 0.75rem;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-default);
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    appearance: none;
    transition: all var(--transition-base);
}

.checkbox-label input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

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

/* Color Palette Section */
.palette-section {
    padding: 1.5rem;
    border-top: 1px solid var(--border-light);
}

.palette-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.radio-label {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    gap: 0.5rem;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-default);
    border-radius: 50%;
    appearance: none;
    cursor: pointer;
    transition: all var(--transition-base);
}

.radio-label input[type="radio"]:checked {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: inset 0 0 0 4px white;
}

/* Color Grid */
.color-grid {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    gap: 0.25rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}

.color-cell {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    transition: all var(--transition-base);
    border: 2px solid transparent;
}

.color-cell:hover {
    transform: scale(1.3);
    z-index: 10;
    border-color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.color-cell.selected {
    transform: scale(1.2);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.color-cell.locked::after {
    content: '🔒';
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 8px;
    background: white;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Right Panel - Canvas Area */
.right-panel {
    min-height: 700px;
}

.preview-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, white, var(--bg-secondary));
}

.preview-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preview-header h2 svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    color: var(--text-secondary);
}

.action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* Canvas Container */
.canvas-container {
    padding: 1.5rem;
    background: var(--bg-secondary);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-default);
    background: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    color: var(--text-secondary);
}

.zoom-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.1);
}

.zoom-slider {
    flex: 1;
    max-width: 200px;
}

.zoom-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 60px;
    text-align: center;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

/* Modern Canvas Wrapper */
.canvas-wrapper {
    border-radius: var(--radius-xl);
    background: white;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: 
        linear-gradient(45deg, #fafafa 25%, transparent 25%),
        linear-gradient(-45deg, #fafafa 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #fafafa 75%),
        linear-gradient(-45deg, transparent 75%, #fafafa 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

#outputCanvas {
    display: none;
    cursor: crosshair;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    background: transparent;
    transition: transform var(--transition-base);
}

#outputCanvas.loaded {
    display: block;
}

/* Modern Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius-xl);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.tool-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-secondary);
    position: relative;
}

.tool-btn:hover {
    background: white;
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.tool-btn svg {
    width: 20px;
    height: 20px;
}

.tool-separator {
    width: 1px;
    height: 32px;
    background: var(--border-light);
    margin: 0 0.5rem;
}

/* Footer */
.app-footer {
    background: white;
    border-top: 1px solid var(--border-light);
    padding: 2rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.footer-links {
    display: flex;
    gap: 2rem;
}

.footer-links a {
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color var(--transition-base);
}

.footer-links a:hover {
    color: var(--primary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .converter-layout {
        grid-template-columns: 1fr;
    }
    
    .left-panel {
        position: static;
    }
}

/* Preview Info Styles */
.preview-info {
    padding: 20px 32px;
    border-top: 1px solid var(--border-light);
    background: linear-gradient(to bottom, var(--bg-white), var(--bg-secondary));
}

.info-row {
    display: flex;
    gap: 24px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.info-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 16px;
}

.color-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid var(--border-light);
    background: #000;
}

.color-hex {
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: var(--transition-base);
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-base);
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Download Button */
.btn-premium {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Toolbar Styles */
.toolbar {
    padding: 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
}

.tool-group {
    display: flex;
    gap: 4px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-light);
    background: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    color: var(--text-secondary);
}

.tool-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tool-separator {
    width: 1px;
    height: 24px;
    background: var(--border-light);
}

.brush-settings {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brush-size-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.brush-slider {
    width: 80px;
    height: 4px;
    background: var(--gray-300);
    outline: none;
    border-radius: 2px;
    -webkit-appearance: none;
    appearance: none;
}

.brush-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    cursor: pointer;
    border-radius: 50%;
}

.brush-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--primary);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

#brushSizeValue {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
    min-width: 30px;
}

/* Color Analysis Styles */
.color-analysis {
    margin-top: 24px;
    padding: 24px;
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.analysis-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.analysis-title svg {
    color: var(--primary);
}

.color-stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    font-size: 14px;
    color: var(--text-secondary);
}

.stat-item strong {
    color: var(--text-primary);
    font-weight: 600;
    margin-left: 4px;
}

.stat-item .free-count {
    color: var(--success);
}

.stat-item .paid-count {
    color: var(--warning);
}

.color-note {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.used-colors-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.used-color-cell {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-base);
    border: 2px solid transparent;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.used-color-cell:hover {
    transform: scale(1.2);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--primary);
}

.used-color-cell.locked::after {
    content: '🔒';
    position: absolute;
    bottom: -4px;
    right: -4px;
    font-size: 12px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Advanced Settings Button */
.accordion-btn {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--bg-white) 0%, var(--bg-secondary) 100%);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition-base);
}

.accordion-btn:hover {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-white) 100%);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.accordion-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.accordion-btn .accordion-icon {
    transition: transform var(--transition-base);
}

.accordion-btn.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-smooth);
}

.accordion-panel.show {
    max-height: 500px;
    padding-top: 16px;
}

@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
    }
    
    .main-content {
        padding: 0 1rem;
    }
    
    .nav-menu {
        display: none;
    }
}