/* Layout base defined in main.css — not duplicated here */

/* ============================================================================
   HEADER — Thinner, title + subtitle + back button only
   ============================================================================ */

.top-header {
    position: relative;
    z-index: 500;
    padding: 8px 16px 8px 20px;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 1px 0 var(--border-color);
    min-height: 44px;
    gap: 12px;
}

/* ── Back button — pill: arrow + previous page name + section badge ─────── */

.header-back-btn {
    display: none; /* shown by router when there is history */
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 8px;
    background: transparent;
    border: 1.5px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    flex-shrink: 0;
    white-space: nowrap;
    max-width: 240px;
    overflow: hidden;
}

.header-back-btn.visible {
    display: flex;
}

.header-back-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-back-btn i {
    font-size: 16px;
    flex-shrink: 0;
}

.header-back-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
    flex-shrink: 1;
}

.header-back-badge {
    padding: 2px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── Title area — left-aligned, vertically centered ──────────────────────── */

.header-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    pointer-events: none;
    padding-left: 4px;
}

.page-title-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-subtitle-header {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Section tabs bar — first child of .page-content, floating pills ─────── */

.section-tabs-bar {
    display: none; /* shown for business/intelligence pages */
}

/* When visible: floating pill group centred at top of canvas — no background row.
   text-align:center on block + inline-flex child is the reliable cross-context centering. */
.section-tabs-bar.visible {
    display: block;
    text-align: center;
    width: 100%;
    /* page-content has 20px top padding, so: above=20+4=24px, below=24px — balanced */
    padding: 4px 0 24px;
}

/* Pill group container — thin border box */
.section-tab-group {
    display: inline-flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
    gap: 2px;
}

.section-tab-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1.5px solid transparent;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.section-tab-pill i { font-size: 13px; }
.section-tab-pill:hover { color: var(--text-secondary); }

/* Light mode active pill — dark/black pill on grey group bg */
.section-tab-pill.active {
    background: #1c1c1e;
    color: #ffffff;
    border-color: transparent;
    box-shadow: none;
}

/* Dark mode active pill — card bg + orange border + light grey text */
[data-theme="dark"] .section-tab-pill.active {
    background: var(--bg-card);
    border-color: var(--primary);
    color: #b8b8b8;
    box-shadow: none;
}

/* ── TOKEN BARS ──────────────────────────────────────────────────────────── */

.token-display {
    display: flex;
    gap: 16px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-width: 190px;
}

.token-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.token-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.token-bar-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.token-bar-value {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}

.token-bar-track {
    height: 8px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.token-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.token-bar-fill.high   { background: linear-gradient(90deg, #10b981, #34d399); }
.token-bar-fill.medium { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.token-bar-fill.low    { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ── Profile dropdown (now anchored from sidebar avatar) ─────────────────── */

.profile-dropdown {
    position: fixed;
    left: 88px;
    bottom: 16px;
    width: 244px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    display: none;
    z-index: 1200;
    overflow: hidden;
}

.profile-dropdown.show { display: block; }

.profile-dropdown-header {
    padding: 16px 16px 14px;
}

/* ── Redesigned avatar + info row ──── */
.pd-avatar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.pd-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 800;
    color: var(--text-secondary);
    flex-shrink: 0;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.02em;
}

.pd-info {
    flex: 1;
    min-width: 0;
}

.pd-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pd-email {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pd-plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(249,115,22,0.10);
    border: 1px solid rgba(249,115,22,0.25);
    color: #f97316;
    letter-spacing: 0.05em;
}

/* ── Dropdown items ──── */
.profile-dropdown-item {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.14s;
}

.profile-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pd-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.14s;
}

.profile-dropdown-item:hover .pd-item-icon {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Logout row — danger tint */
.pd-logout { margin-top: 2px; }
.pd-logout span { color: var(--danger); }
.pd-logout-icon { color: var(--danger) !important; }
.pd-logout:hover { background: rgba(239,68,68,0.06); }
.pd-logout:hover .pd-logout-icon { background: rgba(239,68,68,0.10) !important; }

.profile-dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 2px 0;
}

/* ── Notification dropdown (anchored from sidebar bell) ──────────────────── */

.notification-dropdown {
    position: fixed;
    left: 88px;
    bottom: 80px;
    width: 340px;
    max-height: 520px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    z-index: 1200;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.notification-dropdown.open,
.notification-dropdown.active { display: flex; }

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.notif-header-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.notif-header-btns {
    display: flex;
    align-items: center;
    gap: 6px;
}

.notif-text-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.14s;
}

.notif-text-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.notif-icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    transition: all 0.14s;
}

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

.notif-tabs {
    display: flex;
    gap: 2px;
    padding: 8px 10px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.notif-tab {
    padding: 4px 10px;
    border-radius: 6px;
    border: none;
    font-size: 11px;
    font-weight: 600;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.12s;
}

.notif-tab:hover { background: var(--bg-hover); color: var(--text-secondary); }
.notif-tab.active { background: var(--bg-secondary); color: var(--text-primary); }

.notif-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    min-height: 80px;
    max-height: 300px;
}

.notif-footer {
    padding: 8px 14px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.notif-unread-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

/* notification bell in sidebar */
.notification-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    background: #ef4444;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 2px solid #2e2e2e;
    display: none;
}

.notification-badge.visible { display: flex; }

/* ── ASIN product header block (replaces title area on ASIN page) ──────────── */

.asin-header-block {
    display: none; /* shown by AsinPage.open() */
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.asin-hdr-thumb-wrap {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.asin-hdr-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.asin-hdr-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.asin-hdr-top {
    display: flex;
    align-items: center;
    gap: 6px;
}

.asin-hdr-asin {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace, inherit;
    letter-spacing: 0.02em;
}

.asin-hdr-copy {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 0;
    transition: all 0.12s;
    flex-shrink: 0;
}

.asin-hdr-copy:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.asin-hdr-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.asin-hdr-meta {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asin-hdr-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.asin-hdr-score-pill {
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    border: 1.5px solid transparent;
}

/* Uses score-badge-inline classes: elite/good/fair/weak */
.asin-hdr-price-pill {
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.asin-hdr-roi-pill {
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.3);
    font-size: 12px;
    font-weight: 700;
    color: #059669;
}

.asin-hdr-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.asin-hdr-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.14s;
    border: 1.5px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
}

.asin-hdr-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.asin-hdr-btn.primary {
    background: #1a1a1a;
    color: #ffffff;
    border-color: #1a1a1a;
}

.asin-hdr-btn.primary:hover {
    background: #333;
    border-color: #333;
}

[data-theme="dark"] .asin-hdr-btn.primary {
    background: #2e2e2e;
    border-color: #3a3a3a;
    color: #d0d0d0;
}
[data-theme="dark"] .asin-hdr-btn.primary:hover {
    background: #3a3a3a;
    border-color: #444444;
    color: #f0f0f0;
}

/* Dark mode header — same surface as canvas, flat top layer with thin separator */
[data-theme="dark"] .top-header {
    background: var(--bg-main);        /* matches #1a1a1a canvas — seamless */
    border-bottom: 1px solid rgba(255,255,255,0.06);
    border-radius: 0;                  /* no internal rounded corners */
    box-shadow: none;
}


/* Dark mode section tab group — uses the same var(--bg-secondary) from main.css */
[data-theme="dark"] .section-tab-group {
    background: var(--bg-secondary); /* #303030 */
    border: 1px solid rgba(0,0,0,0.70);
}

/* Dark mode notification + profile dropdowns */
[data-theme="dark"] .notification-dropdown {
    background: #242424;
    border-color: rgba(0,0,0,0.35);
    box-shadow: 0 12px 40px rgba(0,0,0,0.7);
}
[data-theme="dark"] .notif-header,
[data-theme="dark"] .notif-tabs,
[data-theme="dark"] .notif-footer {
    border-color: rgba(0,0,0,0.35);
}
[data-theme="dark"] .notif-tab { color: #5c5c5c; }
[data-theme="dark"] .notif-tab:hover { background: rgba(255,255,255,0.04); color: #909090; }
[data-theme="dark"] .notif-tab.active { background: #2e2e2e; color: #ebebeb; }

/* ── Dark mode typography: titles = white, subtitles/muted = grey ─────────── */
[data-theme="dark"] .page-title-header,
[data-theme="dark"] .panel-title,
[data-theme="dark"] .chart-title,
[data-theme="dark"] .home-panel-title,
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3 {
    color: #ffffff;
}

[data-theme="dark"] .page-subtitle-header,
[data-theme="dark"] .home-panel-sub,
[data-theme="dark"] .chart-subtitle,
[data-theme="dark"] .panel-meta,
[data-theme="dark"] .section-subtitle {
    color: #aaaaaa;  /* lighter — matches --text-muted */
}
