diff --git a/src/app/shared/ui/sidebar/sidebar.component.css b/src/app/shared/ui/sidebar/sidebar.component.css
index 4b8faee..1bf3006 100644
--- a/src/app/shared/ui/sidebar/sidebar.component.css
+++ b/src/app/shared/ui/sidebar/sidebar.component.css
@@ -7,11 +7,14 @@
background: var(--sidebar-bg);
color: var(--sidebar-text);
transform: translateX(0);
- transition: width 0.3s ease;
+ /* The width transition drives the whole expansion; text reveal is gated by the
+ matching delay below so labels never reflow mid-flight. */
+ transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
z-index: 40;
display: flex;
flex-direction: column;
border-left: 1px solid var(--sidebar-border);
+ overflow: hidden;
}
.sidebar.open {
@@ -30,6 +33,52 @@
overflow: hidden;
}
+/* Sidebar width animation: 0.35s. Text must not appear until the sidebar is wide
+ enough to hold the label on one line, so every label fades in only AFTER the
+ width transition finishes (delay = full duration) and fades out immediately
+ when collapsing. This prevents Persian text from wrapping vertically. */
+:root {
+ --sidebar-expand-duration: 0.35s;
+ --sidebar-collapse-duration: 0.15s;
+}
+
+/* Scoped to `.sidebar`: the account menu is a CDK overlay rendered outside the sidebar
+ DOM, so unscoping these selectors would hide the username inside the dropdown too. */
+.sidebar .nav-label,
+.sidebar .history-text,
+.sidebar .history-header .history-title,
+.sidebar .user-info,
+.sidebar .theme-toggle span {
+ max-width: 0;
+ opacity: 0;
+ overflow: hidden;
+ white-space: nowrap;
+ transform: translateX(-8px);
+ /* Fast fade OUT when collapsing — no delay on the way in. */
+ transition:
+ max-width var(--sidebar-collapse-duration) ease-in,
+ opacity var(--sidebar-collapse-duration) ease-in,
+ transform var(--sidebar-collapse-duration) ease-in;
+}
+
+/* Expanded state: the sidebar has finished growing, so the label can fade in.
+ `max-width: 100%` lets it occupy only the remaining space next to the icon
+ (never forcing a second line), and the delay guarantees the width is already
+ sufficient before the text becomes visible. */
+.sidebar.open .nav-label,
+.sidebar.open .history-text,
+.sidebar.open .history-header .history-title,
+.sidebar.open .user-info,
+.sidebar.open .theme-toggle span {
+ max-width: 100%;
+ opacity: 1;
+ transform: translateX(0);
+ transition:
+ max-width var(--sidebar-expand-duration) ease-out var(--sidebar-expand-duration),
+ opacity var(--sidebar-expand-duration) ease-out var(--sidebar-expand-duration),
+ transform var(--sidebar-expand-duration) ease-out var(--sidebar-expand-duration);
+}
+
.sidebar-top {
padding: 0.75rem;
display: flex;
@@ -67,16 +116,19 @@
.sidebar:not(.open) .sidebar-logo-link {
justify-content: center;
- width: 100%;
+ width: 40px;
+ height: 40px;
+ margin: 0 auto;
}
.sidebar:not(.open) .sidebar-logo {
- height: 36px;
+ height: 28px;
}
+/* Keep the logo in the same 40px column as the nav items. */
.sidebar:not(.open) .sidebar-header {
justify-content: center;
- padding: 0.5rem 0.25rem;
+ padding: 0.5rem 0;
}
.sidebar:not(.open) .close-btn {
@@ -181,6 +233,8 @@
font-size: 0.875rem;
font-weight: 500;
transition: background 0.2s;
+ /* Keep the icon and label on one line regardless of sidebar width. */
+ min-width: 0;
}
.nav-item:hover {
@@ -193,17 +247,28 @@
font-weight: 500;
}
+/* Collapsed rail (72px): a fixed 40px item column centred in the rail, so every icon
+ lines up with the others and with the logo/avatar above it. */
+.sidebar:not(.open) .sidebar-top {
+ padding: 0.75rem 1rem;
+ align-items: center;
+}
+
.sidebar:not(.open) .nav-item {
justify-content: center;
- padding: 0.75rem 0;
+ gap: 0;
+ width: 40px;
+ height: 40px;
+ padding: 0;
+ margin: 0 auto;
+ box-sizing: border-box;
}
-.sidebar:not(.open) .nav-item svg {
- margin: 0;
-}
-
-.sidebar:not(.open) .nav-label {
- display: none;
+.sidebar:not(.open) .nav-item .nav-icon {
+ flex-shrink: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
}
.sidebar-divider {
@@ -213,7 +278,8 @@
}
.sidebar:not(.open) .sidebar-divider {
- margin: 0 0.5rem;
+ /* Same 40px column inset (16px each side of the 72px rail). */
+ margin: 0 1rem;
}
.sidebar-bottom {
@@ -229,15 +295,6 @@
display: none;
}
-.history-header {
- padding: 0.25rem 0.5rem;
- font-size: 0.75rem;
- font-weight: 500;
- color: var(--sidebar-muted);
- text-transform: uppercase;
- letter-spacing: 0.05em;
-}
-
.sidebar:not(.open) .history-header {
display: none;
}
@@ -277,6 +334,23 @@
margin: 0;
}
+/* The whole lower section collapses with the sidebar; its labels animate via
+ the shared width/opacity transition defined earlier. */
+.sidebar:not(.open) .history-header {
+ justify-content: center;
+}
+
+.history-header {
+ display: flex;
+ padding: 0.25rem 0.5rem;
+ font-size: 0.75rem;
+ font-weight: 500;
+ color: var(--sidebar-muted);
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ min-width: 0;
+}
+
.history-icon {
flex-shrink: 0;
opacity: 0.7;
@@ -286,10 +360,7 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
-}
-
-.sidebar:not(.open) .history-text {
- display: none;
+ min-width: 0;
}
.history-empty {
@@ -304,10 +375,6 @@
text-align: center;
}
-.sidebar:not(.open) .history-empty {
- display: none;
-}
-
.history-empty-icon {
opacity: 0.5;
margin-bottom: 0.25rem;
@@ -324,25 +391,20 @@
.sidebar:not(.open) .sidebar-footer {
align-items: center;
- padding: 0.5rem;
+ padding: 0.75rem 1rem;
margin-top: auto;
}
-.sidebar:not(.open) .user-info {
- display: none;
-}
-
.sidebar:not(.open) .user-profile {
- width: 56px;
- height: 56px;
+ width: 40px;
+ height: 40px;
padding: 0;
+ gap: 0;
border-radius: 50%;
justify-content: center;
}
-.sidebar:not(.open) .theme-toggle span {
- display: none;
-}
+/* Theme-toggle label animates with the shared transition instead of display:none. */
.user-profile {
display: flex;
@@ -356,6 +418,7 @@
color: var(--sidebar-text);
text-align: start;
cursor: pointer;
+ min-width: 0;
}
.user-profile:hover,
@@ -383,10 +446,16 @@
.account-menu-header {
display: flex;
align-items: center;
+ /* dir="rtl" on .account-menu already lays children right→left, so the default
+ `row` order puts the avatar on the right and the name beside it to the left. */
gap: 0.5rem;
padding: 0.5rem;
}
+.account-menu-header .user-info {
+ text-align: start;
+}
+
.account-menu-divider {
height: 1px;
margin: 0.375rem 0.5rem;
@@ -396,6 +465,7 @@
.account-menu-item {
display: flex;
align-items: center;
+ /* justify-content: space-between; */
gap: 0.75rem;
width: 100%;
padding: 0.625rem 0.75rem;
@@ -436,6 +506,7 @@
flex-direction: column;
gap: 0.125rem;
overflow: hidden;
+ min-width: 0;
}
.user-name {
@@ -479,9 +550,7 @@
margin: 0;
}
-.sidebar:not(.open) .claim-btn span {
- display: none;
-}
+/* Label collapse is handled by the shared width/opacity transition. */
.theme-toggle {
display: flex;
@@ -504,17 +573,20 @@
}
.sidebar:not(.open) .theme-toggle {
- width: 56px;
- height: 56px;
+ width: 40px;
+ height: 40px;
padding: 0;
+ gap: 0;
border-radius: 0.5rem;
justify-content: center;
}
.sidebar:not(.open) .theme-toggle svg {
margin: 0;
+ flex-shrink: 0;
}
-.sidebar:not(.open) .theme-toggle span {
- display: none;
+/* Collapsed rail: the avatar text must not stretch the 40px column. */
+.sidebar:not(.open) .user-avatar {
+ flex-shrink: 0;
}
diff --git a/src/app/shared/ui/sidebar/sidebar.component.html b/src/app/shared/ui/sidebar/sidebar.component.html
index 2afb24e..f2780fb 100644
--- a/src/app/shared/ui/sidebar/sidebar.component.html
+++ b/src/app/shared/ui/sidebar/sidebar.component.html
@@ -44,6 +44,7 @@
fill="none"
stroke="currentColor"
stroke-width="2"
+ class="nav-icon"
>
@@ -116,13 +117,14 @@
-