/* ============================================
   ALPHA FINANS DATA - App Topbar Component
   Shared desktop topbar rendered on all app
   pages except the dashboard (which has its
   own dash-header).
   ============================================ */

/**
 * App Topbar
 * - Logo + title + date
 * - Market status badge (open / closed)
 * - Search, notifications and profile action buttons
 * - Hidden on mobile/tablet (max-width: 1024px) — mobile-topbar handles it
 */

/* ============================================
   TOPBAR CONTAINER
   ============================================ */

/* Wrapper injected by app-topbar.js — must not shrink in flex parents */
.app-topbar-wrapper {
    flex-shrink: 0;
}

/* CLS (erisilebilirlik-ve-performans P-01): ust cubuk betikle sonradan eklenir; eklenene kadar ayni yukseklik
   (--kabuk-bar-h) ayrilir, icerik 72 px asagi kaymaz. Cubuk eklenince yer tutucu :has() ile kalkar. >1024 px'te cubuk gorunur. */
@media (min-width: 1025px) {
    .app-main:not(:has(> .app-topbar-wrapper))::before {
        content: "";
        display: block;
        flex-shrink: 0;
        block-size: var(--kabuk-bar-h, 72px);
    }
}

.app-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px; /* dikey ortalama align-items ile; yükseklik = --kabuk-bar-h */
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border-primary);
    flex-shrink: 0;
    min-height: var(--kabuk-bar-h, 72px); /* yan menü başlığıyla AYNI yükseklik (app-sidebar.css --kabuk-bar-h) */
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

/* ============================================
   LEFT SIDE — Logo + Title + Date
   ============================================ */

.app-topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-topbar-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
}

.app-topbar-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

/* Title row: page title + optional badge */
.topbar-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-topbar-title h1,
.app-topbar-title .app-topbar-heading {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
}

.app-topbar-title span {
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.3;
    white-space: nowrap;
}

/* Subtitle with slightly muted style */
.topbar-subtitle {
    font-size: 12px;
    color: var(--color-text-muted, var(--color-text-secondary));
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

/* ============================================
   TOPBAR BADGES (PRO, AI, YENI, etc.)
   ============================================ */

.topbar-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1.4;
    white-space: nowrap;
    flex-shrink: 0;
    background: var(--color-accent-primary, #2962FF);
    color: #fff;
}

.topbar-badge-pro {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}

.topbar-badge-ai {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff;
}

.topbar-badge-new {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
}

/* ============================================
   RIGHT SIDE — Market status + Action buttons
   ============================================ */

.app-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Action buttons (search, notifications, profile) */
.app-topbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    flex-shrink: 0;
}

.app-topbar-btn:hover {
    background: var(--color-accent-primary);
    color: var(--color-text-inverse);
    border-color: var(--color-accent-primary);
}

.app-topbar-btn svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   MARKET STATUS BADGE
   ============================================ */

.app-topbar .market-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.app-topbar .market-status.open {
    background: rgba(0, 200, 83, 0.15);
    color: var(--color-market-up);
}

.app-topbar .market-status.closed {
    background: rgba(255, 82, 82, 0.15);
    color: var(--color-market-down);
}

.app-topbar .market-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: appTopbarPulse 2s infinite;
    flex-shrink: 0;
}

@keyframes appTopbarPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   RESPONSIVE — Hidden on mobile/tablet
   The mobile-topbar (rendered by app-sidebar.js)
   handles navigation on screens <= 1024px.
   ============================================ */

@media (max-width: 1280px) {
    .topbar-subtitle {
        max-width: 240px;
    }
}

@media (max-width: 1024px) {
    .app-topbar {
        display: none;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.app-topbar-btn:focus-visible {
    outline: 2px solid var(--color-accent-primary);
    outline-offset: 2px;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .app-topbar .market-status-dot {
        animation: none;
        opacity: 1;
    }
    .app-topbar-btn {
        transition: none;
    }
}


/* =============================================
   Açık Tema (Light Theme)
   ============================================= */

[data-theme="light"] .app-topbar {
    background: #FFFFFF;
    border-bottom-color: #E6E6E6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .topbar-page-title {
    color: #1a1a1a;
}

[data-theme="light"] .topbar-page-subtitle {
    color: #666;
}

[data-theme="light"] .topbar-action-btn {
    color: #555;
}

[data-theme="light"] .topbar-action-btn:hover {
    color: var(--color-accent-primary);
    background: rgba(18, 149, 235, 0.06);
}

[data-theme="light"] .topbar-logo-img {
    filter: none;
}

[data-theme="light"] .topbar-bist-badge {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

[data-theme="light"] .topbar-hamburger {
    color: #333;
}

[data-theme="light"] .topbar-hamburger:hover {
    background: rgba(0, 0, 0, 0.04);
}
