/* ==========================================
   SEO Checker — Styles
   Based on Google Search Official Docs
   ========================================== */

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

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --pass: #16a34a;
    --pass-bg: #f0fdf4;
    --warn: #ea580c;
    --warn-bg: #fff7ed;
    --fail: #dc2626;
    --fail-bg: #fef2f2;
    --info: #0ea5e9;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* Header */
.header {
    text-align: center;
    padding: 40px 0 32px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

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

/* Input Section */
.input-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.input-group {
    display: flex;
    gap: 12px;
}

#urlInput {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#urlInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#analyzeBtn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, transform 0.1s;
}

#analyzeBtn:hover {
    background: var(--primary-hover);
}

#analyzeBtn:active {
    transform: scale(0.98);
}

#analyzeBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.input-hints {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.hint-btn {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid transparent;
    padding: 4px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.2s;
}

.hint-btn:hover {
    border-color: var(--primary);
    background: #dbeafe;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 60px 20px;
}

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

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

.loading-state p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Error State */
.error-state {
    text-align: center;
    padding: 40px 20px;
}

.error-card {
    background: var(--fail-bg);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 40px;
    max-width: 480px;
    margin: 0 auto;
}

.error-card h3 {
    color: var(--fail);
    margin: 16px 0 8px;
}

.error-card p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.error-card button {
    padding: 10px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.95rem;
}

/* Score Dashboard */
.score-dashboard {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 32px;
    margin-bottom: 16px;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.score-circle::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 6px solid var(--border);
}

.score-circle.score-a::before { border-color: #16a34a; }
.score-circle.score-b::before { border-color: #2563eb; }
.score-circle.score-c::before { border-color: #ea580c; }
.score-circle.score-d::before { border-color: #dc2626; }

.score-number {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.score-grade {
    flex: 1;
}

.score-grade h2 {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.score-summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.analyzed-url {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    margin-bottom: 24px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow);
}

.analyzed-url strong {
    color: var(--text);
}

/* Page Summary Card */
#pageSummary {
    margin-bottom: 24px;
}

.summary-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.summary-title {
    font-size: 1rem;
    font-weight: 700;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8fafc, #eff6ff);
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.summary-grid {
    padding: 12px 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.summary-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    width: 140px;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-weight: 500;
}

.summary-value {
    flex: 1;
    word-break: break-all;
    color: var(--text);
}

.summary-missing {
    color: #dc2626;
    font-style: italic;
}

.summary-note {
    padding: 10px 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: #fffbeb;
    border-top: 1px solid #fef3c7;
}

@media (max-width: 600px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }
    .summary-row {
        flex-direction: column;
        gap: 2px;
        padding: 10px 0;
    }
    .summary-label {
        width: 100%;
    }
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
    gap: 16px;
}

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

/* Result Card */
.result-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--border);
    transition: box-shadow 0.2s;
}

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

.result-card.status-pass { border-left-color: var(--pass); }
.result-card.status-warn { border-left-color: var(--warn); }
.result-card.status-fail { border-left-color: var(--fail); }
.result-card.status-info { border-left-color: var(--info); }

.card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.card-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: bold;
}

.status-pass .card-icon { background: var(--pass-bg); color: var(--pass); }
.status-warn .card-icon { background: var(--warn-bg); color: var(--warn); }
.status-fail .card-icon { background: var(--fail-bg); color: var(--fail); }
.status-info .card-icon { background: var(--primary-light); color: var(--primary); }

.card-title {
    flex: 1;
}

.card-title h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.card-status {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 20px;
}

.status-pass .card-status { background: var(--pass-bg); color: var(--pass); }
.status-warn .card-status { background: var(--warn-bg); color: var(--warn); }
.status-fail .card-status { background: var(--fail-bg); color: var(--fail); }
.status-info .card-status { background: var(--primary-light); color: var(--primary); }

.card-body {
    margin-top: 12px;
    padding-left: 40px;
}

.card-finding {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.5;
}

.card-finding strong {
    color: var(--text);
}

.card-suggestion {
    font-size: 0.85rem;
    color: #1e40af;
    background: var(--primary-light);
    padding: 12px 14px;
    border-radius: 6px;
    line-height: 1.6;
    white-space: pre-line;
    word-break: break-word;
    border: 1px solid #dbeafe;
}

.card-suggestion code {
    display: inline-block;
    background: #1e293b;
    color: #e2e8f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    margin: 1px 0;
}

.card-details {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 0.82rem;
}

.detail-label {
    color: var(--text-secondary);
}

.detail-value {
    font-weight: 500;
}

.detail-value.good { color: var(--pass); }
.detail-value.bad { color: var(--fail); }

/* Hidden */
.hidden {
    display: none !important;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 48px;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 24px 0 20px;
    }
    .header h1 {
        font-size: 1.5rem;
    }
    .input-group {
        flex-direction: column;
    }
    #analyzeBtn {
        justify-content: center;
    }
    .score-dashboard {
        flex-direction: column;
        text-align: center;
        gap: 16px;
        padding: 24px;
    }
    .input-section {
        padding: 20px;
    }
    .result-card {
        padding: 16px 18px;
    }
    .card-body {
        padding-left: 0;
    }
}
