/* ==========================================================================
   SELECTION STUDIO — TOP BAR CANONICAL STYLES
   Location: /studio/css/studio-topbar.css
   ========================================================================== */

.selection-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height, 56px);
    padding: 0 16px;
    background: rgba(6, 9, 12, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-panel, #1b2a38);
    user-select: none;
    z-index: 100;
    gap: 16px;
    box-sizing: border-box;
}

/* 1. CRITICAL OVERRIDE: Prevent author CSS display values from overriding [hidden] */
.selection-topbar [hidden] {
    display: none !important;
}

/* Slots Layout */
.topbar-slot {
    display: flex;
    align-items: center;
}

.topbar-slot-brand {
    flex-shrink: 0;
}

.topbar-slot-context {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    overflow: hidden;
}

.topbar-slot-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* --- BRAND SLOT ([S] LOGO MARK) --- */
.topbar-brand-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    transition: background-color 160ms ease, transform 160ms ease;
}

.topbar-brand-btn:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: translateY(-1px);
}

.topbar-brand-logo {
    width: 24px;
    height: 24px;
    display: block;
    object-fit: contain;
}

/* --- CONTEXT & PAGE SWITCHER BLOCK --- */
.topbar-context-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    background: transparent;
    border: none;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    max-width: 280px;
    transition: background-color 160ms ease;
}

.topbar-context-block:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.04);
}

.topbar-exp-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--studio-text-muted, #64748b);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.topbar-page-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--studio-text-main, #e2e8f0);
    line-height: 1.3;
    width: 100%;
}

.topbar-page-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-chevron {
    font-size: 10px;
    color: var(--studio-gold, #d4b483);
    opacity: 0.8;
    flex-shrink: 0;
}

/* --- CREATION BUTTON (+ Page) --- */
.topbar-add-page-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 30px;
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-panel, #1b2a38);
    border-radius: 6px;
    color: var(--studio-text-main, #e2e8f0);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
    white-space: nowrap;
}

.topbar-add-page-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* --- DELIVERY & ACTIONS SLOT --- */
.topbar-save-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--studio-text-muted, #64748b);
    margin-right: 4px;
}

.save-status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #64748b;
}

.topbar-save-status[data-status="saving"] .save-status-indicator {
    background-color: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.topbar-save-status[data-status="error"] .save-status-indicator {
    background-color: #ef4444;
}

/* Publish Button */
.topbar-publish-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    background: rgba(212, 180, 131, 0.08);
    border: 1px solid var(--studio-gold, #d4b483);
    border-radius: 6px;
    color: var(--studio-gold, #f0c987);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
    white-space: nowrap;
}

.topbar-publish-btn .publish-arrow {
    display: inline-block;
    font-size: 12px;
    transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.topbar-publish-btn:hover:not(:disabled) {
    background: var(--studio-gold, #d4b483);
    color: #06090c;
    box-shadow: 0 0 12px rgba(212, 180, 131, 0.25);
}

.topbar-publish-btn:hover:not(:disabled) .publish-arrow {
    transform: rotate(-45deg);
}

/* Live Link Button */
.topbar-live-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--studio-text-muted, #64748b);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 160ms ease, color 160ms ease;
}

.topbar-live-btn:hover {
    color: var(--studio-text-main, #e2e8f0);
    background: rgba(255, 255, 255, 0.04);
}

/* --- DISABLED STATES --- */
.topbar-context-block:disabled,
.topbar-add-page-btn:disabled,
.topbar-publish-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- ACCESSIBILITY: FOCUS-VISIBLE --- */
.topbar-brand-btn:focus-visible,
.topbar-context-block:focus-visible,
.topbar-add-page-btn:focus-visible,
.topbar-publish-btn:focus-visible,
.topbar-live-btn:focus-visible {
    outline: 2px solid var(--studio-gold, #d4b483);
    outline-offset: 2px;
}

/* --- ACCESSIBILITY: REDUCED MOTION --- */
@media (prefers-reduced-motion: reduce) {
    .topbar-publish-btn:hover .publish-arrow {
        transform: none;
    }

    .topbar-brand-btn,
    .topbar-publish-btn,
    .topbar-add-page-btn,
    .topbar-live-btn,
    .topbar-context-block {
        transition: none;
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ========================================================================== */

@media (max-width: 900px) {
    .topbar-context-block {
        max-width: 200px;
    }
}

@media (max-width: 640px) {
    .topbar-live-btn [data-ref="liveText"] {
        display: none;
    }

    .topbar-live-btn {
        width: 32px;
        padding: 0;
        justify-content: center;
    }
}

@media (max-width: 560px) {
    .topbar-exp-name {
        display: none;
    }
}

@media (max-width: 480px) {
    .selection-topbar {
        padding: 0 8px;
    }

    .topbar-slot-context {
        gap: 6px;
    }

    .topbar-slot-actions {
        gap: 6px;
    }

    .topbar-context-block {
        min-width: 0;
        max-width: none;
        padding-inline: 4px;
    }

    .topbar-page-title {
        min-width: 0;
    }

    .topbar-live-btn {
        display: none !important;
    }

    .topbar-add-page-btn [data-ref="addPageText"] {
        display: none;
    }

    .topbar-add-page-btn {
        width: 32px;
        padding: 0;
        justify-content: center;
    }
}

/* Landscape Mode Protection */
@media (max-height: 500px) and (orientation: landscape) {
    .selection-topbar {
        height: 48px;
    }

    .topbar-exp-name {
        display: none;
    }
}