/* ============================================================
   RankScan — Modern Design System
   Inspired by Vercel/Linear precision with SEO-tool functionality
   ============================================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
    /* Surfaces */
    --bg: #fafbfc;
    --surface: #ffffff;
    --surface-hover: #f5f6f8;

    /* Text */
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Borders */
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Brand */
    --brand: #2563eb;
    --brand-hover: #1d4ed8;
    --brand-light: #eff6ff;
    --brand-ring: rgba(37, 99, 235, 0.25);

    /* Status */
    --ok: #059669;
    --ok-bg: #ecfdf5;
    --warn: #d97706;
    --warn-bg: #fffbeb;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --info: #6366f1;
    --info-bg: #eef2ff;

    /* Shadows — shadow-as-border technique */
    --shadow-border: 0 0 0 1px rgba(0, 0, 0, 0.06);
    --shadow-card: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-elevated: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-focus: 0 0 0 3px var(--brand-ring);

    /* Radii */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* --- Container --- */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem;
}

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

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.logo {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo a {
    color: var(--text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.logo a::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--brand);
    border-radius: 3px;
    transform: rotate(45deg);
}

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

.execution-time {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* --- Language Switcher --- */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.2rem;
    box-shadow: var(--shadow-border);
}

.lang-link {
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
}

.lang-link:hover { background: var(--brand-light); color: var(--brand); }
.lang-active { background: var(--brand); color: var(--text-inverse); }
.lang-active:hover { background: var(--brand-hover); color: var(--text-inverse); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.9rem;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.15s;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--brand);
    color: var(--text-inverse);
    box-shadow: var(--shadow-border);
}
.btn-primary:hover { background: var(--brand-hover); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-border);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text); background: var(--surface-hover); }

.btn-submit {
    width: 100%;
    padding: 0.85rem;
    background: var(--brand);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: var(--shadow-border);
}
.btn-submit:hover { background: var(--brand-hover); }

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1rem;
    color: var(--brand);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}
.btn-back:hover { text-decoration: underline; }
.btn-back::before { content: '←'; }

.btn-download {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    background: var(--ok);
    color: var(--text-inverse);
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.btn-download:hover { background: #047857; }

/* --- Alerts --- */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: var(--space-lg);
    font-size: 0.9rem;
    box-shadow: var(--shadow-border);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border-left: 3px solid var(--error);
}
.alert-error h2 { font-size: 1rem; margin-bottom: 0.5rem; }

.alert-success {
    background: var(--ok-bg);
    color: var(--ok);
    border-left: 3px solid var(--ok);
}
.alert-success p { margin-bottom: 0.5rem; }

.rate-limit-info {
    background: var(--warn-bg);
    color: var(--warn);
    border-left: 3px solid var(--warn);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: var(--space-lg);
    font-size: 0.9rem;
}

/* --- Form --- */
.analysis-form {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-card);
}

.form-group {
    margin-bottom: var(--space-lg);
}

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

.url-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    box-shadow: var(--shadow-border);
    transition: box-shadow 0.2s;
}
.url-input::placeholder { color: var(--text-muted); }
.url-input:focus {
    outline: none;
    box-shadow: var(--shadow-focus), var(--shadow-border);
}

/* --- Checkboxes --- */
.checks-fieldset {
    border: none;
    margin-bottom: var(--space-lg);
}

.checks-fieldset legend {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.checkbox-label,
.form-group .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
    padding: 0.4rem 0;
    margin-bottom: 0;
    user-select: none;
    transition: color 0.15s;
}
.checkbox-label:hover { color: var(--text); }

.checkbox-label span {
    line-height: 1.35;
}

.checkbox-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.checkbox-label input[type="checkbox"]:hover {
    border-color: var(--brand);
    background: var(--brand-light);
}

.checkbox-label input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-color: var(--brand);
}

.checkbox-label input[type="checkbox"]:checked {
    background: var(--brand);
    border-color: var(--brand);
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 10px;
    border: solid var(--text-inverse);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}
.checkbox-main { font-weight: 600; padding: 0.5rem 0; border-bottom: 1px solid var(--border-light); margin-bottom: 0.5rem; }
.checkbox-sub { padding-left: 1.5rem; }
.checkboxes-simple { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; margin-top: 0.5rem; }
.schema-subtypes { margin-top: 0.5rem; padding: 0.75rem; background: var(--bg); border-radius: var(--radius); }

/* --- Results --- */
.result-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-card);
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.result-detail {
    font-size: 0.9rem;
}

.result-detail p {
    margin-bottom: 0.4rem;
}

.result-detail strong {
    color: var(--text);
    font-weight: 600;
}

/* --- Badges — border-left accent --- */
.badge-ok { border-left: 3px solid var(--ok); padding-left: 0.75rem; }
.badge-warning { border-left: 3px solid var(--warn); padding-left: 0.75rem; }
.badge-error { border-left: 3px solid var(--error); padding-left: 0.75rem; }
.badge-info { border-left: 3px solid var(--brand); padding-left: 0.75rem; }

/* --- Issues List --- */
.issues {
    list-style: none;
    margin-top: 0.5rem;
}
.issues li {
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.25rem;
    background: var(--error-bg);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--error);
}

/* --- Status Colors --- */
.status-ok { color: var(--ok); font-weight: 600; }
.status-warn { color: var(--warn); font-weight: 600; }
.status-error { color: var(--error); font-weight: 600; }

/* --- Technical Params Grid --- */
.tech-params {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
.param {
    text-align: center;
    padding: 0.75rem 0.5rem;
    background: var(--bg);
    border-radius: var(--radius);
}
.param-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.param-value {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
}

/* --- Redirect Chain --- */
.redirect-chain {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--warn-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-border);
}
.redirect-chain h3 {
    font-size: 0.85rem;
    color: var(--warn);
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.redirect-list {
    list-style: none;
    font-size: 0.8rem;
    font-family: var(--font-mono);
}
.redirect-list li {
    padding: 0.3rem 0;
    border-bottom: 1px dashed #fde68a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.redirect-list li:last-child { border-bottom: none; }
.redirect-list code { word-break: break-all; color: var(--text); }
.redirect-arrow { color: var(--warn); font-weight: 600; white-space: nowrap; }
.redirect-final { color: var(--ok); font-weight: 600; white-space: nowrap; }

/* --- Scores Grid --- */
.scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0.75rem;
}
.score-card {
    text-align: center;
    padding: 0.75rem 0.5rem;
    background: var(--bg);
    border-radius: var(--radius);
}
.score-value { display: block; font-size: 1.3rem; font-weight: 700; }
.score-value.score-ok { color: var(--ok); }
.score-value.score-warn { color: var(--warn); }
.score-value.score-err { color: var(--error); }
.score-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.15rem;
}

/* --- Grade Legend --- */
.score-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
}
.grade-legend { padding: 0.15rem 0.5rem; border-radius: 4px; font-weight: 600; }
.grade-a { background: var(--ok-bg); color: var(--ok); }
.grade-b { background: var(--brand-light); color: var(--brand); }
.grade-c { background: var(--warn-bg); color: var(--warn); }
.grade-d { background: var(--error-bg); color: var(--error); }

/* --- Tips Box --- */
.tips-box {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--brand-light);
    border-radius: var(--radius);
}
.tips-box h4 { font-size: 0.85rem; font-weight: 600; color: var(--brand); margin-bottom: 0.4rem; }
.tip-item { font-size: 0.82rem; color: var(--text); margin-bottom: 0.3rem; line-height: 1.4; }
.tip-item strong { color: var(--brand); }

/* --- Validation Messages --- */
.msg-type {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-right: 0.4rem;
}
.msg-error { background: var(--error-bg); color: var(--error); }
.msg-warning { background: var(--warn-bg); color: var(--warn); }
.msg-info { background: var(--info-bg); color: var(--info); }

/* --- Heading Tree --- */
.heading-tree {
    font-size: 0.85rem;
    line-height: 1.8;
}

.htree-item {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--border-light);
}
.htree-item:last-child { border-bottom: none; }

.htree-lvl1 { padding-left: 0; }
.htree-lvl2 { padding-left: 1.5rem; }
.htree-lvl3 { padding-left: 3rem; }
.htree-lvl4 { padding-left: 4.5rem; }
.htree-lvl5 { padding-left: 6rem; }
.htree-lvl6 { padding-left: 7.5rem; }

.htree-tag {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    min-width: 2rem;
    text-align: center;
}

.htree-h1 { background: #dbeafe; color: #1e40af; }
.htree-h2 { background: #e0e7ff; color: #3730a3; }
.htree-h3 { background: #f3f4f6; color: #4b5563; }
.htree-h4 { background: #f9fafb; color: #6b7280; }
.htree-h5, .htree-h6 { background: #f9fafb; color: #9ca3af; }

.htree-text {
    color: var(--text-secondary);
}
.heading-structure {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0;
}
.heading-stat {
    background: var(--bg);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
}
.heading-structure {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

/* --- External Links Table --- */
.ext-links-table { font-size: 0.85rem; }
.ext-link-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}
.ext-link-url {
    color: var(--brand);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}
.ext-link-text { color: var(--text-secondary); font-size: 0.8rem; }
.badge-nofollow {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--warn-bg);
    color: var(--warn);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

/* --- Services / Resources --- */
.services-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.service-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--info-bg);
    color: var(--info);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.ext-resource-list { list-style: none; font-size: 0.8rem; }
.ext-resource-list li { padding: 0.2rem 0; }
.ext-resource-list code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--bg);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

/* --- Images without alt --- */
.img-alt-list { list-style: none; font-size: 0.8rem; }
.img-alt-list code { font-size: 0.75rem; }

/* --- Microdata --- */
.microdata-type {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}
.microdata-type:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
}
.footer-links a:hover { color: var(--text-secondary); }

/* ============================================================
   Cookie Consent Banner
   ============================================================ */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    padding: 1rem 1.25rem;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.cookie-banner.visible { display: flex; }
.cookie-banner p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 600px;
    line-height: 1.5;
}
.cookie-banner a {
    color: var(--brand);
    text-decoration: underline;
}
.cookie-banner .btn {
    white-space: nowrap;
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
}

/* ============================================================
   Loader
   ============================================================ */
.loader-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(250, 251, 252, 0.85);
    backdrop-filter: blur(4px);
    z-index: 999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 1.5rem;
}
.loader-overlay.active {
    display: flex;
}

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

.loader-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    animation: pulse-text 1.8s ease-in-out infinite;
}

.loader-steps {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}
.loader-step {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0;
    transform: translateY(6px);
    transition: all 0.4s ease;
}
.loader-step.visible {
    opacity: 1;
    transform: translateY(0);
}
.loader-step .step-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand);
    animation: blink 1.2s ease-in-out infinite;
}

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

@keyframes pulse-text {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@keyframes blink {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ============================================================
   Policy Page
   ============================================================ */
.policy-page {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-card);
    max-width: 800px;
    margin: 0 auto;
}
.policy-page h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    letter-spacing: -0.5px;
}
.policy-page h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}
.policy-page p, .policy-page li {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}
.policy-page ul, .policy-page ol {
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}
.policy-date {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .container { padding: 1rem 0.75rem; }
    .header { padding: 1.5rem 0 1rem; }
    .analysis-form { padding: 1.25rem; }
    .result-section { padding: 1.25rem; }
    .tech-params { grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }
    .checkboxes-simple { grid-template-columns: 1fr; }
    .cookie-banner { flex-direction: column; text-align: center; gap: 0.75rem; }
    .policy-page { padding: 1.5rem; }
}

@media (max-width: 480px) {
    .tech-params { grid-template-columns: 1fr 1fr; }
    .scores-grid { grid-template-columns: repeat(3, 1fr); }
    .footer-links { gap: 1rem; }
    .header-top { flex-direction: column; }
}
