/* ============================================================
   SEO Opportunity Finder - CSS Principal
   Dark Mode Premium - Inspirado em Semrush/Ahrefs
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --bg-primary:    #0f172a;
    --bg-secondary:  #1e293b;
    --bg-card:       #1e293b;
    --bg-card-hover: #263348;
    --border-color:  rgba(255,255,255,0.08);
    --text-primary:  #f1f5f9;
    --text-muted:    #94a3b8;
    --accent:        #6366f1;
    --accent-hover:  #5254cc;
    --success:       #10b981;
    --warning:       #f59e0b;
    --danger:        #ef4444;
    --info:          #06b6d4;
    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 4px 24px rgba(0,0,0,0.3);
    --shadow-sm:     0 2px 8px rgba(0,0,0,0.2);
}

/* ─── Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

/* ─── Wrapper ───────────────────────────────────────── */
.wrapper { min-height: 100vh; }

/* ─── Sidebar ───────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-icon { font-size: 22px; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav {
    flex: 1;
    list-style: none;
    padding: 12px 12px 0;
    margin: 0;
}

.nav-section {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 12px 8px 6px;
    text-transform: uppercase;
}

.nav-item { margin-bottom: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-link:hover { background: rgba(99,102,241,0.1); color: var(--text-primary); }
.nav-link.active { background: rgba(99,102,241,0.2); color: var(--accent); }
.nav-link i { font-size: 16px; flex-shrink: 0; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.api-usage { font-size: 12px; color: var(--text-muted); }

/* ─── Main Content ──────────────────────────────────── */
.main-content { min-width: 0; overflow-x: hidden; }

/* ─── Topbar ────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 99;
}

/* ─── Page Content ──────────────────────────────────── */
.page-content { padding: 24px; }

/* ─── Cards ─────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    font-weight: 600;
}

.card-body { padding: 18px; }

/* ─── Stat Cards ────────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
}

.stat-card:hover { border-color: rgba(99,102,241,0.4); transform: translateY(-1px); box-shadow: var(--shadow); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-body { flex: 1; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-suffix { font-size: 14px; color: var(--text-muted); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-action { display: flex; flex-direction: column; justify-content: center; }

/* ─── Tables ────────────────────────────────────────── */
.table { --bs-table-bg: transparent; color: var(--text-primary); }
.table thead th { background: rgba(255,255,255,0.03); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border-color); padding: 10px 12px; }
.table td { border-color: var(--border-color); vertical-align: middle; padding: 10px 12px; }
.table-hover tbody tr:hover { background: rgba(255,255,255,0.03); }

/* ─── Buttons ───────────────────────────────────────── */
.btn { border-radius: 8px; font-weight: 500; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ─── Forms ─────────────────────────────────────────── */
.form-control, .form-select {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
}

.form-control:focus, .form-select:focus {
    background: rgba(255,255,255,0.08);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.input-group-text {
    background: rgba(255,255,255,0.05);
    border-color: var(--border-color);
    color: var(--text-muted);
}

/* ─── Score Indicators ───────────────────────────────── */
.score-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    border: 2px solid currentColor;
}

.score-circle.score-success { color: var(--success); }
.score-circle.score-primary { color: var(--accent); }
.score-circle.score-warning { color: var(--warning); }
.score-circle.score-danger  { color: var(--danger); }

.score-gauge { font-size: 18px; font-weight: 700; }
.score-gauge-excellent { color: var(--success); }
.score-gauge-good { color: var(--accent); }
.score-gauge-medium { color: var(--warning); }
.score-gauge-poor { color: var(--danger); }

.mini-bar { width: 60px; height: 5px; background: rgba(255,255,255,0.1); border-radius: 99px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 99px; }

/* ─── Cluster Cards ──────────────────────────────────── */
.cluster-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    transition: all 0.2s;
}

.cluster-card:hover { border-color: rgba(99,102,241,0.4); transform: translateY(-1px); }

.cluster-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; gap: 8px; }
.cluster-name { font-weight: 600; font-size: 14px; }

.cluster-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.metric { text-align: center; }
.metric-value { font-size: 18px; font-weight: 700; }
.metric-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── Gap Cards ──────────────────────────────────────── */
.gap-card {
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid;
    position: relative;
    overflow: hidden;
}

.gap-high { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.3); }
.gap-medium { background: rgba(245,158,11,0.06); border-color: rgba(245,158,11,0.3); }
.gap-low { background: rgba(16,185,129,0.06); border-color: rgba(16,185,129,0.3); }

.gap-badge { margin-bottom: 10px; }
.gap-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.gap-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }
.gap-metrics { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; }

/* ─── Opportunity Cards ───────────────────────────────── */
.opportunity-card {
    border-radius: var(--radius);
    padding: 18px;
    border: 1px solid;
}

.opp-excellent { background: rgba(16,185,129,0.07); border-color: rgba(16,185,129,0.3); }
.opp-good      { background: rgba(99,102,241,0.07); border-color: rgba(99,102,241,0.3); }
.opp-medium    { background: rgba(245,158,11,0.07); border-color: rgba(245,158,11,0.3); }
.opp-poor      { background: rgba(239,68,68,0.07); border-color: rgba(239,68,68,0.3); }

.opp-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; gap: 8px; }
.opp-keyword { font-weight: 700; font-size: 15px; }
.opp-cluster { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.opp-score-circle { text-align: center; }
.score-number { font-size: 26px; font-weight: 700; }
.score-label { margin-top: 2px; }

.opp-metrics { margin-top: 12px; }
.opp-metric { margin-bottom: 8px; }
.opp-metric-bar { height: 6px; background: rgba(255,255,255,0.1); border-radius: 99px; overflow: hidden; margin-bottom: 2px; }
.opp-metric-fill { height: 100%; border-radius: 99px; }
.opp-recommendation { background: rgba(245,158,11,0.1); border-radius: 8px; padding: 10px; margin-top: 12px; font-size: 12px; }

/* ─── Score Breakdown (modal) ────────────────────────── */
.opp-score-display { padding: 20px 0; }
.score-big { font-size: 64px; font-weight: 800; line-height: 1; }

/* ─── Analysis Steps ─────────────────────────────────── */
.analysis-card { border: 1px solid rgba(99,102,241,0.3); background: linear-gradient(135deg, rgba(99,102,241,0.05) 0%, transparent 100%); }
.analysis-icon { width: 52px; height: 52px; background: rgba(99,102,241,0.2); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }

.analysis-steps { display: flex; flex-direction: column; gap: 8px; }
.analysis-step { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 8px; background: rgba(255,255,255,0.03); border: 1px solid transparent; transition: all 0.3s; }
.analysis-step.step-active { background: rgba(99,102,241,0.1); border-color: rgba(99,102,241,0.3); }
.analysis-step.step-done { opacity: 0.6; }
.step-icon { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,0.05); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-label { flex: 1; font-size: 13px; }
.step-status { flex-shrink: 0; }

/* ─── Keyword Header (result page) ──────────────────── */
.keyword-header { border: 1px solid rgba(99,102,241,0.3); }
.keyword-badge { width: 52px; height: 52px; background: rgba(99,102,241,0.2); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.result-stat-value { font-size: 22px; font-weight: 700; }
.result-stat-label { font-size: 11px; color: var(--text-muted); }

/* ─── Competitor Cards ────────────────────────────────── */
.competitor-avatar {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: white;
    flex-shrink: 0;
}

.competitor-avatar-lg {
    width: 64px; height: 64px; border-radius: 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 20px; color: white;
    margin: 0 auto;
}

.user-avatar-sm {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px; color: white;
    flex-shrink: 0;
}

/* ─── Titles List ────────────────────────────────────── */
.titles-list { max-height: 400px; overflow-y: auto; }
.title-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; border-bottom: 1px solid var(--border-color);
    cursor: pointer; transition: background 0.15s;
}
.title-item:hover { background: rgba(255,255,255,0.04); }
.title-item:hover .title-copy-icon { opacity: 1; }
.title-num { font-size: 11px; color: var(--text-muted); width: 20px; flex-shrink: 0; font-weight: 600; }
.title-text { flex: 1; font-size: 13px; }
.title-copy-icon { opacity: 0; color: var(--text-muted); transition: opacity 0.15s; }

/* ─── SILO Map ────────────────────────────────────────── */
.silo-map { padding: 20px 0; }
.silo-root { display: flex; justify-content: center; margin-bottom: 24px; }
.silo-node { padding: 10px 20px; border-radius: 10px; font-weight: 600; font-size: 13px; display: inline-block; }
.silo-main { background: rgba(99,102,241,0.3); border: 2px solid var(--accent); color: var(--text-primary); }
.silo-category { background: rgba(16,185,129,0.2); border: 1px solid rgba(16,185,129,0.4); color: var(--success); }
.silo-branches { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; }
.silo-branch { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 140px; }
.silo-leaves { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.silo-leaf { background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); border-radius: 6px; padding: 6px 12px; font-size: 12px; text-align: center; }

/* ─── Satellite Cards ────────────────────────────────── */
.satellite-card {
    display: flex; gap: 12px;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 14px;
    transition: all 0.2s;
}
.satellite-card:hover { border-color: rgba(99,102,241,0.4); }
.satellite-number {
    width: 28px; height: 28px; border-radius: 8px;
    background: rgba(99,102,241,0.2); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.satellite-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.satellite-keyword { font-size: 12px; color: var(--text-muted); }

/* ─── Monetization Cards ─────────────────────────────── */
.monetization-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 18px; transition: all 0.2s;
}
.monetization-card:hover { border-color: rgba(99,102,241,0.4); transform: translateY(-1px); }
.monet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.monet-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.monet-idea { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.monet-reason { font-size: 12px; color: var(--text-muted); margin-bottom: 0; }

/* ─── Auth Layout ────────────────────────────────────── */
.auth-body {
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-image: radial-gradient(ellipse at top, rgba(99,102,241,0.1) 0%, transparent 60%);
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.brand-icon-lg { font-size: 48px; display: block; margin-bottom: 12px; }
.brand-title { font-size: 24px; font-weight: 800; color: var(--text-primary); margin-bottom: 6px; }
.brand-tagline { color: var(--text-muted); font-size: 14px; }

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.auth-card-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-card-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

.auth-divider {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin: 20px 0;
    position: relative;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border-color);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.demo-credentials {
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 8px;
    padding: 10px 14px;
    text-align: center;
}

.auth-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px 24px;
    margin-top: 32px;
    max-width: 600px;
}

.auth-feature {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 13px;
}
.feature-icon { font-size: 16px; }

/* ─── Loading Overlay ────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.85);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.loading-overlay.active { display: flex; }
.loading-content { text-align: center; }

/* ─── Progress ───────────────────────────────────────── */
.progress { background: rgba(255,255,255,0.08); border-radius: 99px; }
.progress-bar { border-radius: 99px; }

/* ─── Tabs ───────────────────────────────────────────── */
.nav-tabs { border-bottom: 1px solid var(--border-color); }
.nav-tabs .nav-link { color: var(--text-muted); border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 16px; font-size: 13px; }
.nav-tabs .nav-link:hover { color: var(--text-primary); border-bottom-color: rgba(99,102,241,0.4); background: none; }
.nav-tabs .nav-link.active { color: var(--accent); border-bottom-color: var(--accent); background: none; font-weight: 600; }

/* ─── Accordion ──────────────────────────────────────── */
.accordion-item { background: var(--bg-card); border-color: var(--border-color); }
.accordion-button { background: var(--bg-card); color: var(--text-primary); font-size: 13px; }
.accordion-button:not(.collapsed) { background: rgba(99,102,241,0.1); color: var(--accent); box-shadow: none; }
.accordion-button::after { filter: invert(1); }
.accordion-body { background: var(--bg-card); color: var(--text-muted); font-size: 13px; }

/* ─── Badges ─────────────────────────────────────────── */
.badge { font-weight: 500; }

/* ─── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: -100%; z-index: 1000; height: 100vh; }
    .sidebar.open { left: 0; }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; display: none; }
    .sidebar-overlay.active { display: block; }
    .page-content { padding: 16px; }
}

/* ─── Toast Container ────────────────────────────────── */
#toastContainer .toast { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-primary); }
