﻿@import url('https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap');

:root {
    --header-height: 70px;
    --sidebar-w-expanded: 250px;
    --sidebar-w-collapsed: 70px;
    --sidebar-gap: 0; /* grid-gap alternative if needed later */
}

@media (max-width: 1920px) {
    :root { --header-height: 60px; }
}
@media (max-width: 1440px) {
    :root { --header-height: 60px; }
}
@media (max-width: 1024px) {
    :root { --header-height: 55px; }
}

/* Base = collapsed */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    height: calc(100% - var(--header-height));
    width: var(--sidebar-w-collapsed);
    max-width: var(--sidebar-w-expanded);
    background-color: #2a2a2a;
    border-right: 1px solid #454545;
    transition: width 0.25s ease, left 0.3s ease;
    z-index: 997;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Logical collapsed marker (used by JS); base style is already collapsed width */
.sidebar.collapsed {
    width: var(--sidebar-w-collapsed);
}

/* Hover-open (desktop): visually expand */
@media (min-width: 769px) {
    .sidebar.hover-open {
        width: var(--sidebar-w-expanded);
    }
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
}

.sidebar-bottom {
    margin-top: auto;
    padding-bottom: 25px;
}

/* Items */
.sidebar-item {
    display: flex;
    align-items: center;
    padding: 0 20px;
    min-height: 70px;
    color: #c2c2c2;
    text-decoration: none;
    font-family: "Silkscreen", sans-serif;
    font-size: 13px;
    transition: background-color 0.2s ease, color 0.2s ease, padding 0.2s ease;
}

.sidebar-item:hover {
    background-color: #383838;
    color: #fff;
    text-decoration: none;
}

.sidebar-item.active {
    background-color: #303030;
    color: white;
    font-weight: 500;
}

.sidebar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    width: 20px;
    height: 20px;
    margin-right: 12px;
    font-size: 18px;
    color: inherit;
    flex-shrink: 0;
}

.sidebar-text {
    white-space: nowrap;
    transition: opacity 0.2s ease, visibility 0.2s ease, width 0.2s ease;
}

/* Collapsed visual: center icon, hide text */
.sidebar:not(.hover-open):not(.open) .sidebar-item {
    justify-content: center;
    padding: 0;
}

.sidebar:not(.hover-open):not(.open) .sidebar-icon {
    margin-right: 0;
}

.sidebar:not(.hover-open):not(.open) .sidebar-text {
    opacity: 0;
    visibility: hidden;
    width: 0;
    overflow: hidden;
}

/* Expanded visual: restore spacing */
.sidebar.hover-open .sidebar-item,
.sidebar.open .sidebar-item {
    justify-content: flex-start;
    padding: 0 20px;
}

.sidebar.hover-open .sidebar-icon,
.sidebar.open .sidebar-icon {
    margin-right: 12px;
}

.sidebar.hover-open .sidebar-text,
.sidebar.open .sidebar-text {
    opacity: 1;
    visibility: visible;
    width: auto;
}

/* Toggle button in header */
.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-right: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}
.sidebar-toggle-btn .hamburger-line {
    width: 20px;
    height: 2px;
    background-color: #fff;
    border-radius: 1px;
    transition: all 0.3s ease;
}

/* Layout shift */
.main-wrapper {
    margin-left: var(--sidebar-w-collapsed);
    transition: margin-left 0.25s ease;
}

/* While collapsed logically, we keep margin-left collapsed (already default).
   When visually expanded (hover-open on desktop or open on mobile), remove collapsed margin. */
.sidebar.hover-open ~ .main-wrapper {
    margin-left: var(--sidebar-w-expanded);
}
body.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-w-collapsed);
}
.main-wrapper.sidebar-collapsed {
    margin-left: var(--sidebar-w-collapsed);
}

/* Early collapse at mid widths: keep collapsed width, allow hover-open to expand */
@media (max-width: 1400px) and (min-width: 769px) {
    .sidebar {
        width: var(--sidebar-w-collapsed);
    }
    .sidebar.hover-open {
        width: var(--sidebar-w-expanded);
    }
    .main-wrapper,
    .main-wrapper.sidebar-collapsed,
    body.sidebar-collapsed .main-wrapper {
        margin-left: var(--sidebar-w-collapsed);
    }
}

/* Mobile: off-canvas by default, slide in with .open */
@media (max-width: 1300px) {
    .sidebar {
        left: calc(-1 * var(--sidebar-w-expanded));
        width: var(--sidebar-w-expanded);
        height: calc(100% - var(--header-height));
    }

    .sidebar.open {
        left: 0;
    }

    .main-wrapper,
    .main-wrapper.sidebar-collapsed,
    body.sidebar-collapsed .main-wrapper {
        margin-left: 0 !important;
    }
}