/* ==============================================================================
   STROYNA & XBK ENTERPRISE — CATEGORY SALES MATRIX WIDGET
   Shaffof ("Prozrachni"), 100% Kengaytirilgan va O'ta Qulay Ixcham (Compact) Matritsa
   Faqat O'sish (%) va Farq (so'm) ko'rsatiladi. Kataklar bo'yi kichraytirilgan.
   Mishka katakka borganda to'liq batafsil ma'lumot (so'm, ulush, solishtirma) chiqadi.
   ============================================================================== */

.category-sales-section {
    width: 100%;
    max-width: 100%;
    margin-top: 0;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    z-index: 20;
    pointer-events: auto !important;
}

/* "Prozrachni" — Orqa fon butunlay shaffof, qora quti olib tashlangan */
.category-sales-card {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    position: relative;
    overflow: visible;
    width: 100%;
    pointer-events: auto !important;
}

.category-sales-card:hover {
    border: none !important;
    box-shadow: none !important;
}

.category-sales-card::before {
    display: none !important;
}

/* Header — Ixcham va chiroyli */
.cs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 6px;
    background: transparent;
    width: 100%;
    position: relative;
    z-index: 50;
    pointer-events: auto !important;
}

.cs-title-box h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.02em;
    margin: 0;
}

.cs-title-box h2 i {
    color: #38bdf8;
    font-size: 1.1rem;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.5));
}

.cs-subtitle {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Strict Compliance Badge */
.cs-rule-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.cs-rule-badge .pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* Top Action Controls */
.cs-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 55;
}

.cs-mini-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.74rem;
    font-weight: 600;
}

.cs-mini-pill strong {
    color: #38bdf8;
    font-family: 'JetBrains Mono', monospace;
}

/* Executive KPI Ribbon — Ixcham (Bo'yi past, joy tejovchi) */
.cs-kpi-ribbon {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 8px;
    width: 100%;
}

.cs-kpi-tile {
    background: rgba(255, 255, 255, 0.02) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 8px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.cs-kpi-tile:hover {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

.cs-kpi-info-box {
    display: flex;
    flex-direction: column;
}

.cs-kpi-tile-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.cs-kpi-tile-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
    margin-top: 1px;
}

.cs-kpi-tile-sub {
    font-size: 0.66rem;
    color: #64748b;
    margin-top: 1px;
}

/* MATRIX TABLE CONTAINER — 100% Full Width, Shaffof & Ixcham */
.cs-matrix-card {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    width: 100%;
}

.cs-matrix-scroll-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 189, 248, 0.35) rgba(15, 23, 42, 0.2);
}

.cs-matrix-scroll-wrapper::-webkit-scrollbar {
    height: 6px;
}
.cs-matrix-scroll-wrapper::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.2);
}
.cs-matrix-scroll-wrapper::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.35);
    border-radius: 3px;
}

.cs-matrix-table {
    width: 100%;
    min-width: 860px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.78rem;
    table-layout: fixed;
}

/* Header Columns (Tepada Oylar) — Kichik bo'yli va qat'iy ixcham */
.cs-matrix-table th {
    background: rgba(10, 16, 32, 0.6) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #94a3b8;
    font-weight: 700;
    padding: 5px 3px !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.03);
    text-align: center;
    vertical-align: middle;
}

.cs-th-month-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.cs-th-month-name {
    font-size: 0.76rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.01em;
}

.cs-th-month-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.64rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
}

.cs-th-month-badge.up {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}
.cs-th-month-badge.down {
    background: rgba(244, 63, 94, 0.15);
    color: #fb7185;
}

.cs-th-sub {
    font-size: 0.60rem;
    color: #64748b;
    font-family: 'JetBrains Mono', monospace;
}

/* Sticky First Column: Categories (Chap tomonga toifalar) */
.cs-sticky-col {
    position: sticky;
    left: 0;
    z-index: 10;
    background: rgba(8, 12, 24, 0.85) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-right: 1.5px solid rgba(255, 255, 255, 0.08) !important;
    width: 175px;
    min-width: 165px;
    max-width: 185px;
    text-align: left !important;
    padding: 3px 8px !important;
}

.cs-month-col {
    width: calc((100% - 295px) / 10);
    min-width: 68px;
}

.cs-ytd-col {
    width: 120px;
    min-width: 105px;
    background: rgba(245, 158, 11, 0.04) !important;
    border-left: 2px solid rgba(245, 158, 11, 0.25) !important;
    padding: 3px 4px !important;
}

.cs-cat-cell-content {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #f1f5f9;
    font-size: 0.76rem;
    white-space: nowrap;
}

.cs-cat-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.66rem;
    flex-shrink: 0;
}

/* Table Cells — Ixcham qilib qisqartirilgan bo'y (Height reduced to ~30-32px) */
.cs-matrix-table td {
    padding: 2.5px 3px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    border-right: 1px solid rgba(255, 255, 255, 0.02);
    vertical-align: middle;
    background: transparent;
    transition: background 0.12s ease, outline 0.12s ease;
    height: 31px;
}

.cs-matrix-table tr:hover td {
    background: rgba(255, 255, 255, 0.035) !important;
}

/* Interaktiv katak hover effekti */
td.cs-hoverable-cell {
    cursor: pointer;
    position: relative;
}

td.cs-hoverable-cell:hover {
    background: rgba(56, 189, 248, 0.15) !important;
    outline: 1.5px solid #38bdf8;
    outline-offset: -1px;
    z-index: 5;
}

/* Compact Cell Structure (Faqat O'sish % va Farq so'm) */
.cs-compact-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0px;
    text-align: center;
    width: 100%;
    min-height: 27px;
    line-height: 1.15;
}

.cs-compact-pct {
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.cs-compact-pct.up {
    color: #34d399;
}

.cs-compact-pct.down {
    color: #fb7185;
}

.cs-compact-pct.neutral {
    color: #94a3b8;
}

.cs-compact-diff {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.67rem;
    font-weight: 700;
    white-space: nowrap;
}

.cs-compact-diff.up {
    color: #10b981;
}

.cs-compact-diff.down {
    color: #f43f5e;
}

.cs-compact-diff.neutral {
    color: #64748b;
}

/* YTD Cell Structure */
.cs-ytd-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0px;
    text-align: center;
    line-height: 1.1;
}

.cs-ytd-top-row {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    font-weight: 800;
    white-space: nowrap;
}

.cs-ytd-val-26 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    font-weight: 800;
    color: #ffffff;
    white-space: nowrap;
}

.cs-ytd-val-25 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    color: #64748b;
    white-space: nowrap;
}

/* Total Row (Pastki jami qatori) — Qat'iy ixcham */
.cs-total-row td {
    background: rgba(16, 185, 129, 0.08) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 2px solid rgba(16, 185, 129, 0.3) !important;
    font-weight: 800;
    padding: 3px 3px !important;
    height: 33px;
}

.cs-total-label {
    font-size: 0.76rem;
    font-weight: 800;
    color: #34d399;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.cs-total-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0px;
    text-align: center;
    line-height: 1.15;
}

.cs-total-pct {
    font-size: 0.74rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.cs-total-diff {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.66rem;
    font-weight: 700;
}

.cs-total-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    color: #94a3b8;
}

/* ==============================================================================
   MISKHA KATAKKA BORGANDA CHIQUVCHI TO'LIQ MA'LUMOT (HOVER TOOLTIP)
   Glassmorphic, zamonaviy, to'liq so'm, o'tgan yil va o'sish sur'ati bilan
   ============================================================================== */
.cs-matrix-hover-tooltip {
    position: fixed;
    z-index: 999999;
    display: none;
    pointer-events: none;
    background: rgba(8, 14, 28, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.8), 0 0 24px rgba(56, 189, 248, 0.25);
    min-width: 250px;
    max-width: 330px;
    color: #f1f5f9;
    font-family: 'Plus Jakarta Sans', sans-serif;
    animation: csTtFadeIn 0.12s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

@keyframes csTtFadeIn {
    from { opacity: 0; transform: translateY(4px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.cs-tt-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.cs-tt-cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.80rem;
}

.cs-tt-period {
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.cs-tt-metrics {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cs-tt-metric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.75rem;
}

.cs-tt-lbl {
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.73rem;
}

.cs-tt-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}
.cs-tt-dot.c26 { background: #38bdf8; box-shadow: 0 0 6px #38bdf8; }
.cs-tt-dot.c25 { background: #fbbf24; box-shadow: 0 0 6px #fbbf24; }
.cs-tt-dot.up { background: #10b981; box-shadow: 0 0 6px #10b981; }
.cs-tt-dot.down { background: #f43f5e; box-shadow: 0 0 6px #f43f5e; }

.cs-tt-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.78rem;
    text-align: right;
    white-space: nowrap;
}

.cs-tt-val.c26 { color: #38bdf8; }
.cs-tt-val.c25 { color: #fbbf24; }
.cs-tt-val.up { color: #34d399; }
.cs-tt-val.down { color: #fb7185; }

.cs-tt-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 4px 0;
}

.cs-tt-footer {
    margin-top: 6px;
    padding-top: 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.68rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Katta monitorlarda ham katak bo'yi shishib ketmasligi uchun qat'iy compact qoidalar */
@media (min-width: 1600px) {
    .cs-matrix-table td {
        padding: 3px 4px !important;
        height: 32px !important;
    }
    .cs-matrix-table th {
        padding: 6px 4px !important;
    }
    .cs-sticky-col {
        width: 185px;
        min-width: 175px;
        max-width: 195px;
    }
}

@media (min-width: 2200px) {
    .cs-matrix-table td {
        padding: 3px 5px !important;
        height: 33px !important;
    }
    .cs-matrix-table th {
        padding: 6px 5px !important;
    }
    .cs-sticky-col {
        width: 195px;
        min-width: 185px;
        max-width: 205px;
    }
}

/* Mobile Swipe Hint Banner */
.cs-mobile-swipe-hint {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 0.70rem;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.08);
    border: 1px dashed rgba(56, 189, 248, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-weight: 600;
}

@media (max-width: 1024px) {
    .cs-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .cs-kpi-ribbon {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }
    .cs-kpi-tile {
        padding: 6px 10px !important;
    }
    .cs-kpi-tile-val {
        font-size: 1.05rem !important;
    }
}

@media (max-width: 768px) {
    .cs-mobile-swipe-hint {
        display: inline-flex !important;
    }
    .cs-sticky-col {
        width: 135px !important;
        min-width: 130px !important;
        max-width: 140px !important;
        padding: 3px 6px !important;
    }
    .cs-cat-cell-content {
        font-size: 0.72rem !important;
        gap: 5px !important;
    }
    .cs-month-col {
        min-width: 66px !important;
    }
    .cs-ytd-col {
        min-width: 100px !important;
    }
}
