/* ==========================================================================
   SELECTION STUDIO — TOP BAR CANONICAL STYLES (FREEZE V1)
   Location: /studio/css/studio-topbar.css
   ========================================================================== */

.selection-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height, 60px);
    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;
}

/* Override: Sprečavanje autora CSS display vrednosti da preglase [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;
}

/* ==========================================================================
   PHASE 2 — GHOST BUTTON CONSTITUTION
   Ghost Unification: Current Page, Add Page, Live Link
   Contract: transparent -> hover surface -> primary text | No border | No outline on hover
   ========================================================================== */

/* 2A. Current Page (Context Block) */
.topbar-context-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    background: transparent;
    border: none;
    outline: none;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    max-width: 280px;
    transition: background-color 160ms ease, color 160ms ease;
}

.topbar-context-block:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.04);
}

.topbar-context-block:hover:not(:disabled) .topbar-context-value {
    color: #ffffff;
}

.topbar-context-block:hover:not(:disabled) .topbar-chevron {
    opacity: 1;
}

.topbar-context-block:hover:not(:disabled) .topbar-context-label {
    color: #8fa0b3;
}

.topbar-context-label {
    font-size: var(--studio-type-meta-size);
    font-weight: var(--studio-font-weight-regular);
    color: var(--studio-text-muted);
    line-height: var(--studio-type-meta-line-height);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.topbar-context-value {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--studio-type-ui-label-size);
    font-weight: var(--studio-font-weight-strong);
    color: var(--studio-text-primary);
    line-height: var(--studio-type-ui-label-line-height);
    width: 100%;
    transition: color 160ms ease;
}

.topbar-context-title {
    display: block;
    min-width: 0;
    flex: 0 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-chevron {
    font-size: 10px;
    color: var(--studio-gold, #d4b483);
    opacity: 0.8;
    flex-shrink: 0;
    transition: opacity 160ms ease;
}

/* 2B. Add Page Button */
.topbar-add-page-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    background: transparent;
    border: none;
    outline: none;
    border-radius: 6px;
    color: var(--studio-text-secondary);
    font-size: var(--studio-type-ui-label-size);
    font-weight: var(--studio-font-weight-medium);
    line-height: 1;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease;
    white-space: nowrap;
}

.topbar-add-page-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    outline: none;
    color: #ffffff;
}

.topbar-add-page-btn:focus-visible {
    color: #ffffff;
}

.topbar-entry-arrow {
    display: inline-block;
    transition: transform 180ms ease;
}

.topbar-add-page-btn:hover:not(:disabled) .topbar-entry-arrow {
    transform: translateX(4px);
}

/* ==========================================================================
   PHASE 3 — PRIMARY CONSTITUTION
   Primary Unification: Publish, Open Page, Create Page, Create Experience
   Contract: height 32px | radius 6px | gold palette | glow hover | arrow rot (Publish only)
   ========================================================================== */

.topbar-publish-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    background: transparent;
    border: 1px solid rgba(212, 180, 131, 0.45);
    border-radius: 6px;
    color: var(--studio-text-secondary);
    font-size: var(--studio-type-ui-label-size);
    font-weight: var(--studio-font-weight-medium);
    line-height: 1;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
    white-space: nowrap;
}

.topbar-canvas-btn {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--studio-text-secondary);
    font-size: var(--studio-type-ui-label-size);
    font-weight: var(--studio-font-weight-medium);
    cursor: pointer;
}

.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: rgba(212, 180, 131, 0.08);
    border-color: var(--studio-gold, #d4b483);
    color: var(--studio-text-accent);
}

/* Publish keeps the Studio entry-arrow motion. */
.topbar-publish-btn:hover:not(:disabled) .publish-arrow {
    transform: translateX(4px);
}

/* --- SAVE STATUS RENDER --- */
.topbar-save-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--studio-type-meta-size);
    font-weight: var(--studio-font-weight-regular);
    line-height: var(--studio-type-meta-line-height);
    color: var(--studio-text-muted);
    margin-right: 4px;
}

.save-status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #64748b;
    transition: background-color 200ms ease, box-shadow 200ms ease;
}

.topbar-save-status[data-status="typing"] .save-status-indicator {
    background-color: #60a5fa;
    box-shadow: 0 0 6px rgba(96, 165, 250, 0.4);
}

.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="saved"] .save-status-indicator {
    background-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.topbar-save-status[data-status="error"] .save-status-indicator {
    background-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

/* --- DISABLED STATES --- */
.topbar-context-block:disabled,
.topbar-add-page-btn:disabled,
.topbar-publish-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* --- ACCESSIBILITY: FOCUS-VISIBLE --- */
.topbar-brand-btn:focus-visible,
.topbar-context-block:focus-visible,
.topbar-add-page-btn:focus-visible,
.topbar-publish-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-context-block {
        transition: none;
    }

    .topbar-add-page-btn:hover:not(:disabled) .topbar-entry-arrow {
        transform: none;
    }
}

/* Responsive Rules */
@media (max-width: 900px) {
    .topbar-context-block {
        max-width: 200px;
    }
}

@media (max-width: 700px) {
    .topbar-context-block[data-ref="experienceManagerBtn"],
    .topbar-context-block[data-ref="capsuleBtn"] {
        display: none;
    }

    .topbar-canvas-btn,
    .topbar-canvas-mode-btn {
        display: inline-flex;
        align-items: center;
        height: 32px;
        padding: 0 8px;
        border: 0;
        border-radius: 6px;
        background: transparent;
        color: var(--studio-text-secondary);
        font-size: var(--studio-type-ui-label-size);
        font-weight: var(--studio-font-weight-medium);
        cursor: pointer;
    }

    .topbar-canvas-btn:hover,
    .topbar-canvas-btn:focus-visible,
    .topbar-canvas-mode-btn:hover,
    .topbar-canvas-mode-btn:focus-visible {
        background: rgba(255, 255, 255, 0.04);
        color: var(--studio-text-primary);
    }
}

@media (max-width: 410px) {
    .topbar-publish-btn .publish-arrow {
        display: none;
    }

    .topbar-publish-btn {
        padding-inline: 9px;
    }
}

@media (max-width: 560px) {
    .topbar-context-label {
        display: none;
    }
}

@media (max-width: 480px) {
    .selection-topbar {
        padding: 0 8px;
    }

    .topbar-slot-context,
    .topbar-slot-actions {
        gap: 6px;
    }

    .topbar-context-block {
        min-width: 0;
        max-width: none;
        padding-inline: 4px;
    }

    .topbar-context-title {
        min-width: 0;
    }

}

@media (max-height: 500px) and (orientation: landscape) {
    .selection-topbar {
        height: 48px;
    }

    #studio-shell {
        --topbar-height: 48px;
    }

    .topbar-context-label {
        display: none;
    }
}
