:root {
    --primary: #111;
    --primary-hover: #000;
    --secondary: #555;
    --border: #ddd;
    --bg-card: #f8f8f8;
    --bg-error: #fee;
    --text-error: #900;
    --text-muted: #666;
    --badge-good: #10b981;
    --badge-warning: #f59e0b;
    --badge-poor: #ef4444;
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
    color: var(--primary);
    background: #fff;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

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

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

.description {
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

.analyzer {
    margin-bottom: 3rem;
}

.analyzer-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.url-input-group {
    width: 100%;
}

#urlInput {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

#urlInput:focus {
    outline: none;
    border-color: var(--primary);
}

.depth-controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--secondary);
}

.depth-controls select,
.depth-controls input[type="number"] {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
}

.depth-controls input[type="number"] {
    width: 70px;
}

button {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: var(--primary-hover);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #e8e8e8;
}

.btn-small {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}

.error-box {
    background: var(--bg-error);
    color: var(--text-error);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.loading-box {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

.results {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
}

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

.results-header h2 {
    font-size: 1.75rem;
}

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

.metric-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

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

/* Google WRS Card - Special styling */
#wrsCard {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #0ea5e9;
}

#wrsCard h3 {
    color: #0369a1;
    font-weight: 600;
}

#wrsCard .cwv-section h4 {
    color: #0284c7;
}

.metric-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--secondary);
}

.metric-value {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.metric-unit {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.badge.good {
    background: var(--badge-good);
    color: #fff;
}

.badge.needs-improvement {
    background: var(--badge-warning);
    color: #fff;
}

.badge.poor {
    background: var(--badge-poor);
    color: #fff;
}

.badge.elevated {
    background: var(--badge-warning);
    color: #fff;
}

.badge.low {
    background: var(--badge-good);
    color: #fff;
}

.badge.high {
    background: var(--badge-poor);
    color: #fff;
}

.badge.normal {
    background: var(--badge-good);
    color: #fff;
}

.head-warnings {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.head-warnings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.head-warnings-title {
    font-weight: 600;
    color: #0369a1;
}

.head-issue-group {
    margin-bottom: 12px;
}

.head-issue-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.head-summary-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(15, 23, 42, 0.08);
    color: var(--text-muted);
}

.head-summary-pill.poor {
    background: var(--badge-poor);
    color: #fff;
}

.head-summary-pill.needs-improvement {
    background: var(--badge-warning);
    color: #fff;
}

.head-summary-pill.elevated {
    background: var(--badge-warning);
    color: #fff;
}

.head-summary-pill.good {
    background: var(--badge-good);
    color: #fff;
}

.head-issue-group-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.head-issue-row {
    display: flex;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.04);
    margin-bottom: 6px;
}

.head-issue-row .badge {
    flex-shrink: 0;
    font-size: 0.75rem;
    margin-bottom: 0;
}

.head-issue-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
}

.head-issue-message {
    font-weight: 600;
}

.head-issue-count {
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 4px;
}

.head-issue-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.metric-details p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

.url-text {
    word-break: break-all;
}

.signal-list {
    list-style: none;
}

.signal-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.signal-list li:last-child {
    border-bottom: none;
}

.status-badge {
    font-weight: 600;
    font-size: 0.875rem;
}

.status-badge.found {
    color: var(--badge-good);
}

.status-badge.missing {
    color: var(--badge-poor);
}

.sitemap-urls {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: 4px;
    font-size: 0.875rem;
}

.sitemap-urls p {
    margin: 0 0 0.5rem 0;
    font-weight: 600;
    color: var(--secondary);
}

.sitemap-urls ul {
    list-style: none;
    margin: 0;
}

.sitemap-urls ul li {
    padding: 0.25rem 0;
    color: var(--text-muted);
    word-break: break-all;
}

.sitemap-urls ul li a {
    color: var(--primary);
    text-decoration: none;
}

.sitemap-urls ul li a:hover {
    text-decoration: underline;
}

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

.cwv-section h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.cwv-section ul {
    list-style: none;
}

.cwv-section ul li {
    margin: 0.5rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* SEO Failures Section */
.seo-failures-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #fff3cd;
    border: 2px solid var(--badge-warning);
    border-radius: var(--radius);
}

.seo-failures-section h4 {
    margin: 0 0 1rem 0;
    color: var(--badge-poor);
    font-size: 1.1rem;
}

.seo-failures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.failure-stat {
    text-align: center;
    padding: 1rem;
    background: #fff;
    border-radius: var(--radius);
    border-left: 3px solid var(--badge-poor);
}

.failure-count {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--badge-poor);
}

.failure-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.seo-failures-details {
    margin-top: 1rem;
}

.seo-failures-details summary {
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 0;
}

.seo-failures-details .failure-category {
    margin: 1rem 0;
}

.seo-failures-details .failure-category h5 {
    font-size: 0.95rem;
    color: var(--badge-poor);
    margin-bottom: 0.5rem;
}

.seo-failures-details .failure-item {
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: #fff;
    border-left: 3px solid var(--badge-poor);
    border-radius: 4px;
    font-size: 0.875rem;
}

.seo-failures-details .failure-item strong {
    color: var(--primary);
}

.seo-failures-details .failure-item ul {
    margin: 0.5rem 0 0 1.5rem;
    list-style: disc;
}

.raw-json-details {
    margin-top: 2rem;
    cursor: pointer;
}

.raw-json-details summary {
    font-weight: 600;
    padding: 0.5rem 0;
}

.raw-json {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.875rem;
    font-family: 'Monaco', 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

.footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

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

/* Multi-page summary styles */
.multi-page-summary {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
}

.multi-page-summary h3 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-stat {
    text-align: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.page-list {
    margin-top: 1rem;
}

.page-list summary {
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 0;
    color: var(--primary);
}

.page-cards {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.page-card {
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 4px;
    border-left: 3px solid var(--badge-good);
}

.page-card.poor {
    border-left-color: var(--badge-poor);
}

.page-card.needs-improvement {
    border-left-color: var(--badge-warning);
}

.page-card-url {
    font-weight: 600;
    margin-bottom: 0.5rem;
    word-break: break-all;
    font-size: 0.875rem;
}

.page-card-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .depth-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

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

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

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