/* Shared Fotogenic Sidebar (app + account) */

.sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: transparent;
    border-right: none;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar-surface {
    width: 100%;
    height: 100%;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    padding-left: 10px;
}

.brand-content {
    min-width: 0;
}

.brand-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-text {
    font-family: 'Jost', sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    text-transform: uppercase;
    white-space: nowrap;
}

.mobile-sidebar-close {
    display: none;
    margin-left: auto;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
}

.sidebar-compact-toggle {
    display: none;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
}

.sidebar-compact-toggle svg {
    transition: transform 0.2s ease;
}

.sidebar-compact-toggle.expanded svg {
    transform: scaleX(-1);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: auto;
}

.nav-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 10px 16px 6px;
    margin-top: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    pointer-events: none;
}

.nav-menu .nav-section-title:first-child {
    margin-top: 0;
    padding-top: 0;
}

.nav-section-title-full {
    display: inline;
}

.nav-section-title-compact {
    display: none;
}

.nav-item {
    position: relative;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px 16px;
    height: 44px;
    min-height: 44px;
    box-sizing: border-box;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    font-family: var(--font-family);
}

.nav-item:hover {
    background: var(--input-bg);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-color);
    color: var(--accent-foreground)!important;
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.25);
}

.nav-item.nav-item-disabled,
.nav-item[aria-disabled="true"] {
    cursor: not-allowed;
    color: var(--text-tertiary);
}

.nav-item.nav-item-disabled svg,
.nav-item[aria-disabled="true"] svg {
    opacity: 0.62;
}

[data-theme="light"] .nav-item.nav-item-disabled,
[data-theme="light"] .nav-item[aria-disabled="true"] {
    color: rgba(24, 34, 58, 0.46);
}

[data-theme="light"] .nav-item.nav-item-disabled svg,
[data-theme="light"] .nav-item[aria-disabled="true"] svg {
    opacity: 0.54;
}

.sidebar .nav-item.nav-item-disabled:hover,
.sidebar .nav-item[aria-disabled="true"]:hover,
.sidebar .nav-item.nav-item-disabled:focus-visible,
.sidebar .nav-item[aria-disabled="true"]:focus-visible {
    border-color: transparent;
    background: transparent;
    color: var(--text-tertiary);
    box-shadow: none;
}

.sidebar .nav-item[data-tooltip]:not([data-tooltip=""])::before {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    bottom: auto;
    transform: translate(6px, -50%);
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(9, 13, 20, 0.98);
    color: rgba(255, 255, 255, 0.99);
    font-size: 0.67rem;
    line-height: 1.25;
    letter-spacing: 0.02em;
    white-space: normal;
    text-align: center;
    width: max-content;
    max-width: 220px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
    pointer-events: none;
    z-index: 220;
}

.sidebar .nav-item[data-tooltip]:not([data-tooltip=""]):hover::before,
.sidebar .nav-item[data-tooltip]:not([data-tooltip=""]):focus-visible::before {
    opacity: 1;
    visibility: visible;
    transform: translate(0, -50%);
    transition-delay: 0s;
}

[data-theme="light"] .sidebar .nav-item[data-tooltip]:not([data-tooltip=""])::before {
    border-color: rgba(16, 24, 40, 0.24);
    background: rgba(255, 255, 255, 0.99);
    color: rgba(16, 24, 40, 0.98);
    box-shadow: 0 10px 24px rgba(16, 24, 40, 0.14);
}

.nav-item.nav-item-highlighted,
.nav-item.nav-item-highlighted:hover,
.nav-item.nav-item-highlighted.active {
    background: var(--input-bg);
    color: var(--text-primary) !important;
    box-shadow: none;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-top-up {
    width: 100%;
    background: var(--accent-color);
    color: var(--accent-foreground);
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 12px;
    height: 38px;
    min-height: 38px;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    margin-top: 12px;
    margin-bottom: 12px;
    transition: 0.2s;
    overflow: hidden;
}

.btn-top-up svg {
    width: 19.2px;
    height: 19.2px;
}

.btn-top-up:hover {
    filter: brightness(1.05);
}

.btn-side-secondary {
    width: 100%;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    height: 38px;
    min-height: 38px;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    margin-top: 0;
    margin-bottom: 12px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    overflow: hidden;
}

.btn-top-up span,
.btn-side-secondary span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-side-secondary svg {
    width: 19.2px;
    height: 19.2px;
}

.btn-side-secondary:hover {
    border-color: var(--accent-color);
    background: rgba(var(--accent-rgb), 0.12);
}

.user-panel {
    margin-top: 0;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--input-bg);
}

.user-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}

.user-name {
    display: block;
    width: 100%;
    max-width: 100%;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-credits {
    font-size: 0.75rem;
    color: var(--accent-color);
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-credits.user-credits-skeleton {
    color: transparent !important;
    display: inline-flex;
    align-items: center;
    min-height: 14px;
    overflow: visible;
}

.user-credits.user-credits-skeleton::after {
    content: '';
    display: block;
    width: 92px;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.08) 0%,
        rgba(255, 255, 255, 0.22) 50%,
        rgba(255, 255, 255, 0.08) 100%
    );
    background-size: 220% 100%;
    animation: sidebarSkeletonShimmer 1.1s linear infinite;
}

[data-theme="light"] .user-credits.user-credits-skeleton::after {
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.08) 0%,
        rgba(0, 0, 0, 0.18) 50%,
        rgba(0, 0, 0, 0.08) 100%
    );
    background-size: 220% 100%;
}

@keyframes sidebarSkeletonShimmer {
    0% { background-position: 180% 0; }
    100% { background-position: -40% 0; }
}

@keyframes sidebarUserMetaExpandedReveal {
    0% {
        opacity: 0;
        visibility: hidden;
    }
    100% {
        opacity: 1;
        visibility: visible;
    }
}

.sidebar .icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: var(--sidebar-icon-btn-radius, 8px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}

.sidebar .icon-btn:hover {
    background: var(--input-bg);
    color: var(--text-primary);
}

.sidebar .icon-btn svg {
    width: 19.2px;
    height: 19.2px;
    stroke-width: 2;
    display: block;
}

/* Sidebar icon normalization: keep these specific Lucide icons at exact 19x19. */
.sidebar svg.lucide-settings,
.sidebar svg.lucide-zap,
.sidebar svg.lucide-moon,
.sidebar svg.lucide-log-out,
.sidebar svg.lucide-chevrons-right {
    width: 19px !important;
    height: 19px !important;
}

/*
 * Lucide paths are typically drawn in an 18x18 internal box.
 * Scale these to 19x19 visual size so DevTools path box matches and icons look consistent.
 */
.sidebar svg.lucide-settings > *,
.sidebar svg.lucide-zap > *,
.sidebar svg.lucide-moon > *,
.sidebar svg.lucide-log-out > *,
.sidebar svg.lucide-chevrons-right > * {
    transform-box: fill-box;
    transform-origin: center;
    transform: translateX(1px) scale(1.05556);
}

/* Expanded compact-toggle mirrors the SVG, so invert child X shift to keep the same visual direction. */
.sidebar .sidebar-compact-toggle.expanded svg.lucide-chevrons-right > * {
    transform: translateX(-1px) scale(1.05556);
}

/* Optically center these icons after geometry normalization. */
.sidebar .btn-side-secondary svg.lucide-settings,
.sidebar .nav-item svg.lucide-settings {
    margin-left: -0.3px;
}

.sidebar .btn-top-up svg.lucide-zap {
    margin-left: -0.5px;
}

.sidebar .icon-btn svg.lucide-moon {
    margin-left: -0.8px;
}

.sidebar .icon-btn svg.lucide-log-out {
    margin-left: -0.6px;
}

.sidebar .icon-btn svg.lucide-chevrons-right {
    margin-left: -0.6px;
}

.sidebar .user-actions .icon-btn {
    width: 34px;
    height: 34px;
}

.sidebar-backdrop {
    display: none;
}

@media (min-width: 1073px) {
    .mobile-sidebar-close {
        display: none !important;
    }
}

@media (min-width: 765px) {
    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .sidebar-surface {
        background: rgba(17, 17, 17, 0.76);
        -webkit-backdrop-filter: blur(10px) saturate(1.18);
        backdrop-filter: blur(10px) saturate(1.18);
    }

    [data-theme="light"] .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .sidebar-surface {
        background: rgba(255, 255, 255, 0.82);
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .sidebar {
        position: relative;
        width: 74px;
        min-width: 74px;
        max-width: 74px;
        overflow: visible;
        border-right: none;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .sidebar-surface {
        position: relative;
        z-index: 140;
        width: 74px;
        max-width: 260px;
        height: 100%;
        padding: 16px 10px;
        overflow: visible;
        transition: width 0.22s ease, padding 0.22s ease, box-shadow 0.22s ease;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .sidebar-surface {
        width: 260px;
        padding: 16px 20px 20px;
        box-shadow: none;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .brand {
        position: relative;
        height: 36px;
        justify-content: flex-start;
        padding-left: 0;
        margin-bottom: 22px;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .brand-actions {
        margin-left: auto;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .brand {
        justify-content: center;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .brand-actions {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .sidebar-compact-toggle {
        display: inline-flex;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .mobile-sidebar-close {
        display: none !important;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .nav-item {
        justify-content: flex-start;
        padding: 12px 12px 12px 17px;
        gap: 12px;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .nav-item {
        justify-content: center;
        padding: 12px;
        gap: 0;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .nav-item > svg {
        flex: 0 0 20px;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .brand-content {
        position: absolute;
        left: 0;
        right: 44px;
        top: 50%;
        opacity: 0;
        visibility: hidden;
        max-width: 0;
        overflow: hidden;
        white-space: nowrap;
        transform: translateY(-50%) translateX(-4px);
        transition: opacity 0.12s ease, transform 0.12s ease, max-width 0.2s ease, visibility 0s linear 0.2s;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .nav-label {
        opacity: 0;
        visibility: hidden;
        max-width: 0;
        overflow: hidden;
        white-space: nowrap;
        transform: translateX(-4px);
        transition: opacity 0.12s ease, transform 0.12s ease, max-width 0.2s ease, visibility 0s linear 0.2s;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .nav-section-title {
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 10px 0 6px;
        margin-top: 8px;
        font-size: 0.68rem;
        letter-spacing: 0.08em;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .nav-section-title:first-child {
        margin-top: 0;
        padding-top: 0;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .nav-section-title-full {
        display: none;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .nav-section-title-compact {
        display: inline;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .btn-top-up,
    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .btn-side-secondary {
        width: 34px;
        height: 34px;
        min-height: 34px;
        margin-left: auto;
        margin-right: auto;
        padding: 0;
        border-radius: 12px;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .btn-top-up span,
    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .btn-side-secondary span {
        display: none;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .user-panel {
        flex-direction: column;
        gap: 8px;
        padding-top: 16px;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .user-details {
        flex: none;
        align-items: center;
        text-align: center;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .user-details {
        width: 100%;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .user-avatar,
    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .user-details {
        opacity: 1;
        visibility: visible;
        transition: opacity 0.12s ease;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .user-name {
        display: none;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .user-credits.user-credits-skeleton::after {
        width: 44px;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .user-credits.user-credits-skeleton {
        width: 100%;
        justify-content: center;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled:not(.sidebar-compact-expanded) .user-credits.user-credits-skeleton::after {
        margin-left: auto;
        margin-right: auto;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled .user-actions {
        flex-direction: column;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .brand {
        justify-content: space-between;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .brand-content {
        opacity: 1;
        visibility: visible;
        max-width: 220px;
        transform: translateY(-50%) translateX(0);
        transition-delay: 0.08s, 0.08s, 0.08s, 0s;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .nav-label {
        opacity: 1;
        visibility: visible;
        max-width: 220px;
        transform: translateX(0);
        transition-delay: 0.08s, 0.08s, 0.08s, 0s;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .btn-top-up,
    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .btn-side-secondary {
        width: 100%;
        height: 38px;
        min-height: 38px;
        padding: 10px 12px;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .btn-top-up span,
    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .btn-side-secondary span {
        display: inline;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .user-panel {
        flex-direction: row;
        gap: 12px;
        padding-top: 20px;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .user-details {
        flex: 1;
        align-items: flex-start;
        text-align: left;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .user-avatar,
    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .user-details {
        opacity: 1;
        visibility: visible;
        animation: sidebarUserMetaExpandedReveal 0.14s ease 0.08s both;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .user-name {
        display: block;
    }

    .app-container.sidebar-mobile-enabled.sidebar-compact-enabled.sidebar-compact-expanded .user-actions {
        flex-direction: row;
    }
}

@media (max-width: 764px) {
    .app-container.sidebar-mobile-enabled .sidebar .nav-item[data-tooltip]:not([data-tooltip=""])::before {
        content: none;
        display: none;
    }

    .app-container.sidebar-mobile-enabled .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(82vw, 320px);
        min-width: 0;
        max-width: none;
        height: 100%;
        border-right: none;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        z-index: 220;
    }

    .app-container.sidebar-mobile-enabled .sidebar-surface {
        width: 100%;
        height: 100%;
        padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    }

    .app-container.sidebar-mobile-enabled.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-container.sidebar-mobile-enabled .brand {
        justify-content: space-between;
        padding-left: 0;
    }

    .app-container.sidebar-mobile-enabled .brand-content {
        display: block;
    }

    .app-container.sidebar-mobile-enabled .sidebar-compact-toggle {
        display: none !important;
    }

    .app-container.sidebar-mobile-enabled .mobile-sidebar-close {
        display: inline-flex;
    }

    .app-container.sidebar-mobile-enabled .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(5, 5, 5, 0.32);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 210;
    }

    [data-theme="light"] .app-container.sidebar-mobile-enabled .sidebar-backdrop {
        background: rgba(255, 255, 255, 0.34);
    }

    .app-container.sidebar-mobile-enabled.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}
