/* CSS Variables */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6b7280;
    --secondary-hover: #4b5563;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background-color: #f9fafb;
    --surface-color: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --transition: 150ms ease-in-out;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

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

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.tagline {
    opacity: 0.9;
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Section Styles */
section {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* URL Section */
.url-section {
    background: var(--surface-color);
}

.input-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.url-input-wrapper {
    display: flex;
    gap: 0.75rem;
}

.url-input-wrapper input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.url-input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

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

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

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

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

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

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

/* Controls Section */
.controls-grid {
    display: grid;
    gap: 1.5rem;
}

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

@media (min-width: 1024px) {
    .controls-grid {
        grid-template-columns: 1fr 1fr auto;
    }
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-weight: 500;
    color: var(--text-primary);
}

.control-group select {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: white;
    cursor: pointer;
    transition: border-color var(--transition);
}

.control-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.control-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
    appearance: none;
    cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: transform var(--transition);
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.control-buttons {
    flex-direction: row;
    align-items: flex-end;
    gap: 0.75rem;
}

/* Preview Section */
.preview-section {
    padding: 1rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--primary-color);
    color: white;
    border-radius: 9999px;
}

.preview-container {
    position: relative;
    width: 100%;
    min-height: 400px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #f3f4f6;
}

.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-secondary);
}

.placeholder-content {
    text-align: center;
}

.placeholder-content svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.iframe-wrapper {
    position: relative;
    width: 100%;
    height: 500px;
}

.iframe-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transition: all var(--transition);
}

/* Contrast Section */
.contrast-grid {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .contrast-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    .contrast-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-picker-group label {
    font-weight: 500;
    font-size: 0.875rem;
}

.color-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.color-input-wrapper input[type="color"] {
    width: 48px;
    height: 48px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.color-input-wrapper input[type="text"] {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: monospace;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    text-transform: uppercase;
}

.color-input-wrapper input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.contrast-results {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.contrast-ratio {
    text-align: center;
    padding: 0.75rem;
    background: var(--background-color);
    border-radius: var(--radius-md);
}

.ratio-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

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

.wcag-results {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wcag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}

.wcag-level {
    color: var(--text-secondary);
}

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

.wcag-status.pass {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.wcag-status.fail {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.contrast-preview {
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-box {
    width: 100%;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
    border: 2px solid var(--border-color);
}

.preview-text {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.preview-text-large {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Info Section */
.info-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 768px) {
    .info-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.info-card {
    padding: 1rem;
    background: var(--background-color);
    border-radius: var(--radius-md);
}

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

.info-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: white;
    padding: 1.5rem;
    text-align: center;
}

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

.footer a:hover {
    color: #c7d2fe;
    text-decoration: underline;
}

/* Loading State */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Error Message */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    text-align: center;
    margin-top: 1rem;
}

/* Vision Filter Overlays */
.overlay.protanopia {
    background: transparent;
}

.overlay.deuteranopia {
    background: transparent;
}

.overlay.tritanopia {
    background: transparent;
}

.overlay.low-contrast {
    background: rgba(128, 128, 128, 0.3);
    mix-blend-mode: multiply;
}

.overlay.blurred {
    backdrop-filter: blur(2px);
}

.overlay.cataracts {
    background: rgba(255, 255, 200, 0.3);
    backdrop-filter: blur(1px);
}

.overlay.glaucoma {
    background: radial-gradient(circle at center, transparent 30%, rgba(0, 0, 0, 0.8) 100%);
}

.overlay.macular-degeneration {
    background: radial-gradient(circle at center, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.3) 20%, transparent 40%);
}

/* Responsive Adjustments */
@media (max-width: 640px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .url-input-wrapper {
        flex-direction: column;
    }

    .url-input-wrapper .btn {
        width: 100%;
    }

    .control-buttons {
        flex-direction: column;
        width: 100%;
    }

    .control-buttons .btn {
        width: 100%;
    }

    .preview-container {
        min-height: 300px;
    }

    .iframe-wrapper {
        height: 350px;
    }

    section {
        padding: 1rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .controls-section,
    .url-section {
        display: none;
    }

    .preview-section {
        break-inside: avoid;
    }
}
