/* ═══════════════════════════════════════════════════════════
   EWI Markets Hub
   ═══════════════════════════════════════════════════════════ */

/* ── Hub layout ─────────────────────────────────────────────────────────────── */

.mkt-hub {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height, 70px));
    overflow: hidden;
}

/* ── Category tabs ───────────────────────────────────────────────────────────── */

.mkt-hub__tabs {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-alt, #111);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
}

.mkt-hub__tabs::-webkit-scrollbar {
    display: none;
}

.mkt-hub__tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.mkt-hub__tab:hover {
    color: var(--text);
    border-color: var(--border);
}

.mkt-hub__tab.is-active {
    background: rgba(77, 163, 255, 0.1);
    border-color: rgba(77, 163, 255, 0.3);
    color: var(--accent, #4DA3FF);
}

/* ── Body ────────────────────────────────────────────────────────────────────── */

.mkt-hub__body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */

.mkt-hub__sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--bg-alt, #111);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px 0;
    position: relative;
    transition: width 0.2s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.mkt-hub__sidebar.is-collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
}

.mkt-hub__sidebar-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    z-index: 10;
    line-height: 0;
}

.mkt-hub__sidebar-toggle:hover {
    color: var(--text);
}

.mkt-hub__sidebar-cat {
    display: none;
    padding: 0 8px;
}

.mkt-hub__sidebar-cat.is-active {
    display: block;
}

.mkt-hub__group {
    margin-bottom: 16px;
}

.mkt-hub__group-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-faint, #555);
    padding: 0 8px;
    margin: 0 0 6px;
}

.mkt-hub__asset-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 8px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.8125rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.12s;
}

.mkt-hub__asset-btn:hover {
    background: var(--bg-hover, #1a1a1a);
    color: var(--text);
}

.mkt-hub__asset-btn.is-active {
    background: rgba(77, 163, 255, 0.1);
    color: var(--accent, #4DA3FF);
}

.mkt-hub__asset-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mkt-hub__live-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #4caf50;
    flex-shrink: 0;
    animation: mkt-pulse-dot 2s infinite;
}

.mkt-hub__asset-price {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--text-faint, #555);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ── Main panel ──────────────────────────────────────────────────────────────── */

.mkt-hub__panel {
    flex: 1;
    overflow-y: auto;
    background: var(--bg, #0f0f0f);
    min-width: 0;
}

/* ── Welcome screen ──────────────────────────────────────────────────────────── */

.mkt-hub__welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    text-align: center;
    padding: 40px 20px;
}

.mkt-hub__welcome-inner h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--text);
}

.mkt-hub__welcome-inner p {
    color: var(--text-muted);
    margin: 0 0 24px;
    max-width: 400px;
}

.mkt-hub__quick-assets {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.mkt-hub__quick-btn {
    padding: 10px 20px;
    background: rgba(77, 163, 255, 0.1);
    border: 1px solid rgba(77, 163, 255, 0.2);
    border-radius: 8px;
    color: var(--accent, #4DA3FF);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.mkt-hub__quick-btn:hover {
    background: rgba(77, 163, 255, 0.2);
    border-color: rgba(77, 163, 255, 0.4);
}

/* ── Content area ────────────────────────────────────────────────────────────── */

.mkt-hub__content {
    min-height: 100%;
}

/* ── Loading spinner ─────────────────────────────────────────────────────────── */

.mkt-hub__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 0;
}

.mkt-hub__loading p {
    margin: 0;
    font-size: 0.875rem;
}

.mkt-hub__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent, #4DA3FF);
    border-radius: 50%;
    animation: mkt-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

/* ── Animations ──────────────────────────────────────────────────────────────── */

@keyframes mkt-spin {
    to { transform: rotate(360deg); }
}

@keyframes mkt-pulse-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* ── Sidebar collapsed — toggle floats left ──────────────────────────────────── */

.mkt-hub__sidebar.is-collapsed .mkt-hub__sidebar-toggle {
    position: fixed;
    left: 0;
    top: calc(var(--header-height, 70px) + 60px);
    background: var(--bg-alt, #111);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 6px 6px 0;
    padding: 8px 6px;
}

/* ── Tablet + Mobile dropdown ───────────────────────────────────────────────── */

/* ── Featured Charts tab ─────────────────────────────────────────────────────── */

.mkt-hub__tab--featured {
    margin-left: auto;
    border-color: transparent;
    color: var(--text-muted);
}

.mkt-hub__tab--featured:hover {
    border-color: rgba(77, 163, 255, 0.3);
    color: var(--accent, #4DA3FF);
}

.mkt-hub__tab--featured.is-active {
    background: rgba(77, 163, 255, 0.12);
    border-color: rgba(77, 163, 255, 0.4);
    color: var(--accent, #4DA3FF);
}

/* ── Featured sections layout ────────────────────────────────────────────────── */

.mkt-featured-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    height: 100%;
    overflow: hidden;
}

.mkt-featured-section {
    padding: 24px 20px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
}

.mkt-featured-section:last-child {
    border-right: none;
}

.mkt-featured-section__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.mkt-featured-empty {
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 20px 0;
}

/* ── Featured card grid ──────────────────────────────────────────────────────── */

.mkt-featured-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

/* ── Featured card ───────────────────────────────────────────────────────────── */

.mkt-featured-card {
    background: var(--bg-alt, #111);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: border-color 0.15s;
}

.mkt-featured-card:hover {
    border-color: rgba(77, 163, 255, 0.3);
}

.mkt-featured-card__img-wrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--bg, #0f0f0f);
    position: relative;
}

.mkt-featured-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Gallery carousel overlay ────────────────────────────────────────────────
   Every element here is position:absolute inside .mkt-featured-card__img-wrap,
   which stays a fixed aspect-ratio:16/9 box regardless — the carousel adds
   zero height to the card, no matter how many images a post has. */

.mkt-gallery-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.mkt-gallery-slide.is-active {
    opacity: 1;
    pointer-events: auto;
}

.mkt-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    color: #fff;
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s, background 0.15s;
    z-index: 2;
}

/* Always visible (not hover-only) — hover has no equivalent on touch
   devices, and this grid has to work there. */
.mkt-gallery-nav:hover,
.mkt-gallery-nav:focus-visible {
    opacity: 1;
    background: rgba(0, 0, 0, 0.75);
}

.mkt-gallery-nav--prev { left: 6px; }
.mkt-gallery-nav--next { right: 6px; }

.mkt-gallery-dots {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 2;
}

.mkt-gallery-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s, background 0.15s;
}

/* Active state differs by size AND opacity, not color alone — a same-size,
   color-only difference is invisible to colorblind viewers and washes out
   on low-contrast displays; the size/opacity jump reads as "active"
   independent of hue perception. */
.mkt-gallery-dot.is-active {
    width: 7px;
    height: 7px;
    background: #fff;
    opacity: 1;
}

.mkt-featured-card__body {
    padding: 10px 12px 12px;
}

.mkt-featured-card__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.mkt-featured-card__asset {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent, #4DA3FF);
}

.mkt-featured-card__tf {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg, #0f0f0f);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
}

.mkt-featured-card__bias {
    height: 28px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
    margin-left: auto;
}

.mkt-featured-card__title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mkt-featured-card__link {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent, #4DA3FF);
    text-decoration: none;
    display: inline-block;
}

.mkt-featured-card__link:hover {
    text-decoration: underline;
}

/* ── Locked overlay ──────────────────────────────────────────────────────────── */

.mkt-featured-card--locked .mkt-featured-card__img {
    filter: blur(6px);
    transform: scale(1.04);
}

.mkt-featured-card__lock-overlay {
    position: absolute;
    inset: 0 0 auto 0;
    height: calc(100% * 9 / 16);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.45);
    text-align: center;
}

.mkt-featured-card__lock-icon {
    font-size: 1.5rem;
}

.mkt-featured-card__lock-msg {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.mkt-featured-card__upgrade {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent, #4DA3FF);
    text-decoration: none;
    border: 1px solid var(--accent, #4DA3FF);
    border-radius: 4px;
    padding: 2px 8px;
    margin-top: 2px;
}

.mkt-featured-card__upgrade:hover {
    background: rgba(77, 163, 255, 0.15);
}

@media (max-width: 1024px) {

    .mkt-hub__body {
        flex-direction: column;
    }

    /* Hide the static sidebar, replace with dropdown */
    .mkt-hub__sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow: visible;
        padding: 8px 12px;
        position: relative;
    }

    .mkt-hub__sidebar.is-collapsed {
        width: 100%;
        padding: 8px 12px;
        overflow: visible;
    }

    .mkt-hub__sidebar-toggle {
        display: none;
    }

    .mkt-hub__sidebar.is-collapsed .mkt-hub__sidebar-toggle {
        display: none;
        position: static;
    }

    /* Dropdown trigger button */
    .mkt-hub__dropdown-trigger {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 10px 14px;
        background: var(--bg-alt, #111);
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--text);
        font-size: 0.875rem;
        font-weight: 600;
        cursor: pointer;
    }

    .mkt-hub__dropdown-trigger .arrow {
        transition: transform 0.2s;
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .mkt-hub__dropdown-trigger.is-open .arrow {
        transform: rotate(180deg);
    }

    /* Dropdown list */
    .mkt-hub__sidebar-cat {
        display: none !important;
    }

    .mkt-hub__dropdown-list {
        display: none;
        position: absolute;
        top: calc(100% + 4px);
        left: 12px;
        right: 12px;
        background: var(--bg-alt, #111);
        border: 1px solid var(--border);
        border-radius: 8px;
        z-index: 999;
        max-height: 340px;
        overflow-y: auto;
        padding: 8px 0;
        box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    }

    .mkt-hub__dropdown-list.is-open {
        display: block;
    }

    .mkt-hub__dropdown-group-label {
        font-size: 0.6rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: var(--text-faint, #555);
        padding: 8px 14px 4px;
    }

    .mkt-hub__dropdown-item {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 9px 14px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 0.875rem;
        cursor: pointer;
        text-align: left;
    }

    .mkt-hub__dropdown-item:hover {
        background: var(--bg-hover, #1a1a1a);
        color: var(--text);
    }

    .mkt-hub__dropdown-item.is-active {
        color: var(--accent, #4DA3FF);
        background: rgba(77,163,255,0.08);
    }

    .mkt-hub__tab--featured {
        margin-left: 0;
    }

    .mkt-featured-sections {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .mkt-featured-section {
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow: visible;
    }

    .mkt-featured-section:last-child {
        border-bottom: none;
    }
}