/* Main toolbar. Layout: brand | project name | File | Edit | Run | View | Panels ... Help | Language
   Fitting is automatic (js/toolbarFit.js): labels -> icons only (.tb-compact) -> tighter spacing (.tb-tight).
   Logical properties are used throughout so RTL (Persian) mirrors correctly. */
.toolbar { display: flex; align-items: center; gap: 6px; padding: 0 12px; min-width: 0; min-height: 48px; background: var(--bg-panel); border-bottom: 1px solid var(--line); position: relative; z-index: 50; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.toolbar > * { flex: none; }

.brand { display: flex; align-items: center; gap: 9px; padding-inline-end: 10px; color: var(--text); text-decoration: none; white-space: nowrap; border-radius: var(--radius); }
.brand-mark { height: 28px; width: auto; display: block; }
.brand-word { height: 15px; width: auto; display: block; }

.toolbar .project-field { flex: 0 1 220px; min-width: 84px; height: 30px; display: flex; align-items: center; gap: 7px; padding-inline: 9px; border: 1px solid transparent; border-radius: var(--radius); }
.toolbar .project-field:hover { border-color: var(--line); background: var(--bg-input); }
.toolbar .project-field:focus-within { border-color: var(--accent); background: var(--bg-input); box-shadow: 0 0 0 2px var(--accent-soft); }
.project-field .project-name { flex: 1; min-width: 0; width: 100%; padding: 0; background: transparent; border: 0; box-shadow: none; text-align: start; font-weight: 600; text-overflow: ellipsis; }
.project-field .project-name:hover, .project-field .project-name:focus { border: 0; box-shadow: none; outline: none; }
.dirty-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: transparent; border: 1px solid var(--line); }
.dirty-dot.on { background: var(--warn); border-color: var(--warn); }

.tb-group { display: flex; align-items: center; gap: 2px; padding-inline: 8px 4px; border-inline-start: 1px solid var(--line-soft); }
.tb-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 9px; background: none; border: 1px solid transparent; border-radius: var(--radius); color: var(--text); white-space: nowrap; }
.tb-btn:hover:not(:disabled) { background: var(--bg-raised); border-color: var(--line); }
.tb-btn:disabled { color: #566170; }
.tb-btn.icon-only { padding: 0; width: 30px; }
.tb-btn.small { height: 26px; padding: 0 6px; }
.tb-btn.run { color: var(--ok); font-weight: 600; background: rgba(85, 194, 138, .08); border-color: rgba(85, 194, 138, .35); }
.tb-btn.run:hover:not(:disabled) { background: rgba(85, 194, 138, .16); border-color: var(--ok); }
.tb-btn.toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(56, 182, 198, .45); color: #9fe3ec; }
.tb-btn.zoom-level { min-width: 52px; padding: 0 6px; font-family: var(--mono); font-size: 12px; }
.tb-spacer { flex: 1 1 0; min-width: 0; }

/* More menu */
.tb-menu { position: relative; display: flex; }
#moreBtn { width: auto; padding: 0 6px; gap: 2px; }
#moreBtn[aria-expanded="true"] { background: var(--bg-raised); border-color: var(--line); }
.tb-menu-panel { position: fixed; z-index: 70; min-width: 200px; display: flex; flex-direction: column; gap: 1px; padding: 5px; background: var(--bg-raised); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.tb-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; background: none; border: 0; border-radius: 5px; color: var(--text); text-align: start; }
.tb-menu-item:hover, .tb-menu-item:focus-visible { background: var(--accent-soft); outline: none; }
.tb-menu-sep { height: 1px; margin: 4px 2px; background: var(--line); }

/* Language switcher: globe icon + select (no text label, so it can never be cut off) */
.language-switcher { display: flex; align-items: center; gap: 5px; height: 30px; padding-inline-start: 8px; color: var(--muted); white-space: nowrap; border-inline-start: 1px solid var(--line-soft); }
.toolbar .language-switcher select { width: auto; min-width: 0; height: 28px; padding: 2px 6px; }

/* Library / Properties icons follow the sidebar side, which flips in RTL */
html[dir="rtl"] #toggleLeftSidebar .icon, html[dir="rtl"] #toggleRightSidebar .icon { transform: scaleX(-1); }

/* Step 1 - not enough room: icons only (Run keeps its label) */
.tb-compact .tb-btn:not(.run):not(.zoom-level):not(.icon-only):not(#moreBtn) { padding: 0; width: 30px; }
.tb-compact .tb-btn:not(.run) .lbl { display: none; }
/* Step 2 - still not enough: drop the wordmark, tighten spacing */
.tb-tight { gap: 3px; padding: 0 8px; }
.tb-tight .brand-word { display: none; }
.tb-tight .brand { padding-inline-end: 4px; }
.tb-tight .tb-group { padding-inline: 5px 2px; }
.tb-tight .project-field { flex-basis: 150px; min-width: 72px; }
.tb-tight .tb-btn.run .lbl { display: none; }
.tb-tight .tb-btn.run { padding: 0; width: 30px; }
