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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary-color: #0f172a;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --background: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --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: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

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

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

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

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

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

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

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

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

/* Input Section */
.input-section {
    margin-bottom: 2rem;
}

.url-input-container {
    display: flex;
    gap: 0.75rem;
    max-width: 700px;
    margin: 0 auto;
}

.url-input {
    flex: 1;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.url-input::placeholder {
    color: var(--text-muted);
}

.analyze-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    min-width: 120px;
}

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

.analyze-btn:active {
    transform: scale(0.98);
}

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

.btn-loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.hidden {
    display: none !important;
}

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

/* Results Section */
.results-section {
    animation: fadeIn 0.3s ease-out;
}

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

.results-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.results-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.analyzed-url {
    font-size: 0.875rem;
    color: var(--text-secondary);
    word-break: break-all;
}

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

.result-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.result-card:hover {
    box-shadow: var(--shadow-lg);
}

.result-card.full-width {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.card-icon {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
}

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

.card-content {
    padding: 1.25rem;
}

/* Font Families */
.font-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.font-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--background);
    border-radius: var(--radius);
}

.font-name {
    font-weight: 500;
    color: var(--text-primary);
}

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

.font-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--primary-light);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Font Sizes */
.size-analysis {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.size-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.size-stat:last-child {
    border-bottom: none;
}

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

.size-value {
    font-weight: 600;
    color: var(--text-primary);
}

.size-distribution {
    margin-top: 1rem;
}

.size-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.size-bar-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 60px;
}

.size-bar-fill {
    height: 8px;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.3s ease-out;
}

/* Line Heights */
.line-height-analysis {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.line-height-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.line-height-item:last-child {
    border-bottom: none;
}

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

.lh-value {
    font-weight: 600;
    color: var(--text-primary);
}

.lh-recommendation {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.lh-recommendation.good {
    border-left: 3px solid var(--success);
}

.lh-recommendation.warning {
    border-left: 3px solid var(--warning);
}

.lh-recommendation.bad {
    border-left: 3px solid var(--error);
}

/* Color Contrast */
.contrast-analysis {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.contrast-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: var(--radius);
}

.color-pair {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.contrast-info {
    flex: 1;
}

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

.contrast-level {
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.contrast-level.pass {
    background: #d1fae5;
    color: #065f46;
}

.contrast-level.fail {
    background: #fee2e2;
    color: #991b1b;
}

.contrast-level.aa {
    background: #fef3c7;
    color: #92400e;
}

/* Readability Score */
.readability-analysis {
    text-align: center;
}

.readability-score-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.score-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-value {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
}

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

.score-value.good {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

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

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

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

.readability-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    text-align: left;
}

.readability-metric {
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Error Section */
.error-section {
    max-width: 500px;
    margin: 2rem auto;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.error-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.error-icon {
    width: 48px;
    height: 48px;
    color: var(--error);
    margin-bottom: 1rem;
}

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

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

.retry-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--primary-light);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.2s;
}

.retry-btn:hover {
    background: #c7d2fe;
}

/* Info Section */
.info-section {
    margin-top: 3rem;
    text-align: center;
}

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

.info-grid {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.info-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

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

.limitations-note {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    background: #fef3c7;
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: #92400e;
}

/* Footer */
.footer {
    background: var(--secondary-color);
    color: var(--text-muted);
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: auto;
}

.footer a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

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

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

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

    .logo-img {
        width: 40px;
        height: 40px;
    }

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

    .analyze-btn {
        width: 100%;
    }

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

    .info-grid {
        flex-direction: column;
        gap: 1.5rem;
    }

    .readability-score-container {
        gap: 1rem;
    }

    .score-value {
        width: 70px;
        height: 70px;
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem 0.75rem;
    }

    .card-content {
        padding: 1rem;
    }

    .result-card {
        border-radius: var(--radius-lg);
    }
}

/* Animations for result cards */
.result-card {
    animation: slideUp 0.4s ease-out;
    animation-fill-mode: both;
}

.result-card:nth-child(1) { animation-delay: 0.1s; }
.result-card:nth-child(2) { animation-delay: 0.2s; }
.result-card:nth-child(3) { animation-delay: 0.3s; }
.result-card:nth-child(4) { animation-delay: 0.4s; }
.result-card:nth-child(5) { animation-delay: 0.5s; }

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
