/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: 150ms ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

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

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary-color);
    background: #f0f0ff;
}

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

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-area:hover .upload-icon {
    color: var(--primary-color);
}

.upload-content h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-content p {
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.file-types {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Controls Section */
.controls-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.control-group {
    flex: 1;
    min-width: 200px;
}

.control-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.control-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition);
}

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

.control-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.control-buttons {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

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

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

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

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--secondary-color);
}

/* Comparison Section */
.comparison-section {
    margin-bottom: 2rem;
}

/* Side by Side View */
.side-by-side-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.image-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.image-panel.full-width {
    max-width: 800px;
    margin: 0 auto;
}

.image-panel h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-align: center;
}

.image-container {
    background: #f0f0f0;
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.image-container canvas {
    max-width: 100%;
    max-height: 500px;
    display: block;
}

/* Slider View */
.slider-view {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.slider-container {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    cursor: ew-resize;
    min-height: 300px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 500px;
}

#sliderSimulatedCanvas {
    clip-path: inset(0 0 0 50%);
}

.slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

.slider-line {
    flex: 1;
    width: 2px;
    background: white;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.slider-circle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    color: var(--text-secondary);
}

.slider-labels {
    position: absolute;
    bottom: 1rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 1rem;
    pointer-events: none;
}

.slider-labels span {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Simulated Only View */
.simulated-only-view .image-container {
    min-height: 400px;
}

.simulated-only-view canvas {
    max-height: 600px;
}

/* Accessibility Section */
.accessibility-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.accessibility-section h2 {
    font-size: 1.125rem;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.accessibility-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.accessibility-card {
    background: var(--background);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.accessibility-card h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    position: relative;
    cursor: pointer;
    transition: transform var(--transition);
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch::after {
    content: attr(data-color);
    position: absolute;
    bottom: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.625rem;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition);
}

.color-swatch:hover::after {
    opacity: 1;
}

.issues-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.issue-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.issue-badge {
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.issue-badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.issue-badge.error {
    background: #fee2e2;
    color: #991b1b;
}

.issue-badge.success {
    background: #d1fae5;
    color: #065f46;
}

.color-distribution {
    height: 20px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
}

.color-bar {
    height: 100%;
    transition: width var(--transition);
}

.recommendations-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recommendations-list li {
    font-size: 0.875rem;
    color: var(--text-primary);
    padding-left: 1.25rem;
    position: relative;
}

.recommendations-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

/* Info Section */
.info-section {
    margin-bottom: 2rem;
}

.info-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.info-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.info-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.info-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.info-card .prevalence {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--background);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    text-align: center;
}

.footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        padding: 1.5rem;
    }

    .side-by-side-view {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }

    .logo h1 {
        font-size: 1.25rem;
    }

    .main-content {
        padding: 1rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .controls-section {
        padding: 1rem;
    }

    .controls-row {
        flex-direction: column;
        gap: 1rem;
    }

    .control-group {
        width: 100%;
        min-width: unset;
    }

    .control-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .control-buttons .btn {
        flex: 1;
        justify-content: center;
    }

    .image-container {
        min-height: 200px;
    }

    .image-container canvas {
        max-height: 300px;
    }

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

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

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: 0.5rem;
    }

    .tagline {
        font-size: 0.875rem;
    }

    .upload-icon {
        width: 48px;
        height: 48px;
    }

    .upload-content h2 {
        font-size: 1.125rem;
    }

    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .slider-circle {
        width: 32px;
        height: 32px;
    }

    .slider-circle svg {
        width: 18px;
        height: 18px;
    }
}

/* Loading State */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}
