
/* Modern CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4CAF50;
    --secondary-color: #2196F3;
    --accent-color: #FF9800;
    --bg-color: #1a1a1a;
    --surface-color: #2d2d2d;
    --text-color: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --success-color: #4CAF50;
    --error-color: #f44336;
    --warning-color: #FF9800;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
    
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: linear-gradient(135deg, var(--bg-color) 0%, #0f0f0f 100%);
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.section {
    padding: 4rem 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
}

.nav-link:hover {
    color: var(--primary-color);
    background: rgba(76, 175, 80, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: #45a049;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #404040;
    border-color: var(--primary-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #45a049;
}

/* Upload Section */
.upload-section {
    margin-top: 80px;
    text-align: center;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem;
    margin: 2rem 0;
    transition: var(--transition);
    cursor: pointer;
    background: var(--surface-color);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(76, 175, 80, 0.05);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(76, 175, 80, 0.1);
    transform: scale(1.02);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-link {
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
}

.upload-info {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    opacity: 0.7;
}

.sample-skin {
    margin-top: 2rem;
}

.sample-skin a {
    color: var(--secondary-color);
    text-decoration: none;
}

.sample-skin a:hover {
    text-decoration: underline;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 2rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.3s ease;
}

/* Pose Editor */
.pose-editor {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    height: 80vh;
}

.viewer-container {
    position: relative;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

#skinViewer {
    width: 100%;
    height: 100%;
    display: block;
}

.viewer-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
}

.controls-panel {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.preset-poses {
    margin-bottom: 2rem;
}

.pose-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.pose-btn {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.pose-btn:hover {
    border-color: var(--primary-color);
    background: rgba(76, 175, 80, 0.1);
}

.pose-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.part-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.part-group:last-child {
    border-bottom: none;
}

.part-group h4 {
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.slider-group label {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.slider-group input[type="range"] {
    flex: 2;
    appearance: none;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.slider-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.slider-value {
    min-width: 40px;
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Export Section */
.export-section {
    text-align: center;
}

.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
    padding: 2rem;
    background: var(--surface-color);
    border-radius: var(--border-radius);
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-group label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.option-group select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
}

.option-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.export-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
}

.export-result {
    margin-top: 2rem;
    padding: 2rem;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    border: 2px solid var(--success-color);
}

/* Footer */
.footer {
    background: var(--surface-color);
    padding: 2rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.footer-link:hover {
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .header .container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .nav {
        gap: 1rem;
    }
    
    .pose-editor {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .viewer-container {
        height: 400px;
    }
    
    .export-options {
        grid-template-columns: 1fr;
    }
    
    .export-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .section {
        padding: 2rem 0;
        min-height: auto;
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

/* Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles */
button:focus,
input:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #666;
        --text-secondary: #ccc;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* WebGL Fallback Styles - Add these to your existing style.css */

.webgl-error, .webgl-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    text-align: center;
}

.webgl-error h3, .webgl-fallback h3 {
    color: var(--warning-color);
    margin-bottom: 1rem;
}

.webgl-solutions {
    margin: 1.5rem 0;
    text-align: left;
}

.webgl-solutions h4 {
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.webgl-solutions ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.webgl-solutions li {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.skin-preview-fallback, .skin-preview-2d {
    margin-top: 2rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    border: 2px solid var(--border-color);
}

#skinPreview2D {
    display: block;
    margin: 0 auto 1rem;
    border-radius: 4px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.fallback-content {
    max-width: 500px;
}

/* Notification improvements */
.notification {
    box-shadow: var(--shadow-lg);
    border-left: 4px solid currentColor;
}

.notification-success {
    background: var(--success-color) !important;
    border-left-color: #45a049;
}

.notification-error {
    background: var(--error-color) !important;
    border-left-color: #d32f2f;
}

.notification-warning {
    background: var(--warning-color) !important;
    border-left-color: #f57c00;
}

.notification-info {
    background: var(--secondary-color) !important;
    border-left-color: #1976d2;
}

/* Loading state improvements */
.upload-area.loading {
    pointer-events: none;
    opacity: 0.7;
}

.upload-area.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Debugging helpers */
.debug-info {
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    z-index: 9999;
    display: none;
}

.debug-info.show {
    display: block;
}

/* Console-style error display */
.error-details {
    background: #1a1a1a;
    color: #ff6b6b;
    padding: 1rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    margin-top: 1rem;
    border-left: 4px solid #ff6b6b;
}

/* Responsive improvements for fallback */
@media (max-width: 768px) {
    .webgl-error, .webgl-fallback {
        padding: 1rem;
    }
    
    .fallback-content {
        max-width: 100%;
    }
    
    #skinPreview2D {
        width: 200px;
        height: 200px;
    }
    
    .webgl-solutions {
        text-align: center;
    }
    
    .webgl-solutions ul {
        text-align: left;
        display: inline-block;
    }
}