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

:root {
    --app-primary: #2563eb;
    --app-secondary: #7c3aed;
    --app-accent: #059669;
    --app-background: #f8fafc;
    --app-surface: #ffffff;
    --app-text: #1e293b;
    --app-text-muted: #64748b;
    --app-border: #e2e8f0;
    --app-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --app-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --app-radius: 12px;
    --app-radius-sm: 8px;
    --app-transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--app-background);
    color: var(--app-text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header Styles */
.header {
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
    padding: 1.5rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--app-shadow);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

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

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--app-text);
    line-height: 1.2;
}

.tagline {
    font-size: 0.875rem;
    color: var(--app-text-muted);
    margin-top: 0.25rem;
}

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

/* Section Styles */
.section {
    background: var(--app-surface);
    border-radius: var(--app-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--app-shadow);
    border: 1px solid var(--app-border);
}

.section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--app-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Color Input Section */
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.color-input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--app-text);
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--app-background);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    padding: 0.5rem;
    transition: border-color var(--app-transition);
}

.color-picker-wrapper:focus-within {
    border-color: var(--app-primary);
}

.color-picker-wrapper input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--app-border);
    border-radius: 6px;
}

.hex-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.875rem;
    color: var(--app-text);
    text-transform: uppercase;
    outline: none;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--app-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--app-transition);
}

.btn-icon {
    font-size: 1rem;
}

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

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

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

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

.btn-export {
    background: var(--app-background);
    color: var(--app-text);
    border: 1px solid var(--app-border);
    flex: 1;
    justify-content: center;
    min-width: 140px;
}

.btn-export:hover {
    border-color: var(--app-primary);
    color: var(--app-primary);
}

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

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    background: var(--app-primary);
    color: white;
}

.btn-small:hover {
    background: #1d4ed8;
}

/* WCAG Scores Section */
.score-overview {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.overall-score {
    flex-shrink: 0;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--app-primary), var(--app-secondary));
    color: white;
    box-shadow: var(--app-shadow-lg);
}

.score-circle.score-pass {
    background: linear-gradient(135deg, #059669, #10b981);
}

.score-circle.score-warning {
    background: linear-gradient(135deg, #d97706, #f59e0b);
}

.score-circle.score-fail {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.score-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.score-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
    opacity: 0.9;
}

.wcag-levels {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.wcag-level {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--app-background);
    border-radius: var(--app-radius-sm);
    border: 1px solid var(--app-border);
    min-width: 140px;
}

.wcag-level.pass {
    border-color: #10b981;
    background: #ecfdf5;
}

.wcag-level.fail {
    border-color: #ef4444;
    background: #fef2f2;
}

.level-badge {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--app-text);
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
    border-radius: 6px;
}

.wcag-level.pass .level-badge {
    background: #059669;
}

.wcag-level.fail .level-badge {
    background: #dc2626;
}

.level-status {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--app-text);
}

/* Contrast Checker Section */
.contrast-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.contrast-card {
    background: var(--app-background);
    border-radius: var(--app-radius-sm);
    padding: 1rem;
    border: 1px solid var(--app-border);
}

.contrast-preview {
    height: 60px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.contrast-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.contrast-label {
    font-size: 0.75rem;
    color: var(--app-text-muted);
}

.contrast-ratio {
    font-weight: 700;
    font-size: 1rem;
}

.contrast-badges {
    display: flex;
    gap: 0.25rem;
}

.wcag-badge {
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    background: var(--app-border);
    color: var(--app-text-muted);
}

.wcag-badge.pass {
    background: #dcfce7;
    color: #166534;
}

.wcag-badge.fail {
    background: #fee2e2;
    color: #991b1b;
}

/* Theme Preview Section */
.preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--app-radius-sm);
    border: 1px solid var(--app-border);
}

.preview-card {
    padding: 1.25rem;
    border-radius: var(--app-radius-sm);
}

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

.preview-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.preview-badge {
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.preview-text {
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

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

.preview-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity var(--app-transition);
}

.preview-btn:hover {
    opacity: 0.9;
}

.preview-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.preview-form h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.preview-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.preview-input-group label {
    font-size: 0.75rem;
    font-weight: 500;
}

.preview-input,
.preview-textarea {
    padding: 0.625rem 0.875rem;
    border-radius: 6px;
    font-size: 0.875rem;
    border: 1px solid;
    outline: none;
    font-family: inherit;
}

.preview-textarea {
    min-height: 80px;
    resize: vertical;
}

.preview-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
    border-radius: var(--app-radius-sm);
}

.preview-nav-item {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--app-transition);
}

/* Export Section */
.export-options {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.export-output {
    background: #1e293b;
    border-radius: var(--app-radius-sm);
    overflow: hidden;
}

.export-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #0f172a;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 500;
}

#exportCode {
    padding: 1rem;
    margin: 0;
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: #e2e8f0;
}

#exportCode code {
    white-space: pre;
}

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

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

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

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

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--app-text);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--app-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--app-shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: #059669;
}

.toast.error {
    background: #dc2626;
}

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

    .logo {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }

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

    .main-content {
        padding: 1rem;
    }

    .section {
        padding: 1.25rem;
    }

    .score-overview {
        flex-direction: column;
        align-items: flex-start;
    }

    .wcag-levels {
        width: 100%;
    }

    .wcag-level {
        flex: 1;
        min-width: auto;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    .export-options {
        flex-direction: column;
    }

    .btn-export {
        width: 100%;
    }

    .preview-container {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .color-grid {
        grid-template-columns: 1fr;
    }

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

    .preview-container {
        grid-template-columns: 1fr;
    }

    .score-circle {
        width: 100px;
        height: 100px;
    }

    .score-value {
        font-size: 2rem;
    }
}

/* Accessibility - Focus Styles */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .header,
    .action-buttons,
    .export-section,
    .footer {
        display: none;
    }

    .section {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
