/* ============================================================
   2. WIKI UI COMPONENTS, ACCORDIONS & MODALS
   ============================================================ */

.wiki-search-box {
    margin-bottom: 20px;
    position: relative;
}

.wiki-search-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: #ffffff;
    padding: 10px 14px 10px 36px;
    border-radius: 10px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.wiki-search-input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.35);
}

.wiki-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.95rem;
    color: var(--text-muted);
    pointer-events: none;
}

.toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toc-group-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #60a5fa;
    font-weight: 700;
    padding: 14px 8px 6px 8px;
}

/* Native Details/Summary Accordion */
.toc-accordion {
    border-radius: 8px;
    background: transparent;
    transition: background 0.2s ease;
    display: block;
    margin-bottom: 2px;
}

.toc-accordion summary {
    list-style: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 9px 12px !important;
    border-radius: 8px !important;
    color: var(--text-muted) !important;
    font-size: 0.88rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    user-select: none !important;
    transition: all 0.2s ease !important;
    border-left: 2px solid transparent !important;
    outline: none !important;
}

.toc-accordion summary::-webkit-details-marker {
    display: none !important;
}

.toc-accordion summary:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.06) !important;
}

.toc-accordion[open] summary {
    color: #93c5fd !important;
}

.toc-accordion.active summary {
    border-left-color: var(--primary) !important;
    background: rgba(59, 130, 246, 0.09) !important;
    font-weight: 600 !important;
}

.toc-accordion-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
}

.toc-chevron {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
    flex-shrink: 0;
}

.toc-accordion[open] .toc-chevron {
    transform: rotate(90deg);
    color: #60a5fa;
}

.toc-sub-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0 6px 12px;
    margin: 2px 0 4px 14px;
    border-left: 1.5px solid rgba(59, 130, 246, 0.35);
}

.toc-sub-link {
    display: block !important;
    padding: 6px 10px !important;
    border-radius: 6px !important;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    font-size: 0.82rem !important;
    line-height: 1.4 !important;
    transition: all 0.15s ease !important;
}

.toc-sub-link:hover {
    color: #ffffff !important;
    background: rgba(59, 130, 246, 0.15) !important;
    transform: translateX(2px);
    text-decoration: none !important;
}

.toc-sub-link.active {
    color: #60a5fa !important;
    font-weight: 600 !important;
    background: rgba(59, 130, 246, 0.18) !important;
    border-left: 2px solid #60a5fa !important;
    text-decoration: none !important;
}

/* Breadcrumbs */
.wiki-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.wiki-breadcrumbs a {
    color: var(--primary-light);
    text-decoration: none;
}

.wiki-breadcrumbs a:hover {
    text-decoration: underline;
}

.wiki-breadcrumbs span.separator {
    color: var(--border);
}

/* Hero Section */
.wiki-hero {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(15, 23, 42, 0.8) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 20px;
    padding: 38px 32px;
    margin-bottom: 36px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.wiki-hero h1 {
    font-size: clamp(2.1rem, 4.5vw, 2.8rem);
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.02em;
    margin-bottom: 14px;
    line-height: 1.25;
}

.wiki-hero h1 span {
    background: linear-gradient(135deg, #93c5fd, #3b82f6, #60a5fa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.wiki-hero p {
    color: var(--text-light);
    font-size: 1.05rem;
    line-height: 1.7;
}

/* Sections & Typography */
.wiki-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 38px 34px;
    margin-bottom: 36px;
    scroll-margin-top: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.wiki-section h2 {
    font-size: 1.7rem;
    color: #ffffff;
    font-weight: 800;
    margin-bottom: 18px;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
}

.wiki-section h3 {
    font-size: 1.3rem;
    color: #93c5fd;
    font-weight: 700;
    margin: 28px 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wiki-section h4 {
    font-size: 1.1rem;
    color: #e2e8f0;
    font-weight: 600;
    margin: 20px 0 10px 0;
}

.wiki-section p {
    color: var(--text-light);
    margin-bottom: 16px;
    font-size: 1rem;
    line-height: 1.8;
}

.wiki-section ul, .wiki-section ol {
    padding-left: 26px;
    margin-bottom: 22px;
    color: var(--text-light);
}

.wiki-section li {
    margin-bottom: 10px;
    line-height: 1.75;
}

/* Code & Monospace Badges */
code {
    background: var(--code-bg);
    color: #93c5fd;
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 0.86em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    word-break: break-word;
}

pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    overflow-x: auto;
    margin: 16px 0;
}

pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: #e2e8f0;
}

/* Tables */
.wiki-table-wrap {
    overflow-x: auto;
    margin: 24px 0;
    border-radius: 12px;
    border: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: rgba(59, 130, 246, 0.4) transparent;
}

.wiki-table-wrap::-webkit-scrollbar {
    height: 6px;
}

.wiki-table-wrap::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.4);
    border-radius: 3px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    text-align: left;
}

th, td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--surface-card);
    color: #ffffff;
    font-weight: 700;
    white-space: nowrap;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Callout Banners */
.callout {
    border-radius: 14px;
    padding: 20px 24px;
    margin: 24px 0;
    border-left: 4px solid;
}

.callout.tip {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: var(--accent-green);
}

.callout.info {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--primary);
}

.callout.warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: var(--accent-amber);
}

.callout.danger {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: var(--accent-red);
}

/* Pill Badges */
.pill-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.pill-badge.green {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.pill-badge.blue {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.pill-badge.red {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Modals & Lightbox */
#lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

#lightbox-modal.active {
    display: flex;
}

#lightbox-img {
    max-width: 94vw;
    max-height: 92vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 14px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.9), 0 0 30px rgba(59, 130, 246, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: zoom-out;
    animation: lightboxZoomIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes lightboxZoomIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Stock Signal Card Anatomy Mockup */
.stock-card-mockup {
    background: linear-gradient(145deg, #0d1527, #080d1a);
    border: 1.5px solid rgba(59, 130, 246, 0.4);
    border-radius: 16px;
    padding: 18px 20px;
    margin: 22px 0;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 16px rgba(59, 130, 246, 0.15);
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 620px;
}

.stock-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.stock-card-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.stock-rank-badge {
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.4);
    color: #facc15;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
}

.stock-ticker-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.stock-company-name {
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stock-card-price-block {
    text-align: right;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stock-live-price {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
}

.stock-price-change {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #34d399;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
}

.stock-pills-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stock-pill {
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.stock-pill.signal-buy {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid #10b981;
    color: #34d399;
}

.stock-pill.pill-tt {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid #3b82f6;
    color: #93c5fd;
}

.stock-pill.pill-ai {
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid #a855f7;
    color: #d8b4fe;
}

.stock-pill.pill-backtest {
    background: rgba(245, 158, 11, 0.18);
    border: 1px solid #f59e0b;
    color: #fcd34d;
}

.stock-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 8px;
}

.stock-scan-targets {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-light);
}

.stock-scan-targets strong {
    color: #60a5fa;
}

.stock-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stock-fav-star {
    color: #facc15;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.stock-fav-star:hover {
    transform: scale(1.25);
}

#lightbox-close {
    position: absolute;
    top: max(20px, env(safe-area-inset-top, 20px));
    right: max(20px, env(safe-area-inset-right, 20px));
    background: var(--surface-card);
    border: 1px solid var(--border);
    color: #ffffff;
    font-size: 1.5rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

#lightbox-close:hover {
    background: var(--surface-card-hover);
    transform: scale(1.05);
}

#spotlight-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1500;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 5vh;
    backdrop-filter: blur(8px);
}

#spotlight-modal.active {
    display: flex;
}

.spotlight-card {
    background: #0f172a;
    border: 1.5px solid rgba(59, 130, 246, 0.45);
    border-radius: 18px;
    width: 92%;
    max-width: 680px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.85), 0 0 25px rgba(59, 130, 246, 0.25);
    overflow: hidden;
    animation: spotlightPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes spotlightPop {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.spotlight-input-wrap {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    background: rgba(17, 24, 39, 0.8);
    flex-shrink: 0;
}

.spotlight-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.1rem;
    outline: none;
    font-family: inherit;
}

.spotlight-input::placeholder {
    color: #64748b;
}

.spotlight-results {
    list-style: none;
    max-height: calc(86vh - 80px);
    min-height: 200px;
    overflow-y: auto;
    padding: 10px 14px 14px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(59, 130, 246, 0.5) rgba(15, 23, 42, 0.6);
}

.spotlight-results::-webkit-scrollbar {
    width: 6px;
}

.spotlight-results::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 4px;
}

.spotlight-results::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.45);
    border-radius: 4px;
}

.spotlight-results::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.75);
}

.spotlight-item a {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.spotlight-item a:hover {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateX(3px);
}

.spotlight-item-title {
    font-weight: 700;
    color: #60a5fa;
    font-size: 0.95rem;
    margin-bottom: 3px;
}

.spotlight-item-desc {
    font-size: 0.84rem;
    color: var(--text-muted);
    line-height: 1.4;
}

#back-to-top {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface-card);
    border: 1px solid var(--border);
    color: #60a5fa;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 90;
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

#back-to-top:hover {
    background: var(--primary);
    color: #ffffff;
    transform: translateY(-2px);
}

footer {
    border-top: 1px solid var(--border);
    padding: 30px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 40px;
}

.footer-links {
    margin-top: 8px;
}

.footer-links a {
    color: var(--text-light);
    text-decoration: none;
    margin: 0 8px;
}

/* Extended Badges */
.pill-badge.amber {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.pill-badge.purple {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.4);
}

/* Step Flow & Workflow Items */
.step-flow {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 24px 0;
}

.step-flow-item {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step-flow-item h4 {
    margin: 0;
    font-size: 1.05rem;
    color: #ffffff;
}

.step-flow-item p {
    margin: 0;
    font-size: 0.92rem;
    color: var(--text-light);
    line-height: 1.65;
}

/* Cards & Guide Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 20px;
    margin: 28px 0;
}

.guide-card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.2s, border-color 0.2s;
    text-decoration: none;
    color: inherit;
}

.guide-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary-light);
    background: var(--surface-card-hover);
}

.guide-card-icon {
    font-size: 1.8rem;
}

/* Feedback Widget */
.feedback-widget {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 24px;
    margin: 36px 0 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.feedback-question {
    font-size: 0.95rem;
    color: var(--text-light);
    font-weight: 600;
}

.feedback-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.feedback-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feedback-btn:hover {
    border-color: var(--primary-light);
    background: rgba(59, 130, 246, 0.15);
    color: #ffffff;
}

/* Bottom Chapter Pager Navigation */
.wiki-pager {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 32px 0 10px 0;
}

.wiki-pager-btn {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.wiki-pager-btn:hover {
    border-color: var(--primary);
    background: var(--surface-card-hover);
    transform: translateY(-2px);
}

.wiki-pager-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.wiki-pager-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #60a5fa;
}

.spotlight-footer {
    padding: 10px 16px;
    background: var(--surface-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Responsive Overrides for Modals and Components */
@media (max-width: 680px) {
    #spotlight-modal {
        padding-top: 16px;
        padding-left: 12px;
        padding-right: 12px;
        align-items: flex-start;
    }
    .spotlight-card {
        width: 100%;
        max-height: 90vh;
    }
    .spotlight-results {
        max-height: calc(90vh - 75px);
    }
    .wiki-section {
        padding: 24px 18px;
        border-radius: 16px;
    }
    .wiki-hero {
        padding: 24px 18px;
        border-radius: 16px;
    }
}
