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

:root {
    --bg-dark: #1a1d23;
    --bg-sidebar: #1e2128;
    --bg-sidebar-hover: #282c34;
    --bg-sidebar-active: #2d3240;
    --bg-content: #f5f6fa;
    --bg-card: #ffffff;
    --bg-input: #f0f1f5;
    --text-primary: #1a1d23;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-sidebar: #b0b7c3;
    --text-sidebar-active: #ffffff;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #eff6ff;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --info: #6366f1;
    --info-bg: #eef2ff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-content);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

/* ===== LOGIN SCREEN ===== */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #1a1d23 0%, #2d3240 100%);
}

.login-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.login-tab {
    flex: 1;
    padding: 8px;
    text-align: center;
    border: none;
    background: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.login-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    background: var(--bg-input);
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
    background: var(--bg-card);
}

.login-error {
    color: var(--error);
    font-size: 13px;
    margin-bottom: 12px;
    display: none;
}

.login-error.show { display: block; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    width: 100%;
}

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

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

.btn-secondary:hover { background: var(--border-light); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover { background: var(--bg-sidebar-hover); color: var(--text-sidebar-active); }

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

/* ===== APP LAYOUT ===== */
#app-screen { display: none; height: 100vh; }
#app-screen.active { display: flex; flex-direction: column; }

/* Top bar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    z-index: 100;
    flex-shrink: 0;
}

.topbar-toggle {
    display: none;
    width: 36px; height: 36px;
    background: none; border: none;
    color: var(--text-sidebar);
    cursor: pointer;
    font-size: 20px;
    align-items: center;
    justify-content: center;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
}

.topbar-brand svg { width: 24px; height: 24px; }

.topbar-site-select {
    margin-left: 24px;
    padding: 6px 12px;
    background: var(--bg-sidebar);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    min-width: 200px;
    outline: none;
}

.topbar-site-select:focus { border-color: var(--accent); }

.topbar-spacer { flex: 1; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.topbar-user:hover { background: var(--bg-sidebar-hover); }

.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

/* Main layout */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    overflow-y: auto;
    flex-shrink: 0;
    border-right: 1px solid rgba(255,255,255,0.06);
    padding: 8px 0;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-section {
    margin-bottom: 4px;
}

.sidebar-section-title {
    padding: 12px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-sidebar);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
}

.sidebar-item.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    border-left-color: var(--accent);
}

.sidebar-item svg, .sidebar-item .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-item.active svg, .sidebar-item.active .icon { opacity: 1; }

.sidebar-item .lock-icon {
    margin-left: auto;
    font-size: 11px;
    opacity: 0.5;
}

.sidebar-item.locked { opacity: 0.5; }
.sidebar-item.locked:hover { opacity: 0.7; }

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-content);
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Page header */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    padding: 20px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== GRID ===== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ===== SCORE GAUGE ===== */
.score-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
}

.score-circle {
    position: relative;
    width: 120px;
    height: 120px;
}

.score-circle svg {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}

.score-circle .bg {
    fill: none;
    stroke: var(--border-light);
    stroke-width: 8;
}

.score-circle .progress {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: 700;
}

.score-label {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== METRIC CARDS ===== */
.metric-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.metric-card .metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-card .metric-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.metric-card .metric-change {
    font-size: 12px;
    margin-top: 8px;
    font-weight: 500;
}

.metric-card .metric-change.up { color: var(--success); }
.metric-card .metric-change.down { color: var(--error); }

/* ===== TOOL INPUT BAR ===== */
.tool-input-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tool-input-bar input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: var(--bg-card);
    transition: var(--transition);
}

.tool-input-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.tool-input-bar .btn { white-space: nowrap; width: auto; }

/* ===== ISSUE LIST ===== */
.issue-list { list-style: none; }

.issue-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.issue-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.issue-badge.pass { background: var(--success-bg); color: var(--success); }
.issue-badge.warning { background: var(--warning-bg); color: var(--warning); }
.issue-badge.error { background: var(--error-bg); color: var(--error); }
.issue-badge.info { background: var(--info-bg); color: var(--info); }

.issue-text { font-size: 13px; color: var(--text-primary); }
.issue-detail { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ===== TABLE ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.data-table tr:hover td { background: var(--bg-input); }

.data-table .truncate {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== TAGS ===== */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.tag-green { background: var(--success-bg); color: var(--success); }
.tag-yellow { background: var(--warning-bg); color: var(--warning); }
.tag-red { background: var(--error-bg); color: var(--error); }
.tag-blue { background: var(--info-bg); color: var(--info); }
.tag-gray { background: var(--bg-input); color: var(--text-secondary); }

/* ===== PROGRESS BAR ===== */
.progress-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ===== LOADING ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
    gap: 10px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 480px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal-actions .btn { width: auto; }

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--accent); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== SERP PREVIEW ===== */
.serp-preview {
    background: white;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    max-width: 600px;
}

.serp-preview .serp-url {
    font-size: 12px;
    color: #202124;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.serp-preview .serp-title {
    font-size: 20px;
    color: #1a0dab;
    text-decoration: none;
    font-weight: 400;
    line-height: 1.3;
    margin-bottom: 4px;
    display: block;
    cursor: pointer;
}

.serp-preview .serp-title:hover { text-decoration: underline; }

.serp-preview .serp-description {
    font-size: 14px;
    color: #4d5156;
    line-height: 1.5;
}

/* ===== CODE / PRE ===== */
.code-block {
    background: var(--bg-dark);
    color: #e5e7eb;
    padding: 16px;
    border-radius: var(--radius-md);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .topbar-toggle { display: flex; }
    .topbar-site-select { min-width: 120px; margin-left: 8px; }

    .sidebar {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        bottom: 0;
        z-index: 99;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open { transform: translateX(0); }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 98;
    }

    .sidebar-backdrop.active { display: block; }

    .main-content { padding: 16px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

    .login-container { padding: 24px; }
}

/* ===== UPGRADE MODAL ===== */
.upgrade-content {
    text-align: center;
    padding: 16px 0;
}

.upgrade-content svg { width: 48px; height: 48px; color: var(--accent); margin-bottom: 16px; }
.upgrade-content h3 { font-size: 18px; margin-bottom: 8px; }
.upgrade-content p { color: var(--text-secondary); margin-bottom: 20px; }
.upgrade-content .btn { width: auto; display: inline-flex; }

/* ===== HEADING TREE ===== */
.heading-tree { list-style: none; }
.heading-tree li { padding: 4px 0; font-size: 13px; }
.heading-tree .h1 { font-weight: 700; font-size: 15px; }
.heading-tree .h2 { padding-left: 16px; font-weight: 600; }
.heading-tree .h3 { padding-left: 32px; }
.heading-tree .h4 { padding-left: 48px; font-size: 12px; color: var(--text-secondary); }
.heading-tree .h5 { padding-left: 64px; font-size: 12px; color: var(--text-muted); }
.heading-tree .h6 { padding-left: 80px; font-size: 12px; color: var(--text-muted); }

/* ===== KEYWORD DENSITY BAR ===== */
.density-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.density-bar .word { width: 120px; font-size: 13px; font-weight: 500; }
.density-bar .bar-wrap { flex: 1; height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.density-bar .bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.5s ease; }
.density-bar .count { width: 50px; text-align: right; font-size: 12px; color: var(--text-secondary); }
.density-bar .pct { width: 50px; text-align: right; font-size: 12px; color: var(--text-secondary); }

/* ===== ADD SITE ===== */
.site-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.site-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.site-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); }
.site-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }

.site-card .site-url { font-size: 14px; font-weight: 600; margin-bottom: 4px; color: var(--text-primary); }
.site-card .site-name { font-size: 12px; color: var(--text-secondary); margin-bottom: 12px; }
.site-card .site-score { font-size: 24px; font-weight: 700; }
.site-card .site-issues { font-size: 12px; color: var(--text-secondary); }

/* ===== OG PREVIEW ===== */
.og-preview {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    max-width: 500px;
}

.og-preview img { width: 100%; height: 260px; object-fit: cover; background: var(--bg-input); }
.og-preview .og-body { padding: 12px 16px; }
.og-preview .og-site { font-size: 12px; color: var(--text-muted); text-transform: uppercase; }
.og-preview .og-title { font-size: 16px; font-weight: 600; margin: 4px 0; color: var(--text-primary); }
.og-preview .og-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.4; }
