/* Shared workspace navigation. Uses the existing gallery light/dark palette. */
body { --sw-sidebar-width: 264px; }
.sw-workspace-main { min-width: 0; }
.sw-workspace-sidebar { display: none; }
.sw-sidebar-links { display: flex; flex-direction: column; min-height: 100%; gap: 8px; padding: 0 10px 16px; }
.sw-sidebar-toolbar, .sw-mobile-menu-toolbar { display: flex; justify-content: flex-end; padding: 9px 12px 5px; }
.sw-sidebar-toggle { display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; border-radius: 9px; color: var(--gal-text-gray); background: transparent; border: 0; cursor: pointer; flex-shrink: 0; }
.sw-sidebar-toggle:hover { color: var(--gal-dark); background: color-mix(in srgb, var(--gal-text-gray) 10%, transparent); }
.sw-workspace-sidebar .sw-nav-link, .sw-mobile-workspace .sw-nav-link { display: flex; width: 100%; align-items: center; min-height: 39px; gap: 11px; margin: 0; padding: 8px 11px; font-size: .82rem; font-weight: 600; line-height: 1.5; text-decoration: none; border-radius: 9px; color: var(--gal-text-gray); text-align: start; }
.sw-workspace-sidebar .sw-nav-link.active, .sw-mobile-workspace .sw-nav-link.active { background: color-mix(in srgb, var(--gal-primary) 12%, transparent); color: var(--gal-primary); box-shadow: none; }
.sw-workspace-sidebar .sw-nav-link.active svg, .sw-workspace-sidebar .sw-nav-link.active .text-primary { color: var(--gal-primary) !important; fill: currentColor !important; }
.sw-workspace-sidebar .sw-nav-link:hover, .sw-mobile-workspace .sw-nav-link:hover { background: color-mix(in srgb, var(--gal-text-gray) 9%, transparent); color: var(--gal-dark); }
.sw-nav-link > svg, .sw-order-plan > svg { width: 20px; height: 20px; flex-shrink: 0; }
.sw-nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-nav-chevron { margin-inline-start: auto; }
.sw-nav-group-trigger { border: 0; cursor: pointer; }
.sw-workspace-sidebar .sw-nav-separator, .sw-mobile-workspace .sw-nav-separator { height: 1px; margin: 7px 10px; background: var(--gal-card-border); }
.sw-nav-children { padding-inline-start: 21px; }
.sw-nav-children .sw-nav-child { padding: 7px 10px; font-size: .78rem; font-weight: 500; border-radius: 8px; }
.sw-nav-child.is-active { color: var(--gal-primary); }
.sw-order-plan { display: flex; align-items: center; min-height: 38px; gap: 10px; padding: 8px 11px; border: 1px solid var(--gal-card-border); border-radius: 9px; color: var(--gal-dark); text-decoration: none; font-size: .82rem; font-weight: 600; }
.sw-order-plan:hover { color: var(--gal-primary); border-color: var(--gal-primary); background: color-mix(in srgb, var(--gal-primary) 5%, transparent); }
.sw-workspace-history { padding-top: 10px; min-width: 0; }
.sw-history-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 0 9px 10px; }
.sw-history-heading h2 { margin: 0; color: var(--gal-text-gray); font-size: .75rem; line-height: 1.5; font-weight: 600; }
.sw-history-filters { display: inline-flex; padding: 2px; border-radius: 7px; background: color-mix(in srgb, var(--gal-text-gray) 7%, transparent); }
.sw-history-filters button { border: 0; border-radius: 5px; padding: 3px 7px; cursor: pointer; font-size: .68rem; color: var(--gal-text-gray); background: transparent; }
.sw-history-filters button[aria-pressed="true"] { background: var(--gal-card-bg); color: var(--gal-dark); box-shadow: 0 1px 3px #0001; }
.sw-history-list { display: flex; flex-direction: column; gap: 2px; }
.sw-history-item { display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 8px 10px; border-radius: 8px; color: var(--gal-dark); text-decoration: none; font-size: .79rem; line-height: 1.5; }
.sw-history-item:hover, .sw-history-item.is-active { background: color-mix(in srgb, var(--gal-text-gray) 11%, transparent); color: var(--gal-dark); }
.sw-history-item.is-active { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gal-primary) 18%, transparent); }
.sw-history-item-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: start; }
.sw-history-app-badge { flex-shrink: 0; padding: 1px 6px; border-radius: 5px; font-size: .64rem; line-height: 1.6; color: var(--gal-primary); background: color-mix(in srgb, var(--gal-primary) 10%, transparent); }
.sw-history-empty { margin: 0; padding: 5px 10px 16px; color: var(--gal-text-gray); font-size: .75rem; line-height: 1.7; }
.sw-history-more { align-self: flex-start; margin: 8px 10px; font-size: .75rem; cursor: pointer; color: var(--gal-text-gray); }
.sw-history-more:hover { color: var(--gal-primary); }
.sw-sidebar-toggle:focus-visible, .sw-sidebar-links a:focus-visible, .sw-sidebar-links button:focus-visible { outline: 2px solid var(--gal-primary); outline-offset: 2px; }
.sw-mobile-workspace { background: var(--gal-card-bg); }
.sw-mobile-workspace .sw-sidebar-links { padding-inline: 0; }
.sw-mobile-menu-toolbar { padding: 0 0 6px; }
[dir="rtl"] .sw-sidebar-toggle svg { transform: scaleX(-1); }
/* Keep the App marker at the physical right in both language directions. */
[dir="rtl"] .sw-history-item:has(.sw-history-app-badge) { flex-direction: row-reverse; }
@media (min-width: 768px) {
    .sw-workspace-sidebar { position: fixed; display: flex; flex-direction: column; inset-block-start: 64px; inset-inline-start: 0; width: var(--sw-sidebar-width); height: calc(100dvh - 64px); z-index: 15; overflow: hidden; transition: width .18s ease; }
    .sw-sidebar-content { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; }
    .sw-workspace-main { margin-inline-start: var(--sw-sidebar-width); transition: margin-inline-start .18s ease; }
    body.sw-sidebar-collapsed { --sw-sidebar-width: 64px; }
    .sw-sidebar-collapsed .sw-workspace-sidebar .sw-sidebar-toolbar { padding-inline: 13px; }
    .sw-sidebar-collapsed .sw-workspace-sidebar .sw-sidebar-links { padding-inline: 8px; }
    .sw-sidebar-collapsed .sw-workspace-sidebar .sw-nav-link, .sw-sidebar-collapsed .sw-workspace-sidebar .sw-order-plan { justify-content: center; padding-inline: 12px; }
    .sw-sidebar-collapsed .sw-workspace-sidebar .sw-nav-label, .sw-sidebar-collapsed .sw-workspace-sidebar .sw-nav-chevron,
    .sw-sidebar-collapsed .sw-workspace-sidebar .sw-nav-children, .sw-sidebar-collapsed .sw-workspace-sidebar .sw-workspace-history { display: none !important; }
    .sw-sidebar-collapsed .sw-workspace-sidebar .sw-nav-separator { margin-inline: 4px; }
}
@media (prefers-reduced-motion: reduce) {
    .sw-workspace-sidebar, .sw-workspace-main { transition: none; }
}

/* Keep rename separate from the conversation link; renaming never opens a chat. */
.sw-history-row{display:flex;align-items:center;gap:2px;border-radius:8px;min-width:0}
.sw-history-row .sw-history-item{flex:1;min-width:0}
.sw-history-row:hover,.sw-history-row.is-active{background:color-mix(in srgb,var(--gal-text-gray) 11%,transparent)}
.sw-history-row .sw-history-item:hover,.sw-history-row .sw-history-item.is-active{background:transparent;box-shadow:none}
.sw-history-row.is-active{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--gal-primary) 18%,transparent)}
.sw-history-rename{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:29px;height:29px;margin-inline-end:3px;padding:0;border:0;border-radius:6px;cursor:pointer;color:var(--gal-text-gray);background:transparent;opacity:0;transition:opacity .12s ease}
.sw-history-row:hover .sw-history-rename,.sw-history-row:focus-within .sw-history-rename{opacity:1}
.sw-history-rename:hover{background:color-mix(in srgb,var(--gal-text-gray) 14%,transparent);color:var(--gal-dark)}
.sw-rename-backdrop{position:fixed;inset:0;z-index:120;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(15,23,42,.46);backdrop-filter:blur(2px)}
.sw-rename-dialog{width:min(420px,100%);padding:24px;border-radius:18px;border:1px solid var(--gal-card-border,#e5e7eb);background:var(--gal-card-bg,#fff);color:var(--gal-dark,#172033);box-shadow:0 20px 60px #0003}
.sw-rename-dialog h2{margin:0;font-size:19px;font-weight:700}.sw-rename-dialog p{margin:9px 0 18px;font-size:13px;color:var(--gal-text-gray,#64748b)}
.sw-rename-dialog label{display:block;margin-bottom:7px;font-size:13px}.sw-rename-dialog input{width:100%;padding:10px 12px;border:1px solid var(--gal-card-border,#cbd5e1);border-radius:9px;background:transparent;color:inherit;font-size:14px}
.sw-rename-dialog input:focus{outline:2px solid var(--gal-primary,#515cff);outline-offset:2px}.sw-rename-error{color:#dc2626;font-size:12px;margin-top:8px}
.sw-rename-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}.sw-rename-actions button{padding:8px 16px;border:1px solid var(--gal-card-border,#cbd5e1);border-radius:9px;cursor:pointer;background:transparent;color:inherit;font-size:13px;font-weight:600}
.sw-rename-actions .is-main{background:var(--gal-primary,#515cff);border-color:var(--gal-primary,#515cff);color:white}.sw-rename-actions button:disabled{opacity:.55;cursor:wait}
@media(hover:none),(pointer:coarse){.sw-history-rename{opacity:1}}

/* Mobile menu: a drawer from the reading start (right in Arabic, left in English), with its button on the same side. */
.sw-menu-toggle { margin-inline-end: 6px; }
.sw-mobile-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.sw-mobile-drawer { position: absolute; inset-block: 0; inset-inline-start: 0; width: min(86vw, 360px); border-inline-end: 1px solid var(--gal-card-border); }
.sw-drawer-anim { transition: transform .25s ease, opacity .25s ease; }
.sw-drawer-off { transform: translateX(-100%); opacity: .6; }
[dir="rtl"] .sw-drawer-off { transform: translateX(100%); }
.sw-drawer-on { transform: translateX(0); opacity: 1; }
@media (prefers-reduced-motion: reduce) { .sw-drawer-anim { transition: none; } }

/* Reload button: phones and the installed app (standalone) only; desktop browsers have their own reload. */
.sw-reload-btn { display: inline-flex; }
@media (min-width: 1024px) { .sw-reload-btn { display: none; } }
@media (display-mode: standalone) { .sw-reload-btn { display: inline-flex; } }
