/* ============================================================
   AI INTELLIGENCE PANEL — STANDALONE MODULE
   Glassmorphism · Micro-interactions · Award-worthy design
   ============================================================ */

/* ── Panel Container ── */
.features-section {
    background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0.95) 100%);
    border-left: none !important;
    position: relative;
    /* overflow must NOT be hidden — toggle button bleeds left past the panel edge */
    overflow: visible;
}

    /* Static gradient accent stripe on the left edge.
       PERF: this used `animation: ai-gradient-flow 3s infinite` on
       background-position. An infinite paint-triggering animation living in the
       same stacking context as the .feature-card backdrop-filters forced those
       blurs to re-rasterise EVERY frame — the continuous ~60-90ms
       "(no script attribution — style/layout/paint)" frames in the perf trace,
       which is what made typing feel laggy/paused even though the keystroke JS
       is cheap. A static stripe is visually all-but-identical and costs nothing
       after first paint. */
    .features-section::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 4px;
        height: 100%;
        background: linear-gradient(180deg, #F58220, #56C4F8, #F58220);
        z-index: 2;
        pointer-events: none;
    }

/* ============================================================
   TOGGLE BUTTON
   Sits inside #rightPanel (position:relative via Bootstrap class).
   left:-22px bleeds it left across the panel seam so it straddles
   the boundary between left and right panels.
   top:50% + translateY(-50%) centres it vertically in the panel.

   Hidden on mobile (<992px) via CSS, shown on desktop.
   No Bootstrap d-none/d-md-flex used — those override position:absolute.

   Arrow direction:
     Panel OPEN   → chevron-right ▶  ("click to collapse")
     Panel CLOSED → rotated 180° = chevron-left ◀  ("click to expand")
   ============================================================ */
.btn-ai-toggle {
    /* Positioning — straddles the panel seam */
    position: absolute;
    top: 50%;
    left: -22px;
    transform: translateY(-50%);
    z-index: 300;
    /* Hide on mobile — shown on desktop only */
    display: none;
    /* Size — matches floating ecosystem */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    /* Glassmorphic style matching .btn-floating */
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(245, 130, 32, 0.4) !important;
    color: #F58220 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.06), 0 0 0 4px rgba(255, 255, 255, 0.6);
    /* Spring transition */
    transition: background 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.25s ease, border-color 0.25s ease, box-shadow 0.3s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}

@media (min-width: 992px) {
    .btn-ai-toggle {
        display: flex;
    }
}

.btn-ai-toggle:hover {
    background: #F58220 !important;
    color: #ffffff !important;
    border-color: #F58220 !important;
    box-shadow: 0 12px 28px rgba(245, 130, 32, 0.40), 0 4px 10px rgba(245, 130, 32, 0.20), 0 0 0 5px rgba(245, 130, 32, 0.12);
    transform: translateY(-50%) scale(1.10);
}

.btn-ai-toggle:active {
    transform: translateY(-50%) scale(0.94);
}

/* Chevron icon — smooth rotation driven by CSS, not JS */
.ai-toggle-icon {
    font-size: 1.15rem;
    line-height: 1;
    display: block;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Panel OPEN  → ▶ (default, no rotation)
   Panel CLOSED → rotate 180° = ◀ */
#splitWrapper.panel-collapsed .btn-ai-toggle .ai-toggle-icon {
    transform: rotate(180deg);
}

/* ── Panel Content fade ── */
#rightPanelContent {
    transition: opacity 0.35s ease, visibility 0.35s ease;
    width: 100%;
    /* No min-width here — letting it shrink prevents overflow during collapse */
    overflow: hidden;
}

#splitWrapper.panel-collapsed #rightPanelContent {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ── Panel Header ── */
#rightPanelContent .d-flex.justify-content-between.align-items-end {
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 2px solid rgba(245,130,32,0.15);
}

#rightPanelContent h5 {
    font-size: 1.35rem;
    font-weight: 800;
    background: linear-gradient(135deg, #1A1D20 0%, #F58220 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.02em;
    position: relative;
    display: inline-block;
}

    #rightPanelContent h5::after {
        content: '';
        position: absolute;
        bottom: -12px;
        left: 0;
        width: 50px;
        height: 3px;
        background: linear-gradient(90deg, #F58220, #56C4F8);
        border-radius: 3px;
    }

/* ── Badge ── */
.badge.bg-primary-blue {
    background: linear-gradient(135deg, rgba(245,130,32,0.15) 0%, rgba(86,196,248,0.15) 100%) !important;
    color: #F58220 !important;
    padding: 8px 16px !important;
    border-radius: 40px !important;
    font-weight: 700 !important;
    font-size: 0.75rem !important;
    letter-spacing: 0.03em;
    border: 1px solid rgba(245,130,32,0.3);
    backdrop-filter: blur(4px);
}

/* ── Features Scroll Stack ── */
.features-stack {
    display: flex;
    flex-direction: column;
    gap: 7px; /* further tightened */
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-width: thin;
    scrollbar-color: #F58220 rgba(245,130,32,0.2);
    max-height: calc(100vh - 180px);
}

    .features-stack::-webkit-scrollbar {
        width: 5px;
    }

    .features-stack::-webkit-scrollbar-track {
        background: rgba(245,130,32,0.1);
        border-radius: 10px;
    }

    .features-stack::-webkit-scrollbar-thumb {
        background: #F58220;
        border-radius: 10px;
    }

/* ── Feature Card ── */
.feature-card {
    display: flex;
    gap: 10px;
    align-items: center;
    /*   padding: 8px 12px;*/
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(245,130,32,0.12);
    border-radius: 13px;
    cursor: pointer;
    /* CRITICAL: never let a flex-column parent with max-height squash the cards
       below their content (that caused titles to clip/overlap when 8 cards
       exceeded the panel height). Cards keep their natural height; the stack
       scrolls only as a last resort. */
    flex-shrink: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    /* PERF: backdrop-filter removed. The card background is rgba(255,255,255,.95)
       — 95% opaque — so the blur was barely perceptible, but each of the 8 cards
       had to re-rasterise its backdrop whenever anything behind moved. Dropping
       it is a near-zero visual change and a large, continuous paint saving. */
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    animation: ai-card-slide-up 0.5s ease forwards;
    animation-delay: calc(var(--index, 0) * 0.08s);
    opacity: 0;
}

    .feature-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(245,130,32,0.1), transparent);
        transition: left 0.6s ease;
        pointer-events: none;
    }

    .feature-card:hover::before {
        left: 100%;
    }

    .feature-card:hover {
        transform: translateY(-6px) scale(1.02);
        border-color: rgba(245,130,32,0.4);
        box-shadow: 0 20px 35px -12px rgba(245,130,32,0.25);
        background: #ffffff;
    }

    .feature-card:nth-child(1) {
        --index: 1;
    }

    .feature-card:nth-child(2) {
        --index: 2;
    }

    .feature-card:nth-child(3) {
        --index: 3;
    }

    .feature-card:nth-child(4) {
        --index: 4;
    }

    .feature-card:nth-child(5) {
        --index: 5;
    }

    .feature-card:nth-child(6) {
        --index: 6;
    }

    .feature-card:nth-child(7) {
        --index: 7;
    }

    .feature-card:nth-child(8) {
        --index: 8;
    }

@keyframes ai-card-slide-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Icon Box ── */
.icon-box {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center; /* keeps the glyph dead-centre in the wrapper */
    flex-shrink: 0;
    transition: all 0.3s ease;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    position: relative;
    overflow: hidden;
}

    .icon-box i {
        font-size: 1.1rem;
        line-height: 1; /* removes glyph baseline gap so it centres perfectly */
        display: block;
        transition: transform 0.3s ease;
        position: relative;
        z-index: 1;
    }

.feature-card:hover .icon-box i {
    transform: scale(1.15);
}

.icon-box::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.feature-card:hover .icon-box::after {
    opacity: 1;
}

/* Gradient variants */
.bg-orange-gradient {
    background: linear-gradient(135deg, #F58220, #ff9f4d);
}

.bg-blue-gradient {
    background: linear-gradient(135deg, #56C4F8, #2A85FF);
}

.bg-pink-gradient {
    background: linear-gradient(135deg, #e056fd, #686de0);
}

/* ── Feature Text ── */
.feature-text {
    flex: 1;
    min-width: 0;
}

    .feature-text h6 {
        font-size: 0.88rem;
        font-weight: 800;
        margin-bottom: 2px;
        color: #1A1D20;
        letter-spacing: -0.01em;
        line-height: 1.2;
        transition: color 0.2s ease;
    }

.feature-card:hover .feature-text h6 {
    color: #F58220;
}

.feature-text p {
    font-size: 0.7rem;
    color: #6C757D;
    line-height: 1.3;
    margin: 0;
    /* Bound every card to a predictable height: a long description (e.g.
       Marketplace) can't grow a card taller than its siblings and push the
       8th card (Stay) off-screen. The title carries the meaning; this is
       supporting copy, so two lines is enough. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Responsive ── */
@media (max-width: 991px) {
    /* btn-ai-toggle is display:none by default; shown only at 992px+ (see above) */

    .features-section::before {
        display: none;
    }

    .feature-card {
        padding: 9px 12px;
    }

    .icon-box {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

        .icon-box i {
            font-size: 1.15rem;
        }

    .feature-text h6 {
        font-size: 0.88rem;
    }

    .feature-text p {
        font-size: 0.72rem;
    }
}

/* ── Short viewports (laptops like 1366×768, split-screen, zoomed) ───────────
   The desktop split panel must fit all eight cards + header in the panel's
   height (≈ viewport − navbar). On short heights, step the sizes down further
   so nothing has to scroll. Discrete breakpoints (not fluid math) keep this
   predictable and easy to reason about. Only the desktop panel (≥992px). */
@media (min-width: 992px) and (max-height: 860px) {
    .features-stack {
        gap: 7px;
    }

    .feature-card {
        /*  padding: 8px 12px;*/
    }

    .icon-box {
        width: 35px;
        height: 35px;
        border-radius: 10px;
    }

        .icon-box i {
            font-size: 1.12rem;
        }

    .feature-text h6 {
        font-size: 0.56rem;
        margin-bottom: 1px;
    }

    .feature-text p {
        font-size: 0.4rem;
        line-height: 1.28;
    }

    #rightPanelContent .d-flex.justify-content-between.align-items-end {
        margin-bottom: 7px;
        padding-bottom: 5px;
    }

    #rightPanelContent h5 {
        font-size: 1.2rem;
    }
}

@media (min-width: 992px) and (max-height: 720px) {
    .features-stack {
        gap: 6px;
    }

    .feature-card {
        padding: 6px 11px;
        border-radius: 12px;
    }

    .icon-box {
        width: 32px;
        height: 32px;
        border-radius: 9px;
    }

        .icon-box i {
            font-size: 1rem;
        }

    .feature-text h6 {
        font-size: 0.83rem;
    }

    .feature-text p {
        font-size: 0.68rem;
        line-height: 1.25;
    }

    #rightPanelContent h5 {
        font-size: 1.1rem;
    }
}
