/**
 * BCI ZEN FINTECH - SIGNATURE REDESIGN (v7.1 FINAL)
 * Concept: "Zen Dashboard" - Minimalism, whitespace, 2px borders, 12px radius.
 */

:root {
    --zen-bg: var(--site-background, #f9fafb);
    --zen-surface: var(--card-white, #ffffff);
    --zen-border: var(--border-light, #e5e7eb);
    --zen-text-main: var(--headings, #111827);
    --zen-text-body: var(--texts, #374151);
    --zen-text-muted: var(--text-muted, #6b7280);
    --zen-primary: #2563eb;
    --zen-primary-soft: rgba(37, 99, 235, 0.05);
    --zen-radius: 12px;
    --zen-bw: 1.5px;
    --zen-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.02);
}

[data-theme='dark'], .dark-mode {
    --zen-bg: #0b0f15;
    --zen-surface: #141a23;
    --zen-border: rgba(255, 255, 255, 0.06);
    --zen-text-main: #f3f4f6;
    --zen-text-body: #d1d5db;
}

.bci-zen-root {
    font-family: 'iransansx', system-ui, -apple-system, sans-serif;
    direction: rtl;
    background: var(--zen-bg);
    color: var(--zen-text-body);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
    width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.bci-zen-root *, .bci-zen-root *::before, .bci-zen-root *::after {
    box-sizing: border-box;
}

.bci-zen-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* --- COMPONENTS --- */
.zen-card {
    background: var(--zen-surface);
    border: var(--zen-bw) solid var(--zen-border);
    border-radius: var(--zen-radius);
    padding: 24px;
    box-shadow: var(--zen-shadow);
}

.zen-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: var(--zen-bw) solid transparent;
}
.zen-btn-primary { background: var(--zen-text-main); color: var(--zen-surface); }
.zen-btn-primary:hover { background: var(--zen-primary); transform: translateY(-1px); }

.zen-btn-outline { background: transparent; border-color: var(--zen-border); color: var(--zen-text-main); }
.zen-btn-outline:hover { border-color: var(--zen-primary); color: var(--zen-primary); background: var(--zen-primary-soft); }

/* --- INDEX LAYOUT --- */
.zen-index-header { text-align: center; padding: 60px 0; }
.zen-page-title { font-size: 2.4rem; font-weight: 950; color: var(--zen-text-main); margin-bottom: 12px; letter-spacing: -0.02em; }
.zen-page-subtitle { font-size: 1.1rem; color: var(--zen-text-muted); font-weight: 600; }

.zen-grid { display: grid; grid-template-columns: 340px 1fr; gap: 40px; align-items: flex-start; }

.zen-sidebar-card { background: var(--zen-surface); border: var(--zen-bw) solid var(--zen-border); border-radius: var(--zen-radius); padding: 24px; margin-bottom: 24px; }
.zen-card-header { font-weight: 800; color: var(--zen-text-main); margin-bottom: 24px; padding-bottom: 12px; border-bottom: var(--zen-bw) solid var(--zen-border); }

.zen-form-group { margin-bottom: 20px; }
.zen-label { display: block; font-size: 1.3rem; font-weight: 700; color: var(--zen-text-muted); margin-bottom: 8px; }
.zen-input, .zen-select { width: 100%; padding: 12px; border: var(--zen-bw) solid var(--zen-border); border-radius: 10px; background: var(--zen-bg); color: var(--zen-text-main); font-weight: 600; font-size:1.2rem; }
.zen-input:focus { border-color: var(--zen-primary); outline: none; }

.zen-report-item {
    background: var(--zen-surface); border: var(--zen-bw) solid var(--zen-border);
    border-radius: 12px; padding: 24px; margin-bottom: 20px;
    display: flex; justify-content: space-between; align-items: center;
    transition: all 0.25s ease;
}
.zen-report-item:hover { transform: translateX(-6px); border-color: var(--zen-primary); }
.zen-report-main h4 { font-size: 1.3rem; font-weight: 800; color: var(--zen-text-main); margin: 6px 0 3px 3px; }
.zen-report-symbol { font-weight: 900; color: var(--zen-primary); font-size: 1.1rem; }
.zen-report-meta { display: flex; gap: 16px; font-size: 0.95rem; color: var(--zen-text-muted); font-weight: 600; flex-wrap: wrap; }

/* --- SINGLE REPORT LAYOUT --- */
.zen-top-nav { background: var(--zen-surface); border-bottom: var(--zen-bw) solid var(--zen-border); padding: 12px 0; margin-bottom: 40px; }
.zen-nav-meta { font-size: 0.8rem; font-weight: 800; color: var(--zen-text-muted); font-family: monospace; }
.zen-flex-between { display: flex; justify-content: space-between; align-items: center; }
.zen-back-link { text-decoration: none; color: var(--zen-text-muted); font-weight: 700; display: flex; align-items: center; gap: 8px; }

.zen-single-header { margin-bottom: 48px; }
.zen-symbol-tag { background: var(--zen-text-main); color: #fff; padding: 4px 14px; border-radius: 6px; font-weight: 900; }
.zen-company-full { font-weight: 700; color: var(--zen-text-muted); margin-right: 15px; }
.zen-report-title { font-size: clamp(1.5rem, 5vw, 2.6rem); font-weight: 950; color: var(--zen-text-main); margin: 20px 0; line-height: 1.2; letter-spacing: -0.03em; }
.zen-meta-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 15px; color: var(--zen-text-muted); font-weight: 600; }
.zen-meta-sep { width: 4px; height: 4px; background: var(--zen-border); border-radius: 50%; }

.zen-dashboard-grid { 
    display: grid; 
    grid-template-columns: 1fr 340px; 
    gap: 48px;
    grid-template-areas: 
        "main sidebar"
        "chat chat";
}

.zen-content-area { grid-area: main; }
.zen-sidebar-area { grid-area: sidebar; }
.zen-chat-embed { grid-area: chat; width: 100%; margin-top: 40px; }

.zen-summary-text { font-size: 1.2rem; line-height: 2; text-align: justify; color: var(--zen-text-body); }
.zen-request-box { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 20px; }
.zen-quota-hint { font-size: 0.8rem; font-weight: 700; color: var(--zen-text-muted); }

.zen-section-title { font-size: 1.4rem; font-weight: 800; color: var(--zen-text-main); margin: 40px 0 24px; border-right: 5px solid var(--zen-primary); padding-right: 15px; }
.zen-keypoints-grid ul { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; list-style: none; padding: 0; }
.zen-keypoints-grid li { background: var(--zen-surface); border: var(--zen-bw) solid var(--zen-border); padding: 24px; border-radius: var(--zen-radius); font-weight: 700; color: var(--zen-text-main); }

/* --- SIDEBAR REFINEMENTS --- */
.zen-sidebar-main-card { padding: 30px; }
.zen-sidebar-label { font-size: 0.8rem; font-weight: 800; color: var(--zen-text-muted); margin-bottom: 15px; text-transform: uppercase; letter-spacing: 1px; }
.zen-sidebar-divider { height: 1px; background: var(--zen-border); margin: 25px 0; }

.zen-sent-box { padding: 20px; border-radius: 12px; border: var(--zen-bw) solid var(--zen-border); text-align: center; }
.zen-sent-val { font-size: 1.6rem; font-weight: 950; margin-bottom: 5px; }
.zen-sent-conf { font-size: 0.85rem; font-weight: 700; opacity: 0.8; }

.zen-sent-positive { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.zen-sent-negative { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.zen-sent-neutral, .zen-sent-pending { background: var(--zen-bg); color: var(--zen-text-body); }

.zen-action-list { display: flex; flex-direction: column; gap: 10px; }
.zen-action-item { 
    text-decoration: none; padding: 12px 18px; border-radius: 10px; 
    border: var(--zen-bw) solid var(--zen-border); color: var(--zen-text-main);
    font-weight: 700; font-size: 0.9rem; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; cursor: pointer; background: transparent;
}
.zen-action-item:hover { background: var(--zen-bg); border-color: var(--zen-primary); color: var(--zen-primary); }
.zen-action-item.primary { background: var(--zen-text-main); color: #fff; border-color: var(--zen-text-main); }

.zen-tech-list { display: flex; flex-direction: column; gap: 12px; }
.zen-tech-item { display: flex; justify-content: space-between; font-size: 0.9rem; }
.zen-tech-item .label { color: var(--zen-text-muted); }
.zen-tech-item .value { font-weight: 800; color: var(--zen-text-main); }

.zen-rel-item { display: block; text-decoration: none; padding: 16px; border-radius: 10px; transition: all 0.2s; }
.zen-rel-item:hover { background: var(--zen-bg); }
.rel-symbol { display: block; font-size: 0.8rem; font-weight: 800; color: var(--zen-primary); margin-bottom: 4px; }
.rel-title { font-size: 0.95rem; font-weight: 700; color: var(--zen-text-main); line-height: 1.4; }

/* SENTIMENT WIDGET */
.bci-sentiment-widget { background: var(--zen-surface); border: var(--zen-bw) solid var(--zen-border); border-radius: 12px; padding: 24px; margin-top: 24px; }
.bci-sentiment-header h3 { font-size: 1.1rem; font-weight: 900; margin-bottom: 5px; }
.bci-sentiment-header p { font-size: 0.8rem; color: var(--zen-text-muted); margin-bottom: 20px; }
.bci-sentiment-meter { height: 8px; background: var(--zen-bg); border-radius: 100px; display: flex; overflow: hidden; margin-bottom: 20px; }
.bci-meter-fill { height: 100%; transition: width 0.5s ease; }
.bci-meter-fill.positive { background: #10b981; }
.bci-meter-fill.neutral { background: var(--zen-text-muted); }
.bci-meter-fill.negative { background: #ef4444; }
.bci-sentiment-labels { display: flex; justify-content: space-between; margin-bottom: 15px; }
.bci-label { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; font-weight: 700; }
.bci-label .dot { width: 6px; height: 6px; border-radius: 50%; }
.bci-label.pos .dot { background: #10b981; }
.bci-label.neu .dot { background: var(--zen-text-muted); }
.bci-label.neg .dot { background: #ef4444; }
.bci-sentiment-footer { font-size: 0.7rem; color: var(--zen-text-muted); text-align: center; border-top: 1px solid var(--zen-border); padding-top: 12px; }

/* ZEN PAGINATION */
.zen-pagination { display: flex; justify-content: center; gap: 8px; margin-top: 50px; flex-wrap: wrap; }
.zen-pagination a { 
    padding: 8px 16px; border-radius: 8px; border: var(--zen-bw) solid var(--zen-border); 
    text-decoration: none; color: var(--zen-text-main); font-weight: 800; font-size: 0.9rem;
}
.zen-pagination a.active { background: var(--zen-text-main); color: #fff; border-color: var(--zen-text-main); }

/* --- MODALS --- */
.zen-modal-root { position: fixed; inset: 0; z-index: 99999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.zen-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(8px); }
.zen-modal-container { position: relative; width: 100%; max-width: 600px; z-index: 1; }
.zen-modal-card { background: var(--zen-surface); border-radius: 16px; padding: 40px; border: var(--zen-bw) solid var(--zen-border); width: 100%; }
.zen-modal-card.wide { max-width: 900px; }
.zen-poster-frame { max-width: 100%; overflow-x: auto; margin-bottom: 24px; border-radius: 12px; }
.zen-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.zen-modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--zen-text-muted); }

/* --- SPARKLINE --- */
.bci-sparkline { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; margin-right: 8px; }
.bci-spark-bar { width: 3px; border-radius: 1px; }
.bci-spark-bar.positive { background: #10b981; height: 100%; }
.bci-spark-bar.neutral { background: var(--zen-text-muted); height: 60%; }
.bci-spark-bar.negative { background: #ef4444; height: 40%; }

/* --- TOAST --- */
.zen-toast {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px);
    background: var(--zen-text-main); color: var(--zen-surface);
    padding: 12px 24px; border-radius: 100px; font-weight: 700;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100001; opacity: 0;
}
.zen-toast.active { transform: translateX(-50%) translateY(0); opacity: 1; }

/* MOBILE RESPONSIVENESS */
@media (max-width: 900px) {
    .zen-grid { grid-template-columns: 1fr; }
    .zen-dashboard-grid { 
        display: flex; 
        flex-direction: column; 
        gap: 30px; 
    /* --- Fix single-report mobile overflow (add inside @media (max-width: 900px)) --- */

/* Force all media & block elements to respect container width */
.bci-zen-root img,
.bci-zen-root iframe,
.bci-zen-root video,
.bci-zen-root table,
.bci-zen-root pre,
.bci-zen-root code {
    max-width: 100%;
    height: auto;
}

/* Tables that would break layout become horizontally scrollable */
.bci-zen-root table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

/* Prevent long unbroken strings (URLs, monospace IDs) from pushing the viewport */
.bci-zen-root {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Ensure grid/flex children can shrink below their content size */
.zen-dashboard-grid > *,
.zen-grid > * {
    min-width: 0;
    width: 100%;
}

/* Extra safety for the content areas */
.zen-content-area,
.zen-sidebar-area,
.zen-chat-embed {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Modal wide version shouldn’t exceed viewport on small screens */
.zen-modal-card.wide {
    max-width: 100%;
}

/* Container itself must clip any overflow */
.bci-zen-container {
    overflow-x: hidden;
}
    }
    .zen-content-area { order: 1; }
    .zen-sidebar-area { order: 2; }
    .zen-chat-embed { order: 3; margin-top: 20px; }

    .zen-index-header { padding: 40px 0; }
    .zen-page-title { font-size: 1.8rem; }
    .bci-zen-container { padding: 0 16px; }
    .zen-sidebar-card { padding: 20px; }
    .zen-report-item { flex-direction: column; align-items: flex-start; gap: 20px; }
    .zen-report-actions { width: 100%; display: flex; flex-direction: column; gap: 10px; }
    .zen-report-actions .zen-btn { width: 100%; margin-left: 0 !important; }
    .zen-top-nav .bci-zen-container { flex-direction: column; gap: 15px; }
    .zen-top-nav .zen-nav-meta { display: none; }
    .zen-single-header { margin-bottom: 30px; }
    .zen-meta-strip { font-size: 0.8rem; }
    .zen-summary-text { font-size: 1.1rem; }
    .zen-keypoints-grid ul { grid-template-columns: 1fr; }
    .zen-sidebar-main-card { padding: 20px; }
}



/* Anchor the dropdown inside the search wrapper */
.bci-zen-root .zen-search-wrapper {
    position: relative !important;
}

/* The dropdown itself – forced to never exceed the viewport */
.bci-zen-root .zen-dropdown {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 9999 !important;

    /* Visual design (matches your cards) */
    background: var(--zen-surface) !important;
    border: var(--zen-bw) solid var(--zen-border) !important;
    border-radius: var(--zen-radius) !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08) !important;

    /* Critical: force width & overflow to never cause horizontal scroll */
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;          /* allow shrinking */
    box-sizing: border-box !important;

    /* Scroll vertically, never horizontally */
    max-height: 280px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;   /* absolutely no horizontal overflow */
    -webkit-overflow-scrolling: touch !important;

    /* Smooth hide/show */
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(-4px) !important;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s !important;

    /* Text */
    text-align: right !important;
    font-weight: 600 !important;
    padding: 8px !important;
    margin: 0 !important;
}

/* Visible state (add 'active' class via JS) */
.bci-zen-root .zen-dropdown.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* Dropdown items */
.bci-zen-root .zen-dropdown-item {
    display: block !important;
    padding: 10px 16px !important;
    margin: 2px 0 !important;
    border-radius: 10px !important;
    color: var(--zen-text-main) !important;
    text-decoration: none !important;
    transition: background 0.2s !important;
    cursor: pointer !important;
    word-break: break-word !important;
    white-space: normal !important;   /* prevent long strings from overflowing */
    line-height: 1.5 !important;
    box-sizing: border-box !important;
}

.bci-zen-root .zen-dropdown-item:hover,
.bci-zen-root .zen-dropdown-item:focus-visible {
    background: var(--zen-primary-soft) !important;
    color: var(--zen-primary) !important;
    outline: none !important;
}

/* Empty state */
.bci-zen-root .zen-dropdown-empty {
    padding: 12px !important;
    text-align: center !important;
    color: var(--zen-text-muted) !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
}

/* Extra safety: never let the parent root cause overflow */
.bci-zen-root {
    overflow-x: hidden !important;
}

/* Company name inside dropdown – smaller & lighter */
.bci-zen-root .zen-dropdown-item .zen-item-company {
    font-size: 1rem !important;
    font-weight: 500 !important;
    color: var(--zen-text-muted) !important;
    opacity: 0.75 !important;
    margin-right: 8px !important;  /* RTL-friendly gap */
}