/* ═══ 🟢 Top Status Bar (40px sticky) ═══ */
.top-bar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: var(--bg-card-solid);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), 0 4px 16px rgba(0, 0, 0, 0.08);
    margin: 0 0 16px 0;
}
[data-theme="light"] .top-bar {
    background: rgba(255, 255, 255, 0.95) !important;
}
.top-bar-content {
    height: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
}

.tb-group {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 100%;
}
.tb-group-center {
    flex: 1;
    justify-content: center;
}

.tb-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    color: var(--text);
    line-height: 1;
    white-space: nowrap;
}
.tb-clickable {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}
.tb-clickable:hover {
    background: var(--bg-hover);
}
.tb-icon {
    font-size: 0.85rem;
    line-height: 1;
}
.tb-mono {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}
.tb-sep {
    width: 1px;
    height: 18px;
    background: var(--border-strong);
    flex-shrink: 0;
}

/* Pulse for market status */
.tb-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.tb-pulse.open {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: pulse 2s ease-in-out infinite;
}
.tb-pulse.closed {
    background: var(--danger);
}

/* Pills (system, TG, MT5, pairs) */
.tb-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.74rem;
    color: var(--text);
    padding: 4px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    line-height: 1;
    white-space: nowrap;
    transition: border-color var(--transition-fast);
}
.tb-pill:hover {
    border-color: var(--primary);
}
/* Action pills (clickable, with hover effect) */
.tb-pill-action {
    cursor: pointer;
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.25);
    font-family: inherit;
    color: var(--text);
}
.tb-pill-action:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    transform: translateY(-1px);
}
.tb-pill-action .tb-pill-label {
    color: var(--text);
    font-weight: 600;
}
.tb-pill-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
}
.tb-pill-meta {
    color: var(--text-dim);
    font-size: 0.68rem;
    font-family: 'JetBrains Mono', monospace;
}

/* Special highlighted pills for important info */
#tb-scan {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.25);
}
#tb-scan:hover {
    background: rgba(99, 102, 241, 0.12);
}
#tb-sent {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
}
#tb-sent:hover {
    background: rgba(16, 185, 129, 0.12);
}
#tb-pairs {
    background: rgba(217, 119, 6, 0.08);
    border-color: rgba(217, 119, 6, 0.25);
}

/* Light mode pill variants */
[data-theme="light"] #tb-scan {
    background: rgba(99, 102, 241, 0.06) !important;
}
[data-theme="light"] #tb-sent {
    background: rgba(16, 185, 129, 0.06) !important;
}
[data-theme="light"] #tb-pairs {
    background: rgba(217, 119, 6, 0.06) !important;
}
.tb-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.tb-dot.green {
    background: var(--success);
    box-shadow: 0 0 4px var(--success);
}
.tb-dot.red {
    background: var(--danger);
}
.tb-dot.yellow {
    background: var(--warning);
}
.tb-pill.active {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success);
}
.tb-pill.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

/* Auto-update toggle */
.tb-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.74rem;
    color: var(--text-muted);
    user-select: none;
}
.tb-toggle input {
    display: none;
}
.tb-toggle-track {
    position: relative;
    width: 30px;
    height: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: background-color var(--transition-fast);
}
.tb-toggle-thumb {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 12px;
    height: 12px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-normal);
}
.tb-toggle input:checked + .tb-toggle-track {
    background: var(--success);
    border-color: var(--success);
}
.tb-toggle input:checked + .tb-toggle-track .tb-toggle-thumb {
    left: 16px;
    background: white;
}
.tb-toggle input:checked ~ .tb-toggle-label {
    color: var(--success);
}

/* Theme button (smaller for top bar) */
.tb-theme-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    width: 30px;
    height: 30px;
    min-width: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition-fast),
                background-color var(--transition-fast);
}
.tb-theme-btn:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

/* Mobile: hide some items */
@media (max-width: 1400px) {
    .tb-pill-label {
        display: none;  /* Hide "Scan:", "أُرسلت:", "أزواج:" labels */
    }
}
@media (max-width: 1200px) {
    .tb-pill-meta {
        display: none;  /* Hide "(51m)" countdown */
    }
    #tb-next-session {
        display: none;
    }
}
@media (max-width: 1024px) {
    .tb-toggle-label {
        display: none;
    }
    #tb-session {
        display: none;  /* Hide current session, keep only market status */
    }
}
@media (max-width: 900px) {
    .tb-pill[id="tb-mt5"] span:last-child {
        display: none;
    }
    #tb-system span:not(.tb-dot) {
        display: none;
    }
    #tb-tg span:not(.tb-dot) {
        display: none;
    }
}
@media (max-width: 768px) {
    .top-bar {
        height: auto;
        padding: 6px 0;
    }
    .top-bar-content {
        flex-wrap: wrap;
        gap: 6px;
        padding: 0 var(--space-sm);
    }
    .tb-group-center {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .tb-sep { display: none; }
    .tb-item { font-size: 0.7rem; }
    .tb-pill { font-size: 0.68rem; padding: 3px 7px; }
}



/* ═══ Theme Toggle Button ═══ */
.theme-toggle {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    width: 42px;
    height: 42px;
    min-width: 42px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text);
    transition: background-color var(--transition-fast),
                border-color var(--transition-fast),
                transform var(--transition-fast);
    position: relative;
    overflow: hidden;
    z-index: 10;
}
.theme-toggle:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    transform: scale(1.08);
}
.theme-toggle:active {
    transform: scale(0.92);
}
.theme-icon-dark, .theme-icon-light {
    position: absolute;
    top: 50%;
    left: 50%;
    line-height: 1;
    transition: opacity var(--transition-normal), transform var(--transition-normal);
    pointer-events: none;
}
/* Default (dark mode): show moon, hide sun */
.theme-icon-dark {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}
.theme-icon-light {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-180deg) scale(0.5);
}
/* Light mode: show sun, hide moon */
[data-theme="light"] .theme-icon-dark {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(180deg) scale(0.5);
}
[data-theme="light"] .theme-icon-light {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}



