/* UNIVERSAL SIDEBAR CSS */

:root {
    --sidebar-width: 100px;
    --sidebar-collapsed-width: 0px;
    --green-primary: #00ff41;
    --purple-primary: #8b5cf6;
    --text-secondary: #8a8f98;
}

/* Sidebar Container */
.sidebar {
    background: linear-gradient(180deg, #060608, #08080c);
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0 1.5rem;
    gap: 0.5rem;
    position: fixed;
    left: 0;
    top: 78px;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 998;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed State */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    padding: 0;
    border-right: none;
}

.sidebar.collapsed .sidebar-nav,
.sidebar.collapsed .sidebar-item {
    opacity: 0;
    pointer-events: none;
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, rgba(0,255,65,0.15), transparent 30%, transparent 70%, rgba(0,240,255,0.1));
    transition: opacity 0.3s ease;
}

.sidebar.collapsed::after {
    opacity: 0;
}

/* =============================================
   КОНТЕНТ СТОРІНКИ — розтягується коли sidebar відкритий/прихований
   Перелік всіх контейнерів які зустрічаються на сторінках
   ============================================= */
/* Тільки TOP-LEVEL контейнери отримують margin — не їхні діти */
body:has(.sidebar) .platform-container,
body:has(.sidebar) .page-content,
body:has(.sidebar) .content-wrapper,
body:has(.sidebar) .trading-container,
body:has(.sidebar) .pulse-page,
body:has(.sidebar) .mode-toggle-container,
body:has(.sidebar) .legal-container {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Для сторінок де main/main-content є top-level (без platform-container) */
body:has(.sidebar) > main,
body:has(.sidebar) > .main-content {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body:has(.sidebar.collapsed) .platform-container,
body:has(.sidebar.collapsed) .page-content,
body:has(.sidebar.collapsed) .content-wrapper,
body:has(.sidebar.collapsed) .trading-container,
body:has(.sidebar.collapsed) .pulse-page,
body:has(.sidebar.collapsed) .mode-toggle-container,
body:has(.sidebar.collapsed) .legal-container {
    margin-left: 0 !important;
}

body:has(.sidebar.collapsed) > main,
body:has(.sidebar.collapsed) > .main-content {
    margin-left: 0 !important;
}

/* Navigation */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
    padding-top: 4.75rem;
    transition: opacity 0.2s ease;
}

/* Sidebar Items */
.sidebar-item {
    width: 56px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-secondary);
    text-decoration: none;
    position: relative;
}

/* Hover — single clean effect */
.sidebar-item:hover {
    background: rgba(255,255,255,0.06);
    color: #e8e8ea;
    border-color: rgba(255,255,255,0.08);
}

/* Active — green accent, no double glow */
.sidebar-item.active {
    background: rgba(0,255,65,0.08);
    color: var(--green-primary);
    border-color: rgba(0,255,65,0.18);
}

.sidebar-item svg {
    width: 26px;
    height: 26px;
}

/* ── Tooltip ── */
.sidebar-item[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: rgba(8,8,12,0.97);
    color: #e8e8ea;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    border: 1px solid rgba(0,255,65,0.12);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
    z-index: 1001;
}

.sidebar-item[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}


/* =============================================
   ЄДИНА КНОПКА TOGGLE
   ============================================= */
/* ── Sidebar Buttons Group (toggle + swap move together) ── */
.sidebar-btns-group {
    position: fixed;
    top: calc(78px + 30px);
    left: calc(var(--sidebar-width) / 2 - 28px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed ~ .sidebar-btns-group {
    left: 10px;
}

.sidebar-toggle-btn {
    position: relative;
    width: 56px;
    height: 36px;
    background: linear-gradient(135deg, rgba(0,255,65,0.08), rgba(0,255,65,0.03));
    border: 1px solid rgba(0,255,65,0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed ~ .sidebar-btns-group .sidebar-toggle-btn {
    background: rgba(6, 6, 8, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-color: rgba(0,255,65,0.25);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
}

.sidebar-toggle-btn:hover {
    background: linear-gradient(135deg, rgba(0,255,65,0.15), rgba(0,255,65,0.05));
    border-color: var(--green-primary);
    box-shadow: 0 0 16px rgba(0,255,65,0.25);
    transform: scale(1.05);
}

.sidebar-toggle-btn svg {
    width: 20px;
    height: 20px;
    color: var(--green-primary);
    position: absolute;
    transition: opacity 0.25s ease;
}

.sidebar-toggle-btn .arrow-collapse { opacity: 1; }
.sidebar.collapsed ~ .sidebar-btns-group .sidebar-toggle-btn .arrow-collapse { opacity: 0; }
.sidebar-toggle-btn .arrow-expand { opacity: 0; }
.sidebar.collapsed ~ .sidebar-btns-group .sidebar-toggle-btn .arrow-expand { opacity: 1; }

/* Hide swap button when sidebar collapsed (injected by admin.html) */
.sidebar.collapsed ~ .sidebar-btns-group .sidebar-swap-btn {
    display: none !important;
}

/* Мобільні — ховаємо все */
@media (max-width: 900px) {
    .sidebar,
    .sidebar-btns-group {
        display: none !important;
    }

    body:has(.sidebar) .platform-container,
    body:has(.sidebar) .page-content,
    body:has(.sidebar) .content-wrapper,
    body:has(.sidebar) .trading-container,
    body:has(.sidebar) .pulse-page,
    body:has(.sidebar) .mode-toggle-container,
    body:has(.sidebar) > main,
    body:has(.sidebar) > .main-content {
        margin-left: 0 !important;
    }
}
