/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --success-bg: #d1fae5;
    --error-color: #ef4444;
    --error-bg: #fee2e2;
    --warning-color: #f59e0b;
    --warning-bg: #fef3c7;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #f9fafb;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --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-md: 8px;
    --radius-lg: 12px;
}

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

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

/* App Container */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

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

/* Main Content */
main {
    flex: 1;
}

/* Color Inputs Section */
.color-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 2rem;
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.color-input-group {
    flex: 1;
    min-width: 200px;
    max-width: 280px;
}

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

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.25rem;
}

.color-picker-wrapper input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    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(--border-color);
    border-radius: var(--radius-sm);
}

.color-picker-wrapper input[type="text"] {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    text-transform: uppercase;
    min-width: 80px;
    padding: 0.5rem;
}

.color-picker-wrapper input[type="text"]:focus {
    outline: none;
}

.copy-btn {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: color 0.2s, background-color 0.2s;
}

.copy-btn:hover {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.1);
}

.swap-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.swap-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: rotate(180deg);
}

/* Results Section */
.results-section {
    margin-bottom: 2rem;
}

.contrast-ratio {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1rem;
}

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

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

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

.wcag-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
}

.wcag-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.wcag-tests {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.test-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.test-result {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    text-transform: uppercase;
}

.test-result.pass {
    background: var(--success-bg);
    color: var(--success-color);
}

.test-result.fail {
    background: var(--error-bg);
    color: var(--error-color);
}

/* Preview Section */
.preview-section {
    margin-bottom: 2rem;
}

.preview-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.preview-container {
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s, color 0.3s;
}

.preview-large {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.preview-normal {
    font-size: 1rem;
    margin-bottom: 1rem;
    line-height: 1.7;
}

.preview-small {
    font-size: 0.75rem;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.preview-button {
    padding: 0.75rem 1.5rem;
    border: 2px solid currentColor;
    background: transparent;
    color: inherit;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: opacity 0.2s;
}

.preview-button:hover {
    opacity: 0.8;
}

/* Suggestions Section */
.suggestions-section {
    margin-bottom: 2rem;
}

.suggestions-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.suggestions-intro {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.suggestions-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.suggestion-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.suggestion-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.suggestion-preview {
    width: 100%;
    height: 60px;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.suggestion-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.suggestion-ratio {
    font-weight: 600;
    color: var(--text-primary);
}

.suggestion-type {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.7rem;
}

.no-suggestions {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--success-color);
    background: var(--success-bg);
    border-radius: var(--radius-md);
}

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

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

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

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

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

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

/* Responsive Design */
@media (max-width: 640px) {
    .app-container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .color-inputs {
        flex-direction: column;
        align-items: stretch;
    }

    .color-input-group {
        max-width: none;
    }

    .swap-btn {
        align-self: center;
    }

    .ratio-value {
        font-size: 2.5rem;
    }

    .wcag-results {
        grid-template-columns: 1fr;
    }

    .preview-container {
        padding: 1.5rem;
    }

    .preview-large {
        font-size: 1.25rem;
    }

    .suggestions-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 400px) {
    .suggestions-container {
        grid-template-columns: 1fr;
    }
}

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

/* Focus styles for accessibility */
button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
