/**
 * SidebarBuilder.css - Material Design 3 Styles
 */

/* === Sidebar Container === */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    background: #ffffff;
    border-right: 1px solid #e8eaed;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    z-index: 1000;
    overflow: visible;
}

.sidebar-left {
    left: 0;
}

.sidebar-right {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid #e8eaed;
}

/* === Sidebar Header === */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e8eaed;
    flex-shrink: 0;
}

.sidebar-collapsed .sidebar-header {
    padding: 16px;
    text-align: center;
}

/* === Sidebar Search === */
.sidebar-search {
    padding: 16px;
    border-bottom: 1px solid #e8eaed;
    flex-shrink: 0;
}

.sidebar-search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.sidebar-search-input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.sidebar-collapsed .sidebar-search-input {
    text-align: center;
    padding: 10px 8px;
}

/* === Sidebar Navigation === */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 8px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #dadce0;
    border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: #bdc1c6;
}

/* === Sidebar List === */
.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-list[data-level="1"] {
    padding-left: 16px;
}

.sidebar-list[data-level="2"] {
    padding-left: 32px;
}

/* === Sidebar Item === */
.sidebar-item {
    margin: 0 8px;
}

/* === Sidebar Link === */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: #5f6368;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
}

.sidebar-link:hover {
    background: #f1f3f4;
    color: #202124;
}

.sidebar-item-active>.sidebar-link {
    background: #e8f0fe;
    color: #1a73e8;
}

.sidebar-item-active>.sidebar-link .sidebar-icon {
    color: #1a73e8;
}

/* === Sidebar Icon === */
.sidebar-icon {
    font-size: 20px;
    line-height: 1;
    color: #5f6368;
    flex-shrink: 0;
    transition: color 0.2s;
}

.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 12px;
}

.sidebar-collapsed .sidebar-icon {
    font-size: 24px;
}

/* === Sidebar Label === */
.sidebar-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-collapsed .sidebar-label {
    display: none;
}

/* === Sidebar Badge === */
.sidebar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #ea4335;
    color: white;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-collapsed .sidebar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 8px;
    height: 8px;
    padding: 0;
    font-size: 0;
}

/* === Sidebar Arrow === */
.sidebar-arrow {
    font-size: 16px;
    color: #5f6368;
    margin-left: auto;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.sidebar-arrow-expanded {
    transform: rotate(90deg);
}

.sidebar-collapsed .sidebar-arrow {
    display: none;
}

/* === Sidebar Submenu === */
.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-submenu-expanded {
    max-height: 1000px;
}

.sidebar-collapsed .sidebar-submenu {
    display: none;
}

/* === Sidebar Divider === */
.sidebar-divider {
    height: 1px;
    background: #e8eaed;
    margin: 8px 16px;
}

/* === Sidebar Heading === */
.sidebar-heading {
    padding: 12px 16px 4px;
    color: #5f6368;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Collapsed state: Show as horizontal divider line */
.sidebar-heading-collapsed {
    text-align: center;
    padding: 8px 12px;
    font-size: 0;
    position: relative;
}

.sidebar-heading-collapsed::after {
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #dadce0 50%, transparent 100%);
    width: 100%;
}

/* === Sidebar Footer === */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #e8eaed;
    flex-shrink: 0;
}

.sidebar-collapsed .sidebar-footer {
    padding: 12px;
    text-align: center;
}

/* === Sidebar Toggle Button === */
.sidebar-toggle {
    position: absolute;
    top: 20px;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid #dadce0;
    background: #ffffff;
    color: #5f6368;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1001;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle:hover {
    background: #f8f9fa;
    color: #1a73e8;
    border-color: #1a73e8;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.2);
}

.sidebar-toggle:active {
    background: #e8f0fe;
}

.sidebar-right .sidebar-toggle {
    right: auto;
    left: -14px;
}

.sidebar-toggle-icon {
    transition: transform 0.2s ease;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Rotate icon when collapsed */
.sidebar-collapsed .sidebar-toggle-icon {
    transform: rotate(180deg);
}

/* === Mobile === */
@media (max-width: 1023px) {
    .sidebar {
        box-shadow: 2px 0 16px rgba(0, 0, 0, 0.2);
        z-index: 1100;
    }

    .sidebar-toggle {
        top: 50%;
        right: -14px;
        transform: translateY(-50%);
    }

    .sidebar-collapsed .sidebar-toggle {
        right: -14px;
    }

    .sidebar-collapsed .sidebar-toggle-icon {
        transform: rotate(180deg);
    }
}

/* === Backdrop for Mobile === */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.sidebar-backdrop.show {
    display: block;
}

/* === Sidebar Version Badge === */
.sidebar .ssi-version-badge {
    position: absolute;
    bottom: 4px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    border: none;
    color: #dadce0;
    font-family: var(--ssi-font-family);
    font-size: 10px;
    width: auto;
    opacity: 1;
    z-index: 1;
}

.sidebar-collapsed .ssi-version-badge {
    display: none;
}

/* === Push Mode (v2.2.0) === */
/* When sidebar pushes content instead of overlaying it */

.sidebar-push-mode {
    position: relative;
}

.sidebar-push-content {
    transition: margin-left 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
                margin-right 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Push mode on mobile still uses overlay */
@media (max-width: 1023px) {
    .sidebar-push-mode {
        position: fixed;
    }

    .sidebar-push-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* === Full Collapse Mode (v2.5.3) === */
/* Sidebar completely hides when collapsed */

.sidebar-full-collapse.sidebar-collapsed {
    overflow: visible; /* Keep visible so toggle button shows */
    border: none;
    background: transparent;
}

.sidebar-full-collapse.sidebar-collapsed .sidebar-header,
.sidebar-full-collapse.sidebar-collapsed .sidebar-search,
.sidebar-full-collapse.sidebar-collapsed .sidebar-nav,
.sidebar-full-collapse.sidebar-collapsed .sidebar-footer,
.sidebar-full-collapse.sidebar-collapsed .ssi-version-badge {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Toggle button stays visible and moves to edge */
.sidebar-full-collapse .sidebar-toggle {
    transition: all 0.3s ease;
}

.sidebar-full-collapse.sidebar-collapsed .sidebar-toggle {
    right: -40px;
    top: 20px;
    background: #1a73e8;
    color: white;
    border-color: #1a73e8;
    width: 36px;
    height: 36px;
    border-radius: 0 8px 8px 0;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-full-collapse.sidebar-collapsed .sidebar-toggle:hover {
    background: #1557b0;
    border-color: #1557b0;
}

.sidebar-full-collapse.sidebar-right.sidebar-collapsed .sidebar-toggle {
    left: -40px;
    right: auto;
    border-radius: 8px 0 0 8px;
}

/* === Dark Mode === */
html.dark-mode .sidebar,
html.m3-dark .sidebar {
    background: #1e1e1e !important;
    border-right-color: #3d3d3d !important;
}

html.dark-mode .sidebar-right,
html.m3-dark .sidebar-right {
    border-left-color: #3d3d3d !important;
}

html.dark-mode .sidebar-header,
html.m3-dark .sidebar-header {
    border-bottom-color: #3d3d3d !important;
}

html.dark-mode .sidebar-search,
html.m3-dark .sidebar-search {
    border-bottom-color: #3d3d3d !important;
}

html.dark-mode .sidebar-search-input,
html.m3-dark .sidebar-search-input {
    background: #2d2d2d !important;
    border-color: #4d4d4d !important;
    color: #e1e1e1 !important;
}

html.dark-mode .sidebar-search-input::placeholder,
html.m3-dark .sidebar-search-input::placeholder {
    color: #a1a1a1 !important;
}

html.dark-mode .sidebar-search-input:focus,
html.m3-dark .sidebar-search-input:focus {
    border-color: #8ab4f8 !important;
    box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.2) !important;
}

html.dark-mode .sidebar-nav::-webkit-scrollbar-thumb,
html.m3-dark .sidebar-nav::-webkit-scrollbar-thumb {
    background: #6c6c6c !important;
}

html.dark-mode .sidebar-nav::-webkit-scrollbar-thumb:hover,
html.m3-dark .sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: #8c8c8c !important;
}

html.dark-mode .sidebar-link,
html.m3-dark .sidebar-link {
    color: #a1a1a1 !important;
}

html.dark-mode .sidebar-link:hover,
html.m3-dark .sidebar-link:hover {
    background: rgba(138, 180, 248, 0.12) !important;
    color: #e1e1e1 !important;
}

html.dark-mode .sidebar-item-active > .sidebar-link,
html.m3-dark .sidebar-item-active > .sidebar-link {
    background: rgba(138, 180, 248, 0.2) !important;
    color: #8ab4f8 !important;
}

html.dark-mode .sidebar-item-active > .sidebar-link .sidebar-icon,
html.m3-dark .sidebar-item-active > .sidebar-link .sidebar-icon {
    color: #8ab4f8 !important;
}

html.dark-mode .sidebar-icon,
html.m3-dark .sidebar-icon {
    color: #a1a1a1 !important;
}

html.dark-mode .sidebar-divider,
html.m3-dark .sidebar-divider {
    background: #3d3d3d !important;
}

html.dark-mode .sidebar-heading,
html.m3-dark .sidebar-heading {
    color: #a1a1a1 !important;
}

html.dark-mode .sidebar-heading-collapsed::after,
html.m3-dark .sidebar-heading-collapsed::after {
    background: linear-gradient(90deg, transparent 0%, #4d4d4d 50%, transparent 100%) !important;
}

html.dark-mode .sidebar-footer,
html.m3-dark .sidebar-footer {
    border-top-color: #3d3d3d !important;
}

html.dark-mode .sidebar-toggle,
html.m3-dark .sidebar-toggle {
    background: #2d2d2d !important;
    border-color: #4d4d4d !important;
    color: #a1a1a1 !important;
}

html.dark-mode .sidebar-toggle:hover,
html.m3-dark .sidebar-toggle:hover {
    background: #353535 !important;
    color: #8ab4f8 !important;
    border-color: #8ab4f8 !important;
}

html.dark-mode .sidebar-toggle:active,
html.m3-dark .sidebar-toggle:active {
    background: rgba(138, 180, 248, 0.2) !important;
}

html.dark-mode .sidebar-arrow,
html.m3-dark .sidebar-arrow {
    color: #a1a1a1 !important;
}

html.dark-mode .sidebar .ssi-version-badge,
html.m3-dark .sidebar .ssi-version-badge {
    color: #6c6c6c !important;
}

html.dark-mode .sidebar-backdrop,
html.m3-dark .sidebar-backdrop {
    background: rgba(0, 0, 0, 0.7) !important;
}

/* Full collapse dark mode */
html.dark-mode .sidebar-full-collapse.sidebar-collapsed .sidebar-toggle,
html.m3-dark .sidebar-full-collapse.sidebar-collapsed .sidebar-toggle {
    background: #8ab4f8 !important;
    border-color: #8ab4f8 !important;
    color: #003c8f !important;
}

html.dark-mode .sidebar-full-collapse.sidebar-collapsed .sidebar-toggle:hover,
html.m3-dark .sidebar-full-collapse.sidebar-collapsed .sidebar-toggle:hover {
    background: #aecbfa !important;
    border-color: #aecbfa !important;
}