/* Source of truth: copied 1:1 from /themes/create (templates/theme_edit.html)
   Sidebar classes:
   - .theme-sections-nav
   - .theme-section-link (+ .active)
   IMPORTANT: Do not modify styling here unless /themes/create changes too.
*/

/* Левое меню секций */
.theme-sections-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: static;
    height: fit-content;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 18px;
    padding: 16px 8px;
    align-self: start;
    z-index: 1;
}

/* /themes/create + theme editor pages:
   Sidebar must stay visible ("always on screen") → sticky.
   Uses real header height from base.html JS: --cp-header-height. */
[data-theme-edit] .theme-sections-nav {
    /* Theme editor sidebar: always visible while scrolling.
       Use fixed (more robust than sticky across containers/iframes). */
    position: fixed !important;
    top: calc(var(--cp-header-height, 0px) + 16px) !important;
    left: clamp(16px, 2vw, 28px) !important;
    width: 240px !important;
    bottom: auto !important;
    align-self: start;
    max-height: calc(100vh - var(--cp-header-height, 0px) - 32px) !important;
    overflow: auto !important;
    z-index: 2;
}

/* When sidebar is fixed (out of flow), keep the main content in the 2nd grid column
   so section cards are NOT squeezed into the first 240px column. */
@media (min-width: 681px) {
  [data-theme-edit] .theme-sections-content {
    grid-column: 2 / -1;
    min-width: 0;
  }
}

html[data-theme="dark"] .theme-sections-nav {
    background: rgba(15, 23, 42, 0.6);
}

/* Light theme: делаем меню секций (табы) читабельным */
html[data-theme="light"] .theme-sections-nav {
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.12);
    box-shadow:
        0 10px 24px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.theme-section-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    width: 100%;
}

@media (max-width: 680px) {
    .theme-edit-layout {
        grid-template-columns: 1fr;
    }

    /* In single-column mode the nav sits above content; keep it visible while scrolling */
    [data-theme-edit] .theme-sections-nav {
        position: fixed !important;
        top: calc(var(--cp-header-height, 0px) + 10px) !important;
        left: clamp(12px, 2vw, 16px) !important;
        width: 100%;
        max-height: calc(100vh - var(--cp-header-height, 0px) - 20px) !important;
        overflow: auto !important;
        z-index: 3;
    }
}

html[data-theme="dark"] .theme-section-link {
    color: #94a3b8;
}

html[data-theme="light"] .theme-section-link {
    color: #0f172a;
}

.theme-section-link:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    text-decoration: none;
}

html[data-theme="dark"] .theme-section-link:hover {
    color: #60a5fa;
}

html[data-theme="light"] .theme-section-link:hover {
    background: rgba(37, 99, 235, 0.10);
    color: #1d4ed8;
}

.theme-section-link.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.2));
    color: #2563eb;
    font-weight: 600;
}

html[data-theme="dark"] .theme-section-link.active {
    color: #60a5fa;
}

html[data-theme="light"] .theme-section-link.active {
    background: rgba(37, 99, 235, 0.14);
    border: 1px solid rgba(37, 99, 235, 0.22);
    color: #1d4ed8;
}

/* Accessibility: фокус для клавиатуры */
.theme-section-link:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.45);
    outline-offset: 2px;
}


