/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 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);
    --transition: all 0.2s ease;
}

/* 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, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

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

/* Header */
header {
    text-align: center;
    padding: 40px 20px;
    color: white;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tagline {
    font-size: 1.125rem;
    opacity: 0.9;
    margin-top: 8px;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.card h2 {
    font-size: 1.25rem;
    color: var(--gray-800);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-100);
}

/* Input Section */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.input-with-unit {
    display: flex;
    gap: 8px;
}

.input-with-unit input[type="number"] {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.input-with-unit input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-with-unit select {
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.input-with-unit select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.unit-label {
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: var(--gray-100);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* Screen Size Section */
.screen-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.screen-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.screen-btn:hover {
    border-color: var(--primary-light);
    background: var(--gray-50);
}

.screen-btn.active {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.screen-btn .icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.screen-btn .label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

.screen-btn .size {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 2px;
}

.custom-screen {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: 8px;
    flex-wrap: wrap;
}

.custom-screen label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
}

.custom-screen input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.875rem;
}

.custom-screen input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.custom-screen span {
    color: var(--gray-400);
}

.btn-secondary {
    padding: 8px 16px;
    background: var(--gray-200);
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition);
}

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

/* Contrast Section */
.color-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.color-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.color-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

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

.color-input-wrapper input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 1rem;
    font-family: monospace;
    text-transform: uppercase;
}

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

.contrast-result {
    background: var(--gray-50);
    border-radius: 12px;
    padding: 20px;
}

.ratio-display {
    text-align: center;
    margin-bottom: 20px;
}

.ratio-label {
    display: block;
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.ratio-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

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

.wcag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.wcag-label {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.wcag-status {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
}

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

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

/* Preview Section */
.preview-container {
    display: flex;
    justify-content: center;
}

.preview-frame {
    width: 100%;
    max-width: 500px;
    background: var(--gray-100);
    border-radius: 16px;
    padding: 16px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.preview-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-text {
    text-align: center;
    transition: var(--transition);
}

.preview-info {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    padding: 0 8px;
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Analysis Section */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.analysis-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: 12px;
}

.analysis-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.analysis-content {
    flex: 1;
}

.analysis-content h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.score-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.score-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.score-fill.warning {
    background: linear-gradient(90deg, var(--warning-color), var(--error-color));
}

.analysis-text {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Suggestions Section */
.suggestions-list {
    display: grid;
    gap: 12px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--gray-50);
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
    flex-wrap: wrap;
    gap: 12px;
}

.suggestion-info {
    flex: 1;
    min-width: 200px;
}

.suggestion-title {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.suggestion-description {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.suggestion-preview {
    padding: 8px 16px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.btn-apply {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Guidelines Section */
.guidelines-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    background: var(--gray-100);
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    background: var(--gray-200);
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.guideline-item {
    padding: 16px;
    background: var(--gray-50);
    border-radius: 12px;
    margin-bottom: 12px;
}

.guideline-item:last-child {
    margin-bottom: 0;
}

.guideline-item h4 {
    font-size: 1rem;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.guideline-item p,
.guideline-item ul {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.6;
}

.guideline-item ul {
    margin-left: 20px;
    margin-top: 8px;
}

.guideline-item li {
    margin-bottom: 4px;
}

.guideline-item strong {
    color: var(--gray-700);
}

/* Footer */
footer {
    text-align: center;
    padding: 24px;
    margin-top: 24px;
    color: white;
}

footer a {
    color: white;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

footer a:hover {
    text-decoration: underline;
    opacity: 0.9;
}

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

    header {
        padding: 24px 12px;
    }

    .logo-section {
        flex-direction: column;
        gap: 12px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .card {
        padding: 16px;
    }

    .card h2 {
        font-size: 1.125rem;
    }

    .screen-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .screen-btn {
        padding: 12px 8px;
    }

    .screen-btn .icon {
        font-size: 1.25rem;
    }

    .screen-btn .label {
        font-size: 0.75rem;
    }

    .screen-btn .size {
        font-size: 0.625rem;
    }

    .custom-screen {
        flex-direction: column;
        align-items: stretch;
    }

    .custom-screen input {
        width: 100%;
    }

    .color-inputs {
        grid-template-columns: 1fr;
    }

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

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

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

    .suggestion-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .guidelines-tabs {
        gap: 6px;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .screen-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .input-with-unit {
        flex-direction: column;
    }

    .input-with-unit select {
        width: 100%;
    }
}

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

.card {
    animation: fadeIn 0.3s ease forwards;
}

.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }
.card:nth-child(7) { animation-delay: 0.35s; }

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Focus states */
button:focus,
input:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --gray-200: #666;
        --gray-300: #555;
        --gray-400: #444;
    }

    .card {
        border: 2px solid var(--gray-800);
    }
}
