/* App main menu — Arbox-inspired rail; follows app theme (dark default, light via body.light-mode) */

#app-sidebar-overlay {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
}

body.light-mode #app-sidebar-overlay {
    background: rgba(15, 23, 42, 0.45);
}

.app-sidebar {
    /* Dark theme (default — matches glass panels / library drawer) */
    --sidebar-bg: rgb(23, 23, 23);
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-text: var(--text-primary, #ffffff);
    --sidebar-text-muted: var(--text-secondary, #a3a3a3);
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active-bg: rgba(var(--accent-rgb, 56, 189, 248), 0.14);
    --sidebar-active-text: rgb(var(--accent-rgb, 56, 189, 248));
    --sidebar-scrollbar: rgba(255, 255, 255, 0.2);
    --sidebar-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
    --sidebar-width: 17.5rem;

    position: fixed;
    top: 0;
    right: 0;
    z-index: 110;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    max-width: min(var(--sidebar-width), 92vw);
    height: 100%;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--sidebar-border);
    box-shadow: var(--sidebar-shadow);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    color: var(--sidebar-text);
    font-family: 'Ploni', sans-serif;
}

/* Light theme — Arbox-style light rail */
body.light-mode .app-sidebar {
    --sidebar-bg: #ffffff;
    --sidebar-border: #e8eaed;
    --sidebar-text: #1a1d21;
    --sidebar-text-muted: #6b7280;
    --sidebar-hover: #f3f4f6;
    --sidebar-active-bg: rgba(var(--accent-rgb, 56, 189, 248), 0.12);
    --sidebar-active-text: rgb(var(--accent-rgb, 56, 189, 248));
    --sidebar-scrollbar: #d1d5db;
    --sidebar-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
}

html[dir="ltr"] .app-sidebar {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--sidebar-border);
    --sidebar-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
    transform: translateX(-100%);
}

body.light-mode html[dir="ltr"] .app-sidebar {
    --sidebar-shadow: 8px 0 32px rgba(15, 23, 42, 0.12);
}

.app-sidebar.is-open {
    transform: translateX(0);
}

.app-sidebar__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1.25rem 1rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.app-sidebar__logo {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    background: linear-gradient(145deg, rgba(var(--accent-rgb, 56, 189, 248), 0.15), rgba(var(--accent-rgb, 56, 189, 248), 0.05));
    border: 1px solid rgba(var(--accent-rgb, 56, 189, 248), 0.25);
    color: rgb(var(--accent-rgb, 56, 189, 248));
    font-size: var(--text-small);
    font-weight: var(--fw-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-sidebar__title {
    font-size: var(--text-ui);
    font-weight: var(--fw-bold);
    line-height: var(--lh-snug);
    color: var(--sidebar-text);
    margin: 0;
}

.app-sidebar__subtitle {
    font-size: var(--text-caption);
    font-weight: var(--fw-normal);
    line-height: var(--lh-snug);
    color: var(--sidebar-text-muted);
    margin: 0.15rem 0 0;
}

.app-sidebar__close {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    border: none;
    background: transparent;
    color: var(--sidebar-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-sidebar__close:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.app-sidebar__body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0.625rem 1.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-scrollbar) transparent;
}

.app-sidebar__body::-webkit-scrollbar {
    width: 5px;
}

.app-sidebar__body::-webkit-scrollbar-thumb {
    background: var(--sidebar-scrollbar);
    border-radius: 4px;
}

.app-sidebar__section {
    margin-bottom: 0.5rem;
}

.app-sidebar__section + .app-sidebar__section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--sidebar-border);
}

body:not(.planner-weekly) .app-sidebar__section--planner-only {
    display: none;
}

.app-sidebar__section-label {
    font-size: var(--text-caption);
    font-weight: var(--fw-medium);
    line-height: var(--lh-snug);
    color: var(--sidebar-text-muted);
    padding: 0 0.625rem 0.5rem;
    margin: 0;
}

.app-sidebar__item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    margin-bottom: 0.125rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--sidebar-text);
    text-align: start;
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-sidebar__item:hover {
    background: var(--sidebar-hover);
}

.app-sidebar__item.is-active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.app-sidebar__item.is-active::before {
    content: '';
    position: absolute;
    top: 0.35rem;
    bottom: 0.35rem;
    right: 0;
    width: 3px;
    border-radius: 3px 0 0 3px;
    background: rgb(var(--accent-rgb, 56, 189, 248));
}

html[dir="ltr"] .app-sidebar__item.is-active::before {
    right: auto;
    left: 0;
    border-radius: 0 3px 3px 0;
}

.app-sidebar__icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    color: var(--sidebar-text-muted);
    transition: color 0.15s ease;
}

.app-sidebar__item:hover .app-sidebar__icon,
.app-sidebar__item.is-active .app-sidebar__icon {
    color: var(--sidebar-active-text);
}

.app-sidebar__label {
    font-size: var(--text-ui);
    font-weight: var(--fw-medium);
    line-height: var(--lh-snug);
    flex: 1;
    min-width: 0;
}

.app-sidebar__item.is-active .app-sidebar__label {
    font-weight: var(--fw-semibold);
}

/* Top bar — ghost back / sidebar toggles (no boxed chrome) */
.app-nav-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    color: var(--text-secondary, #a3a3a3);
    border-radius: 0.375rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}
.app-nav-icon-btn:hover {
    color: rgb(var(--accent-rgb, 56, 189, 248));
    background: rgba(255, 255, 255, 0.06);
}
body.light-mode .app-nav-icon-btn:hover {
    background: rgba(15, 23, 42, 0.06);
}
.app-nav-icon-btn .app-nav-icon {
    width: 1.125rem;
    height: 1.125rem;
}
/* Chevron points toward the screen edge the button sits on */
html[dir="ltr"] #app-nav-back-btn .app-nav-back-chevron {
    transform: scaleX(1);
}
html[dir="rtl"] #app-nav-back-btn .app-nav-back-chevron {
    transform: scaleX(-1);
}

.app-nav-heading {
    min-width: 0;
    flex: 1 1 auto;
}
.app-nav-heading .text-role-title {
    line-height: var(--lh-tight);
}
@media (max-width: 639px) {
    .app-nav-heading {
        max-width: calc(100vw - 11rem);
    }
}

/* Client bar — click dashboard for actions menu */
#planner-client-bar.client-bar-panel {
    position: relative;
}
#client-bar-menu.client-bar-menu {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 0.35rem);
    z-index: 60;
    min-width: 11rem;
    max-width: min(16rem, calc(100vw - 2rem));
    background: rgba(12, 12, 12, 0.96);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.75rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.55);
    padding: 0.25rem 0;
}
body.light-mode #client-bar-menu.client-bar-menu {
    background: rgba(255, 255, 255, 0.98);
    border-color: #e5e7eb;
}
.client-bar-menu {
    pointer-events: auto;
}
.client-bar-menu__divider {
    height: 1px;
    margin: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
}
.client-bar-menu__item {
    display: block;
    width: 100%;
    padding: 0.65rem 1rem;
    text-align: start;
    font-size: var(--text-small);
    font-weight: var(--fw-semibold);
    color: var(--text-primary, #fff);
    transition: background 0.15s ease;
}
.client-bar-menu__item:hover {
    background: rgba(255, 255, 255, 0.08);
}
.client-bar-menu__delete {
    display: block;
    width: 100%;
    padding: 0.45rem 1rem 0.55rem;
    text-align: start;
    font-size: var(--text-caption);
    font-weight: var(--fw-semibold);
    color: #f87171;
    transition: background 0.15s ease, color 0.15s ease;
}
.client-bar-menu__delete:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
}
