/* Sidebar Widget styles */

:root {
    --aiw-header-offset: 78px;
    --sb-left-collapsed: 72px;
}

.aiwriter-sidebar-widget {
    position: fixed;
    left: 0;
    top: var(--aiw-header-offset, 0);
    bottom: 0;
    width: var(--sb-left, 230px);
    background: #f8faff;
    border-right: 1px solid #e0e7ef;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 0 0 16px 0;
    min-height: 100vh;
    box-shadow: 1px 0 6px 0 rgba(77, 107, 254, 0.04);
    transition: width 0.22s ease, padding 0.22s ease, box-shadow 0.22s ease;
}
.aiwriter-sidebar-widget.aiw-preload {
    transition: none !important;
}

/* Hide Astra primary footer only on pages with AI sidebar */
body.has-ai-sidebar footer#colophon .site-primary-footer-wrap {
    display: none !important;
}

.aiwriter-sidebar-widget nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.sidebar-item {
    display: flex;
    align-items: center;
    width: 100%;
    height: 35px;
    border-radius: var(--border-radius);
    color: #a0a7c6;
    transition: background 0.16s, color 0.16s;
    cursor: pointer;
}

.sidebar-item.active,
.sidebar-item:hover {
    background: var(--bg-primaryColor, #e7ecff);
    color: var(--primaryColor, #4d6bfe);
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 1px;
    width: 100%;
    height: 100%;
    text-decoration: none;
    padding: 0 18px;
    box-sizing: border-box;
    color: inherit;
    /* Make sure no blue color for links */
}

.sidebar-label {
    display: inline;
    /*margin-left: 7px;*/
    font-size: 1em;
    font-weight: 500;
    color: #233353;
    letter-spacing: 0.01em;
    white-space: nowrap;
    min-width: 0;
    transition: color 0.15s;
}

.sidebar-item.active .sidebar-label,
.sidebar-item:hover .sidebar-label {
    color: var(--primaryColor, #4d6bfe);
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.aiwriter-sidebar-widget .sidebar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    max-width: 18px;
    max-height: 18px;
    /* SVG inlining support */
}
.aiwriter-sidebar-widget .sidebar-icon svg {
    width: 100%;
    height: 100%;
    display: block;
    /* Set main color for strokes/fills via CSS variable if needed */
}

.sidebar-item.access-locked {
    opacity: 0.44;
    pointer-events: none;
}

/* Desktop collapse toggle */
.aiw-collapse-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 42px;
    margin: 0;
    align-self: stretch;
    border-radius: 0;
    border: 1px solid #e0e7ef;
    background: #fff;
    box-shadow: none;
    cursor: pointer;
    color: #314bee;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.aiw-collapse-btn .aiw-collapse-icon {
    all: unset;
    width: 16px !important;
    height: 16px !important;
    display: block !important;
    color: currentColor !important;
    box-sizing: content-box !important;
    pointer-events: none !important;
}
.aiw-collapse-btn .aiw-collapse-icon,
.aiw-collapse-btn .aiw-collapse-icon * {
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
}
.aiw-collapse-btn:focus,
.aiw-collapse-btn:hover {
    background: #eef2ff;
    color: #314bee;
    border-color: #cfd6ff;
}
.aiw-collapse-btn:active {
    transform: scale(.98);
}

@media (min-width: 901px) {
    .aiw-sidebar-header {
        width: 100%;
        min-height: 64px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: stretch;
        gap: 10px;
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        margin-top: auto;
        z-index: 4;
        background: inherit;
        border-top: 1px solid #e6ecf7;
    }
    .aiw-collapse-btn { display: inline-flex; position: relative; z-index: 4; 
    padding: 0;}

    body.aiw-sb-collapsed { --sb-left: var(--sb-left-collapsed); }

    body.aiw-sb-collapsed #aiwriterSidebar {
        width: var(--sb-left-collapsed);
        min-width: var(--sb-left-collapsed);
        padding: 12px 0;
        box-shadow: 1px 0 10px rgba(77,107,254,0.06);
    }
    body.aiw-sb-collapsed #aiwriterSidebar .sidebar-label,
    body.aiw-sb-collapsed #aiwriterSidebar .sidebar-section {
        display: none !important;
    }
    body.aiw-sb-collapsed #aiwriterSidebar .sidebar-item a {
        padding: 0 14px;
        justify-content: center;
    }
    body.aiw-sb-collapsed #aiwriterSidebar .sidebar-menu li a span {
        margin-right: 0;
    }
    body.aiw-sb-collapsed #aiwriterSidebar .have-children > a {
            padding: 8px 0px;
        justify-content: center;
    }
    body.aiw-sb-collapsed #aiwriterSidebar .have-children > a::after {
        display: none;
    }
    body.aiw-sb-collapsed #aiwriterSidebar .have-children > ul {
        display: none !important;
    }
    body.aiw-sb-collapsed #aiwriterSidebar nav {
        padding-left: 4px;
        padding-right: 4px;
    }
    body.aiw-sb-collapsed .aiw-collapse-btn .aiw-collapse-icon {
        transform: rotate(180deg);
    }
    body.aiw-sb-collapsed .aiw-sidebar-header {
        justify-content: stretch;
    }
}

/* For mobile: hide text, shrink sidebar */
@media (max-width: 700px) {
    .aiwriter-sidebar-widget {
        width: 54px;
        min-width: 48px;
        padding: 6px 0;
    }
    .sidebar-label {
        display: none;
    }
    .sidebar-item a {
        padding: 0 7px;
    }
}

/* Optional: subtle hover effect for icons */
.aiwriter-sidebar-widget .sidebar-icon {
    transition: filter 0.18s;
}
.sidebar-item.active .sidebar-icon,
.sidebar-item:hover .sidebar-icon {
    filter: brightness(1.35) drop-shadow(0 0 2px #4d6bfe11);
}



ul.sidebar-menu {
    margin: 0;
    padding: 0;
    width: 100%;
    /*background: #fff;*/
    /*border-right: 1px solid #e0e7ef;*/
    list-style: none;
}
.sidebar-menu li {
    width: 100%;
}
.sidebar-menu li a span {
    margin-right: 16px;
    display: inline-block;
    vertical-align: middle;
    width: 21px;
    height: 21px;
    /* SVG icons will fit naturally */
}
.sidebar-menu li a {
    background-color: #f8faff;
    padding: 8px 22px;
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #233353;
    font-weight: 500;
    border-radius: var(--border-radius);
    transition: background 0.14s, color 0.14s;
}
.sidebar-menu li a:hover {
    background-color: #e7ecff;
    color: #4d6bfe;
}
li.have-children ul {
    padding: 0;
    margin: 0;
}
li.have-children ul li a {
    background-color: #f5f7fd;
    padding-left: 26px;
    font-size: 0.90em;
    color: #5d658d;
    border-radius: var(--border-radius);
    transition: background 0.14s, color 0.14s;
}
li.have-children ul li a:hover {
    color: #314bee;
    background-color: #eaf0ff;
    padding-left: 27px;
}
li.have-children, li {
    position: relative;
}

li.active.have-children span::after {
    transform: translateY(-50%) rotate(90deg);
    color: #4d6bfe;
}
.sidebar-menu .have-children > ul {
    display: none;
}

.have-children > a {
    position: relative;
    padding-right: 34px;
}
.have-children > a::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 20px;
    width: 9px;
    height: 9px;
    border-right: 2px solid #a0a7c6;
    border-bottom: 2px solid #a0a7c6;
    transform: translateY(-50%) rotate(45deg);
    transition: transform 0.25s, border-color 0.18s;
    opacity: 0.8;
}
li.active.have-children > a::after {
    transform: translateY(-50%) rotate(135deg);
    border-color: #4d6bfe;
    opacity: 1;
}


/*Right column: widgets area*/

.aiwriter-widgets-sidebar {


    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 230px;
    background: #f8faff;
    border-left: 1px solid #e0e7ef;
    z-index: 150;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 15px;
    min-height: 100vh;
    box-shadow: -1px 0 6px 0 rgba(77,107,254,0.03);
    gap: 22px;

}

.aiwriter-widget {
    background: #fff;
    /*margin: 5px;*/
}

.aiwriter-widget-title {
    font-weight: 700;
    font-size: 1.08em;
    color: #314bee;
    margin-bottom: 12px;
    letter-spacing: 0.01em;
}



/* Smooth fade for context tips */
#aiwriter-hints-body {
    opacity: 1;
    transition: opacity .42s ease; /* keep in sync with HINT_FADE_MS */
    will-change: opacity;
}
#aiwriter-hints-body.is-fading {
    opacity: 0;
}

/* Respect users that prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    #aiwriter-hints-body {
        transition: none;
    }
}
/* --- Sidebar section headings (Services / Templates / Tools) ---
   - Subtle divider + small uppercase label
   - Aligned with menu item left padding (22px)
   - No pills, fits the light sidebar aesthetic
*/
.sidebar-menu .sidebar-section {
    position: relative;
    width: 100%;
    margin: 14px 0 6px 0;
    padding: 10px 22px 0 22px; /* align with .sidebar-menu li a */
    list-style: none;
}

/* hairline divider above the label */
.sidebar-menu .sidebar-section::before {
    content: "";
    position: absolute;
    left: 22px;
    right: 22px;
    top: 0;
    height: 1px;
    background: #e0e7ef; /* matches sidebar border */
}

/* label: small, uppercase, muted */
.sidebar-menu .sidebar-section-tag {
    display: block;
    padding: 0;             /* no chip/pill look */
    border-radius: 0;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebarSectionColor, #8a96b6); /* subtle, matches UI */
    background: transparent;
    opacity: 0.95;
}

/* non-interactive */
.sidebar-menu .sidebar-section-tag:hover { cursor: default; }

/* Hide headings on narrow screens where labels collapse */
@media (max-width: 700px) {
    .sidebar-menu .sidebar-section { display: none; }
}


/* =============================
   Sidebar: vertical scroll area
   - Makes only the <nav> scrollable
   - Works inside flex column
   - Pretty, thin scrollbars
   ============================= */

/* The sidebar is a flex column. Allow <nav> to shrink and scroll. */
.aiwriter-sidebar-widget nav {
    flex: 1 1 auto;          /* fill remaining height */
    min-height: 0;            /* critical for overflow scrolling in flex containers */
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 6px 10px 6px;  /* space for the scrollbar gutter */
    scrollbar-gutter: stable both-edges; /* avoid layout shift when scrollbar appears */
    -webkit-overflow-scrolling: touch;   /* momentum scroll on iOS */
    overscroll-behavior: contain;        /* prevent scroll chaining to the page */
    scroll-behavior: smooth;             /* smooth wheel/trackpad scrolling */

    /* Soft edge fade (supported in modern engines; harmless elsewhere) */
    mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}

/* Firefox custom scrollbar */
.aiwriter-sidebar-widget nav {
    scrollbar-width: thin;
    scrollbar-color: #c6cfff #f8faff;   /* thumb / track */
}

/* WebKit/Blink custom scrollbar */
.aiwriter-sidebar-widget nav::-webkit-scrollbar {
    width: 8px;
}
.aiwriter-sidebar-widget nav::-webkit-scrollbar-track {
    background: #f1f4ff;
    border-radius: var(--border-radius);
}
.aiwriter-sidebar-widget nav::-webkit-scrollbar-thumb {
    background: #d1d9ff;
    border-radius: var(--border-radius);
    border: 2px solid #f1f4ff; /* creates a nice inset effect */
}
.aiwriter-sidebar-widget nav::-webkit-scrollbar-thumb:hover {
    background: #b7c3ff;
}

/* Optional: small visual fades at top/bottom (purely decorative) */
.aiwriter-sidebar-widget {
    position: fixed; /* already set, just ensuring for the pseudo-elements */
}
.aiwriter-sidebar-widget::before,
.aiwriter-sidebar-widget::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 12px;
    pointer-events: none; /* keep clicks on items */
    z-index: 2;
}
.aiwriter-sidebar-widget::before {
    top: 0;
    background: linear-gradient(to bottom, #f8faff, rgba(248,250,255,0));
}
.aiwriter-sidebar-widget::after {
    bottom: 0;
    background: linear-gradient(to top, #f8faff, rgba(248,250,255,0));
}

/* Mobile: keep scroll active even when labels are hidden */
@media (max-width: 700px) {
    .aiwriter-sidebar-widget nav {
        padding: 0 3px 8px 3px;
    }
}
@media (max-width: 900px) {
    .aiwriter-sidebar-widget { top: 0; }
    .aiw-sidebar-header { display: none; }
}



@media (min-width: 1681px) {
    .aiwriter-sidebar-widget {
        width: var(--sb-left, 260px);
    }
    .aiwriter-widgets-sidebar {
        width: 260px;
    }
}

@media (min-width:1180px) and (max-width:1680px){

    .aiwriter-sidebar-widget { width: var(--sb-left, 230px); }
    .aiwriter-widgets-sidebar { width: var(--sb-right); }
    .aiwriter-sidebar-widget ul.sidebar-menu { width: 100%; }

    #aiwriter-hints-widget ul{
        margin: 8px 0 0 0 !important;
    }
}


/* =========================================================
   Mobile drawer (single source of truth)
   - Toggle + overlay + drawer widths
   ========================================================= */

/* Hide toggle on desktop by default */
.aiw-toggle { display: none; }

/* Prevent background scroll via class instead of inline styles */
body.no-scroll { overflow: hidden; }

@media (max-width: 900px) {
  .aiwriter-widgets-sidebar { display: none !important; }

  .aiwriter-sidebar-widget .sidebar-menu .have-children > ul { display: none !important; }
  #aiwriterSidebar.aiwriter-sidebar-widget.is-open .sidebar-menu .have-children > ul {
      display: block !important;
      width: max-content;
  }

  .sidebar-menu li a { padding: 7px; }
  #aiwriterSidebar.is-open .sidebar-menu li a { padding: 10px 18px; }

  .aiw-toggle {
    display: inline-flex;
    position: fixed;
    bottom: max(12px, env(safe-area-inset-bottom));
    left:   0;
    z-index: 340; /* above overlay (300) and sidebar (320) */
    width: 46px; height: 44px;
    align-items: center; justify-content: center;
    border-radius: 3px;
    border: 1px solid #e3e8f6;
    background: #fff;
    color: #35405f; /* drives SVG stroke via currentColor */
    box-shadow: 0 6px 22px rgba(50,60,120,.10);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
    overflow: clip; /* clip internal overflow safely */
  }
  .aiw-toggle:active { transform: scale(.98); }

  /* Active style when drawer is open */
  body.drawer-open .aiw-toggle {
    background: #e7ecff;
    color: #314bee;
    border-color: #cfd6ff;
    box-shadow: 0 6px 22px rgba(49,75,238,.16);
  }

  /* SVG icon: hard reset to survive hostile globals */
  .aiw-toggle .aiw-icon {
    all: unset;
    display: block !important;
    width: 22px !important;
    height: 22px !important;
    color: currentColor !important;
    overflow: visible !important;
    pointer-events: none !important;
    box-sizing: content-box !important;
    shape-rendering: geometricPrecision;
  }
  .aiw-toggle .aiw-icon,
  .aiw-toggle .aiw-icon * {
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    vector-effect: non-scaling-stroke !important;
  }

  /* Overlay under the sidebar */
  .aiw-overlay {
    position: fixed;
    inset: 0;
    background: rgba(24,32,56,.28);
    backdrop-filter: blur(1px);
    z-index: 300;                /* < sidebar (320), > page */
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }
  .aiw-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Sidebar as drawer */
  #aiwriterSidebar.aiwriter-sidebar-widget {
    width: 46px; min-width: 46px; padding: 6px 0;
    box-shadow: 1px 0 6px rgba(77,107,254,0.04);
    transition: transform .22s ease, width .22s ease, box-shadow .22s ease;
    z-index: 320; /* above overlay */
    will-change: width, transform;
  }
  #aiwriterSidebar.aiwriter-sidebar-widget.is-open {
    width: min(78vw, 320px);
    min-width: 280px;
    box-shadow: 2px 0 28px rgba(30,40,80,.18);
  }

  /* Labels visibility */
  #aiwriterSidebar:not(.is-open) .sidebar-label { display: none !important; }
  #aiwriterSidebar.is-open .sidebar-label { display: inline !important; }

  /* Section headings hidden when closed */
  #aiwriterSidebar:not(.is-open) .sidebar-section { display: none !important; }

  /* Link paddings per state */
  #aiwriterSidebar:not(.is-open) .sidebar-item a { padding: 0 7px; }
  #aiwriterSidebar.is-open .sidebar-item a { padding: 0 18px; }

  /* Drawer nav scrolling */
  #aiwriterSidebar nav { padding: 0 6px 10px 6px; }
}

/* Optional: fully hide the rail until opened
@media (max-width: 900px) {
  #aiwriterSidebar.aiwriter-sidebar-widget { transform: translateX(-100%); width: min(78vw, 320px); min-width: 280px; }
  #aiwriterSidebar.aiwriter-sidebar-widget.is-open { transform: translateX(0); }
}
*/

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .aiw-overlay,
  #aiwriterSidebar.aiwriter-sidebar-widget,
  .aiw-toggle,
  .aiw-collapse-btn { transition: none !important; }
}
