/*
Theme Name: Rankolab App
Theme URI:  https://app.rankolab.com
Author:     Rankolab
Description: Headless SaaS Dashboard Theme for the Rankolab AI Growth Platform.
Version:    1.0.0
*/

/* ───────────────────────────────────────────
   DESIGN TOKENS
─────────────────────────────────────────── */
:root {
    --color-bg: #070a10;
    --color-surface: #0d1117;
    --color-elevated: #161b22;
    --color-border: rgba(255, 255, 255, 0.07);
    --color-primary: #5b6cf9;
    --color-secondary: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;

    --text-primary: #e6edf3;
    --text-secondary: #7d8590;
    --text-muted: #484f58;

    --sidebar-width: 260px;
    --header-height: 60px;
    --radius: 12px;
    --radius-sm: 8px;

    --shadow-card: 0 4px 32px rgba(0, 0, 0, 0.4);
    --glow-primary: 0 0 20px rgba(91, 108, 249, 0.3);
}

/* ───────────────────────────────────────────
   RESET & BASE
─────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    background: var(--color-bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ───────────────────────────────────────────
   LAYOUT SHELL
─────────────────────────────────────────── */
#app-shell {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ───────────────────────────────────────────
   SIDEBAR
─────────────────────────────────────────── */
.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 0;
    position: relative;
    z-index: 10;
    transition: width 0.3s ease;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.5px;
    gap: 10px;
}

.sidebar-brand .brand-dot {
    width: 8px;
    height: 8px;
    background: var(--color-primary);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--color-primary);
    animation: blink-dot 2.5s ease-in-out infinite;
}

@keyframes blink-dot {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 12px var(--color-primary);
    }

    50% {
        opacity: 0.4;
        box-shadow: none;
    }
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 8px 8px 4px;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13.5px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(91, 108, 249, 0.12);
    color: var(--color-primary);
}

.nav-item .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active .nav-icon {
    opacity: 1;
}

/* Status badge in nav */
.nav-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 100px;
    background: rgba(91, 108, 249, 0.2);
    color: var(--color-primary);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--color-border);
}

.workspace-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--color-elevated);
    cursor: pointer;
    transition: background 0.15s;
}

.workspace-pill:hover {
    background: rgba(255, 255, 255, 0.05);
}

.workspace-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--color-primary), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.workspace-name {
    font-weight: 600;
    font-size: 13px;
}

.workspace-plan {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ───────────────────────────────────────────
   MAIN PANEL
─────────────────────────────────────────── */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ───────────────────────────────────────────
   TOP HEADER
─────────────────────────────────────────── */
.app-topbar {
    height: var(--header-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-breadcrumb {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-breadcrumb .current {
    color: var(--text-primary);
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-elevated);
    border: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.15s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

/* ───────────────────────────────────────────
   CONTENT AREA
─────────────────────────────────────────── */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 28px;
    background: var(--color-bg);
}

/* Page Title */
.page-header {
    margin-bottom: 28px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ───────────────────────────────────────────
   STATS STRIP
─────────────────────────────────────────── */
.stats-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.stat-delta {
    font-size: 12px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-delta.up {
    color: var(--color-secondary);
}

.stat-delta.neutral {
    color: var(--text-muted);
}

/* ───────────────────────────────────────────
   CARDS
─────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ───────────────────────────────────────────
   FORM CONTROLS
─────────────────────────────────────────── */
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-textarea {
    width: 100%;
    background: var(--color-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--color-primary);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

/* ───────────────────────────────────────────
   BUTTONS
─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 0 0 0 rgba(91, 108, 249, 0);
    transition: box-shadow 0.2s, transform 0.1s;
}

.btn-primary:hover {
    box-shadow: var(--glow-primary);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-ghost {
    background: var(--color-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--color-border);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

/* Loading spinner inside btn */
.btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ───────────────────────────────────────────
   RESULT OUTPUT BOXES
─────────────────────────────────────────── */
.result-block {
    margin-top: 20px;
    background: #0d1117;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fadeSlideIn 0.3s ease forwards;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-elevated);
}

.result-topbar-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-copy-btn {
    font-size: 11px;
    color: var(--color-primary);
    cursor: pointer;
    font-weight: 600;
}

.result-json {
    padding: 20px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: #adbac7;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 500px;
    overflow-y: auto;
}

/* Error block */
.alert-error {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    margin-top: 16px;
    font-size: 13px;
    line-height: 1.5;
}

.alert-error svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
}

/* ───────────────────────────────────────────
    TABS
─────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 20px;
}

.tab {
    padding: 8px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ───────────────────────────────────────────
   STATUS INDICATORS
─────────────────────────────────────────── */
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.green {
    background: var(--color-secondary);
    box-shadow: 0 0 6px var(--color-secondary);
}

.status-dot.blue {
    background: var(--color-primary);
}

.status-dot.red {
    background: var(--color-danger);
}


/* ───────────────────────────────────────────
   LOGIN PAGE
─────────────────────────────────────────── */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--color-bg);
    background-image: radial-gradient(ellipse at 30% 20%, rgba(91, 108, 249, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(124, 58, 237, 0.08) 0%, transparent 50%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-card);
}

.login-logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    text-align: center;
}

.login-logo span {
    color: var(--color-primary);
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    margin-bottom: 32px;
}

/* ───────────────────────────────────────────
   SCROLLBAR
─────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ───────────────────────────────────────────
   UTILITY
─────────────────────────────────────────── */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 8px;
}

.gap-4 {
    gap: 16px;
}

.mt-1 {
    margin-top: 4px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-4 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

.w-full {
    width: 100%;
}

.text-muted {
    color: var(--text-secondary);
}

.text-xs {
    font-size: 12px;
}

.font-bold {
    font-weight: 700;
}

.hidden {
    display: none;
}

@media (max-width: 768px) {
    .app-sidebar {
        display: none;
    }

    .stats-strip {
        grid-template-columns: 1fr 1fr;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .leads-table th,
    .leads-table td {
        font-size: 11px;
        padding: 8px;
    }
}

/* ═══════════════════════════════════════════
   SEO RESULT CARD UI
═══════════════════════════════════════════ */
.seo-result-wrap {
    animation: fadeSlideIn 0.35s ease forwards;
}

/* Score ring */
.seo-score-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--color-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.seo-score-ring {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
}

.seo-score-ring svg {
    width: 72px;
    height: 72px;
    transform: rotate(-90deg);
}

.seo-score-ring span {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    color: var(--score-color, #fff);
}

/* Meta strip */
.seo-meta-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.seo-meta-item {
    background: var(--color-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.seo-meta-item span {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.seo-meta-item strong {
    font-size: 13px;
    font-weight: 600;
    word-break: break-word;
}

/* Sections */
.seo-section {
    margin-bottom: 16px;
    background: var(--color-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.seo-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.02);
}

/* Issue list */
.seo-issue-list {
    padding: 8px 0;
}

.seo-issue-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.seo-issue-row:last-child {
    border-bottom: none;
}

.seo-severity {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    margin-top: 2px;
}

.seo-sev-critical,
.seo-sev-high {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.seo-sev-medium,
.seo-sev-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
}

.seo-sev-low,
.seo-sev-info {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}

/* Keyword chips */
.seo-kw-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px;
}

.seo-kw-chip {
    background: rgba(91, 108, 249, 0.12);
    border: 1px solid rgba(91, 108, 249, 0.25);
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 100px;
    transition: background 0.15s;
}

.seo-kw-chip:hover {
    background: rgba(91, 108, 249, 0.22);
}

/* Recommendations */
.seo-rec-list {
    padding: 14px 14px 14px 32px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.seo-rec-list li {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Raw toggle */
.seo-raw-toggle summary {
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    padding: 8px 14px;
    background: var(--color-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    list-style: none;
}

.seo-raw-toggle summary:hover {
    color: var(--text-primary);
}

.seo-copy {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 11px;
    padding: 4px 10px;
    font-family: inherit;
}

/* ═══════════════════════════════════════════
   LEADS TABLE
═══════════════════════════════════════════ */
.leads-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.leads-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--color-border);
}

.leads-table td {
    padding: 11px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    vertical-align: middle;
}

.leads-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.leads-table tbody tr:last-child td {
    border-bottom: none;
}

.leads-loading {
    padding: 32px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Status badges */
.status-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-ok,
.badge-good {
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-good {
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.25);
}

.badge-err {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-neutral {
    background: rgba(161, 161, 170, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--color-border);
}

/* ═══════════════════════════════════════════
   ACTIVITY SKELETON LOADER
═══════════════════════════════════════════ */
.activity-placeholder {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 0;
}

.activity-skeleton {
    height: 40px;
    background: linear-gradient(90deg, var(--color-elevated) 25%, rgba(255, 255, 255, 0.06) 50%, var(--color-elevated) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Mobile Sidebar Toggle Styles */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex !important;
    }
    .app-sidebar.active {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        width: var(--sidebar-width);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    }
}
