/* SEO Auditor v2.1 — Stylesheet */

:root {
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-sidebar: #cbd5e1;
    --border: #e2e8f0;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #eab308;
    --info: #3b82f6;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07);
    --sidebar-w: 220px;
    --header-h: 60px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login Page ──────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-container { width: 100%; max-width: 400px; padding: 1rem; }

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
}
.login-logo h1 { font-size: 1.5rem; color: var(--text); margin-top: .5rem; }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; }
.login-footer { text-align: center; color: rgba(255,255,255,.4); margin-top: 2rem; font-size: .8rem; }

/* ── Layout ──────────────────────────────────────────── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: .75rem .5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    text-decoration: none;
    transition: background .15s;
    font-size: .9rem;
}
.nav-item:hover { background: var(--bg-sidebar-hover); text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }

.nav-divider { height: 1px; background: rgba(255,255,255,.08); margin: .5rem .75rem; }

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info { display: flex; align-items: center; gap: .5rem; }

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
}

.user-name { font-size: .85rem; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-header {
    height: var(--header-h);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title { font-size: 1.25rem; font-weight: 600; }

.content-body {
    flex: 1;
    padding: 1.5rem;
    max-width: 1200px;
    width: 100%;
}

.main-footer {
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-size: .8rem;
    border-top: 1px solid var(--border);
}

/* ── Buttons ─────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }

.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-icon {
    background: none;
    border: none;
    color: var(--text-sidebar);
    cursor: pointer;
    padding: .25rem;
    border-radius: var(--radius-sm);
}
.btn-icon:hover { background: rgba(255,255,255,.1); }

/* ── Forms ────────────────────────────────────────────── */

.form-container { max-width: 640px; }

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: none; }
.form-section h3 { margin-bottom: 1rem; font-size: 1rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: .3rem; font-size: .85rem; }

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-family: inherit;
    background: var(--bg-card);
    transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

.form-hint { display: block; margin-top: .25rem; font-size: .8rem; color: var(--text-muted); }

.form-actions {
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
    padding-top: 1rem;
}

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    cursor: pointer;
}

.input-with-action { display: flex; gap: .5rem; }
.input-with-action input { flex: 1; }

.input-sm {
    padding: .3rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .85rem;
}

/* ── Alerts ───────────────────────────────────────────── */

.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: .875rem;
}
.alert.hidden { display: none; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Stats ────────────────────────────────────────────── */

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

.stat-card {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .85rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Sections ─────────────────────────────────────────── */

.section { margin-bottom: 2rem; }
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.section-header h2 { font-size: 1.1rem; }

/* ── Project Cards ────────────────────────────────────── */

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

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    display: block;
}
.project-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .5rem;
}

.project-domain { font-size: .8rem; color: var(--text-muted); }
.project-name { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; }

.project-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.project-score { font-size: 1.5rem; font-weight: 700; }
.score-grade { margin-right: .25rem; }
.score-value { font-size: .9rem; font-weight: 400; }

.project-meta { text-align: right; font-size: .8rem; color: var(--text-muted); }
.project-meta span { display: block; }

.score-big { font-size: 2rem; font-weight: 700; }

/* ── Info Grid ────────────────────────────────────────── */

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

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.info-label { font-size: .8rem; color: var(--text-muted); margin-bottom: .25rem; }
.info-value { font-size: 1.1rem; font-weight: 600; }

/* ── Tables ───────────────────────────────────────────── */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.data-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    padding: .75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: #f8fafc; }

/* ── Badges ───────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 500;
    background: #f1f5f9;
    color: var(--text-muted);
}

.status-badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 600;
}
.status-completed { background: #dcfce7; color: #166534; }
.status-running, .status-crawling, .status-analyzing { background: #dbeafe; color: #1e40af; }
.status-failed { background: #fef2f2; color: #b91c1c; }
.status-pending, .status-queued { background: #f1f5f9; color: #64748b; }
.status-cancelled { background: #fef3c7; color: #92400e; }

/* ── Tags ─────────────────────────────────────────────── */

.tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: var(--radius-sm);
    font-size: .8rem;
    background: #eff6ff;
    color: #1e40af;
}
.tag-warning { background: #fef3c7; color: #92400e; }

/* ── Settings ─────────────────────────────────────────── */

.settings-layout { display: flex; flex-direction: column; }

.settings-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab {
    padding: .6rem 1.25rem;
    font-size: .9rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.settings-content { max-width: 640px; }

/* ── Toolbar ──────────────────────────────────────────── */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* ── Utilities ────────────────────────────────────────── */

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.loading { padding: 2rem; text-align: center; color: var(--text-muted); }
.error { padding: 1rem; text-align: center; color: var(--danger); }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state p { margin-bottom: 1rem; }

/* ── Score Hero ───────────────────────────────────────── */

.score-hero {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.score-gauge {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 6px solid;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.gauge-grade { font-size: 2.5rem; font-weight: 800; line-height: 1; }
.gauge-score { font-size: .9rem; color: var(--text-muted); }

.score-stats { flex: 1; }

.score-badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .85rem;
}

.impact-badge {
    display: inline-block;
    padding: .15rem .4rem;
    border-radius: var(--radius-sm);
    font-size: .75rem;
    font-weight: 500;
}
.impact-critical { background: #fef2f2; color: #b91c1c; }
.impact-high { background: #fff7ed; color: #c2410c; }
.impact-medium { background: #fefce8; color: #a16207; }
.impact-low { background: #eff6ff; color: #1d4ed8; }
.impact-info { background: #f1f5f9; color: #64748b; }

/* ── Audit Running ────────────────────────────────────── */

.audit-status-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.status-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.progress-container { margin: 1rem 0; }

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
    border-radius: 6px;
    transition: width .5s ease;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-top: .4rem;
    font-size: .85rem;
    color: var(--text-muted);
}

.audit-stats-row {
    display: flex;
    gap: 1.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.mini-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.mini-stat strong { font-size: 1.3rem; }
.mini-stat span { font-size: .75rem; color: var(--text-muted); }

.current-url {
    margin-top: .5rem;
    font-size: .85rem;
    word-break: break-all;
}
.current-url code {
    background: var(--bg);
    padding: .1rem .4rem;
    border-radius: var(--radius-sm);
    font-size: .8rem;
}

.audit-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: .875rem;
}

/* ── Audit Log ────────────────────────────────────────── */

.audit-log {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: var(--radius);
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: .8rem;
    line-height: 1.8;
}

.log-entry { display: flex; gap: .5rem; }
.log-time { color: #64748b; min-width: 65px; }
.log-phase { color: #60a5fa; min-width: 80px; }
.log-msg { color: #e2e8f0; }
.log-entry.log-error .log-msg { color: #f87171; }
.log-entry.log-warning .log-msg { color: #fbbf24; }

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-row { flex-direction: column; gap: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .projects-grid { grid-template-columns: 1fr; }
    .project-info-grid { grid-template-columns: repeat(2, 1fr); }
}
