/* =========================================================
   CVAM Candle Chart v8.1
   ========================================================= */
.cvam-chart-app {
    font-family: 'IRANSansWeb', 'Tahoma', 'Segoe UI', sans-serif;
    direction: rtl;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.cvam-chart-app * { box-sizing: border-box; }

.cvam-chart-widget {
    background: linear-gradient(145deg, #f8faff 0%, #ffffff 100%);
    border-radius: 2rem;
    padding: 1.5rem;
    box-shadow: 0 25px 45px -12px rgba(0, 0, 0, 0.22),
                0 0 0 1px rgba(123, 104, 238, 0.1);
    position: relative;
    overflow: hidden;
}
.cvam-chart-widget::before {
    content: "";
    position: absolute;
    top: -120px; right: -120px;
    width: 280px; height: 280px;
    background: radial-gradient(circle, rgba(176, 38, 255, 0.14), transparent 70%);
    pointer-events: none;
    border-radius: 50%;
}
.cvam-chart-widget::after {
    content: "";
    position: absolute;
    bottom: -100px; left: -100px;
    width: 240px; height: 240px;
    background: radial-gradient(circle, rgba(123, 104, 238, 0.12), transparent 70%);
    pointer-events: none;
    border-radius: 50%;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
    position: relative;
    z-index: 2;
    flex-wrap: wrap;
}
.chart-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.chart-title .icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    background: linear-gradient(135deg, #B026FF, #7B68EE);
    color: #fff;
    font-size: 1.3rem;
    box-shadow: 0 8px 20px rgba(176, 38, 255, 0.35);
    flex-shrink: 0;
}
.chart-title h3 {
    font-size: 1.15rem;
    font-weight: 800;
    background: linear-gradient(135deg, #B026FF, #7B68EE);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.3;
    margin: 0 0 0.1rem;
}
.chart-title p {
    font-size: 0.72rem;
    color: #6c6f78;
    margin: 0;
}

.chart-badges {
    display: flex;
    gap: 0.6rem;
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chart-countdown {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.5rem 0.9rem;
    background: linear-gradient(135deg, rgba(176,38,255,0.1), rgba(123,104,238,0.08));
    border: 1px solid rgba(176, 38, 255, 0.25);
    border-radius: 1rem;
    backdrop-filter: blur(10px);
    min-width: 130px;
    position: relative;
    overflow: hidden;
}
.chart-countdown::before {
    content: "";
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: countdownShine 3s ease-in-out infinite;
    pointer-events: none;
}
@keyframes countdownShine {
    0%   { left: -100%; }
    50%  { left: 100%; }
    100% { left: 100%; }
}
.chart-countdown .cd-label {
    font-size: 0.62rem;
    color: #5b2c8e;
    font-weight: 700;
    white-space: nowrap;
}
.chart-countdown .cd-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: #B026FF;
    direction: ltr;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(176, 38, 255, 0.3);
    line-height: 1.1;
}
.chart-countdown.urgent .cd-value {
    color: #e0356a;
    text-shadow: 0 0 12px rgba(224, 53, 106, 0.4);
    animation: pulseUrgent 1s ease-in-out infinite;
}
@keyframes pulseUrgent {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}

.chart-price-badge {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
    padding: 0.5rem 0.9rem;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(123, 104, 238, 0.2);
    border-radius: 1rem;
    backdrop-filter: blur(10px);
}
.chart-price-badge .price {
    font-size: 1.05rem;
    font-weight: 800;
    color: #1e1e2f;
}
.chart-price-badge .price small {
    font-size: 0.65rem;
    color: #7B68EE;
    font-weight: 600;
}
.chart-price-badge .change {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    border-radius: 2rem;
}
.chart-price-badge .change.up {
    color: #00a878;
    background: rgba(0, 200, 150, 0.12);
}
.chart-price-badge .change.down {
    color: #e0356a;
    background: rgba(255, 77, 109, 0.12);
}
.chart-price-badge .current-price {
    font-size: 0.68rem;
    font-weight: 600;
    color: #5b2c8e;
    background: linear-gradient(135deg, rgba(176,38,255,0.1), rgba(123,104,238,0.08));
    padding: 0.15rem 0.55rem;
    border-radius: 2rem;
    border: 1px solid rgba(176, 38, 255, 0.2);
    white-space: nowrap;
}
.chart-price-badge .current-price strong {
    color: #B026FF;
    font-weight: 800;
    direction: ltr;
    display: inline-block;
}

.chart-bank-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.15rem 0.15rem 0.5rem;
    margin-bottom: 0.6rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(176,38,255,0.4) transparent;
    position: relative;
    z-index: 2;
}
.chart-bank-tabs::-webkit-scrollbar { height: 4px; }
.chart-bank-tabs::-webkit-scrollbar-thumb {
    background: rgba(176,38,255,0.4);
    border-radius: 10px;
}
.bank-tab {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    border: 1.5px solid rgba(123, 104, 238, 0.25);
    background: rgba(255, 255, 255, 0.6);
    color: #5b2c8e;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    touch-action: manipulation;
}
.bank-tab:hover {
    background: rgba(176, 38, 255, 0.08);
    border-color: rgba(176, 38, 255, 0.45);
    transform: translateY(-1px);
}
.bank-tab.active {
    background: linear-gradient(135deg, #B026FF, #7B68EE);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 18px rgba(176, 38, 255, 0.4);
}

.chart-months-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
    padding: 0.5rem 0.7rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(123, 104, 238, 0.15);
    border-radius: 1rem;
}
.months-label {
    font-size: 0.72rem;
    color: #5b2c8e;
    font-weight: 700;
    white-space: nowrap;
}
.chart-months {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    flex: 1;
}
.month-btn {
    padding: 0.35rem 0.8rem;
    border-radius: 2rem;
    border: 1.2px solid rgba(123, 104, 238, 0.3);
    background: rgba(255, 255, 255, 0.7);
    color: #5b2c8e;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    touch-action: manipulation;
    white-space: nowrap;
}
.month-btn:hover {
    border-color: rgba(176, 38, 255, 0.6);
    background: rgba(176, 38, 255, 0.08);
    transform: translateY(-1px);
}
.month-btn.active {
    background: linear-gradient(135deg, #B026FF, #7B68EE);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(176, 38, 255, 0.4);
}

.chart-type-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
    padding: 0.5rem 0.7rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(123, 104, 238, 0.15);
    border-radius: 1rem;
}
.chart-types {
    display: flex;
    gap: 0.35rem;
}
.type-btn {
    padding: 0.35rem 0.8rem;
    border-radius: 2rem;
    border: 1.2px solid rgba(123, 104, 238, 0.3);
    background: rgba(255, 255, 255, 0.7);
    color: #5b2c8e;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    touch-action: manipulation;
}
.type-btn:hover {
    border-color: rgba(176, 38, 255, 0.6);
    background: rgba(176, 38, 255, 0.08);
}
.type-btn.active {
    background: linear-gradient(135deg, #B026FF, #7B68EE);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(176, 38, 255, 0.4);
}
.type-btn.disabled,
.type-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(200, 200, 210, 0.3);
    border-style: dashed;
    color: #8a8aa0;
    box-shadow: none;
    transform: none;
}

.chart-ranges {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 2;
    flex-wrap: wrap;
}
.range-btn {
    padding: 0.35rem 0.85rem;
    border-radius: 2rem;
    border: 1.2px solid rgba(123, 104, 238, 0.25);
    background: rgba(255, 255, 255, 0.55);
    color: #5b2c8e;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    touch-action: manipulation;
}
.range-btn:hover {
    border-color: rgba(176, 38, 255, 0.5);
    background: rgba(176, 38, 255, 0.06);
}
.range-btn.active {
    background: linear-gradient(135deg, #B026FF, #7B68EE);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(176, 38, 255, 0.35);
}

.chart-ohlc {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin-bottom: 0.8rem;
    position: relative;
    z-index: 2;
}
.ohlc-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.7rem;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(123, 104, 238, 0.15);
    border-radius: 0.9rem;
    backdrop-filter: blur(8px);
}
.ohlc-item .lbl {
    font-size: 0.65rem;
    color: #7B68EE;
    font-weight: 700;
}
.ohlc-item .val {
    font-size: 0.85rem;
    font-weight: 800;
    color: #1e1e2f;
    direction: ltr;
    text-align: right;
}
.ohlc-item.o .val { color: #7B68EE; }
.ohlc-item.h .val { color: #00a878; }
.ohlc-item.l .val { color: #e0356a; }
.ohlc-item.c .val { color: #B026FF; }

.chart-offers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 2;
}
.offers-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    background: linear-gradient(135deg, rgba(176,38,255,0.06), rgba(123,104,238,0.05));
    border: 1px solid rgba(176, 38, 255, 0.18);
    border-radius: 1rem;
    backdrop-filter: blur(8px);
}
.offers-item .oi-lbl {
    font-size: 0.72rem;
    color: #5b2c8e;
    font-weight: 700;
}
.offers-item .oi-val {
    font-size: 0.82rem;
    font-weight: 800;
    color: #B026FF;
    direction: ltr;
}

.chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 420px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(123, 104, 238, 0.18);
    border-radius: 1.2rem;
    padding: 0.5rem;
    box-shadow: inset 0 0 30px rgba(123, 104, 238, 0.04);
    z-index: 2;
    overflow: hidden;
}
#candleChart,
#lineChart {
    width: 100%;
    height: 100%;
    border-radius: 0.9rem;
    direction: ltr;
}

.chart-empty, .line-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-align: center;
    color: #7B68EE;
    pointer-events: none;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 0.9rem;
    z-index: 5;
}
.chart-empty span, .line-empty span { font-size: 2rem; }
.chart-empty p, .line-empty p {
    font-size: 0.85rem;
    font-weight: 700;
    margin: 0;
}
.chart-empty small, .line-empty small {
    font-size: 0.7rem;
    color: #a9a9c9;
}

.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(30, 30, 47, 0.95);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.7rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.15s ease;
    direction: rtl;
    white-space: nowrap;
    z-index: 10;
    border: 1px solid rgba(176, 38, 255, 0.35);
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tt-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.15rem 0;
}
.chart-tooltip .tt-row .k { color: #b8b8d0; }
.chart-tooltip .tt-row .v {
    font-weight: 700;
    direction: ltr;
}
.chart-tooltip .tt-date {
    border-bottom: 1px solid rgba(255,255,255,0.12);
    padding-bottom: 0.3rem;
    margin-bottom: 0.3rem;
    color: #B026FF;
    font-weight: 800;
    text-align: center;
}
.chart-tooltip .up { color: #34e6b8; }
.chart-tooltip .down { color: #ff7a9b; }

.chart-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.9rem;
    position: relative;
    z-index: 2;
    gap: 1rem;
    flex-wrap: wrap;
}
.chart-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.7rem;
    color: #6c6f78;
}
.chart-legend .lg {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.chart-legend .dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}
.chart-legend .dot.up { background: #00c896; }
.chart-legend .dot.down { background: #ff4d6d; }
.chart-legend .dot.vol { background: linear-gradient(135deg, #7B68EE, #B026FF); }
.chart-note {
    font-size: 0.68rem;
    color: #a9a9c9;
    background: rgba(123, 104, 238, 0.08);
    padding: 0.25rem 0.7rem;
    border-radius: 2rem;
}

.tv-attribution {
    margin-top: 0.6rem;
    font-size: 0.65rem;
    color: #a9a9c9;
    text-align: left;
    direction: ltr;
    position: relative;
    z-index: 2;
}
.tv-attribution a {
    color: #7B68EE;
    text-decoration: none;
    font-weight: 700;
}
.tv-attribution a:hover {
    color: #B026FF;
    text-decoration: underline;
}

.line-widget .line-bank-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    position: relative;
    z-index: 2;
}
.bank-check {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem 0.4rem 0.6rem;
    border-radius: 2rem;
    border: 1.4px solid rgba(123, 104, 238, 0.25);
    background: rgba(255, 255, 255, 0.6);
    color: #5b2c8e;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
    touch-action: manipulation;
}
.bank-check:hover {
    border-color: rgba(176, 38, 255, 0.5);
    background: rgba(176, 38, 255, 0.06);
}
.bank-check input { display: none; }
.bank-check .box {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    border: 1.6px solid rgba(123, 104, 238, 0.5);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #fff;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.bank-check .box::after {
    content: "✓";
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.2s;
}
.bank-check.checked {
    background: linear-gradient(135deg, rgba(176,38,255,0.12), rgba(123,104,238,0.08));
    border-color: rgba(176, 38, 255, 0.55);
    color: #B026FF;
}
.bank-check.checked .box {
    background: linear-gradient(135deg, #B026FF, #7B68EE);
    border-color: transparent;
}
.bank-check.checked .box::after {
    opacity: 1;
    transform: scale(1);
}
.bank-check .clr-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 0.15rem;
    border: 1.5px solid rgba(255,255,255,0.7);
    box-shadow: 0 0 4px rgba(0,0,0,0.1);
}

.line-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem 1.2rem;
    margin-top: 0.9rem;
    position: relative;
    z-index: 2;
    font-size: 0.75rem;
}
.line-legend .lg-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #2d2f3e;
    font-weight: 700;
}
.line-legend .lg-line {
    width: 22px;
    height: 3px;
    border-radius: 2px;
    display: inline-block;
}
.line-legend .lg-val {
    color: #7B68EE;
    font-size: 0.7rem;
    direction: ltr;
}

.loading-inline {
    font-size: 0.75rem;
    color: #7B68EE;
    padding: 0.5rem 0.8rem;
    display: inline-block;
    background: rgba(123,104,238,0.08);
    border-radius: 2rem;
}

@media (max-width: 640px) {
    .cvam-chart-widget {
        padding: 1rem;
        border-radius: 1.5rem;
    }
    .chart-header { gap: 0.6rem; }
    .chart-title h3 { font-size: 1rem; }
    .chart-title p { font-size: 0.68rem; }
    .chart-title .icon {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }
    .chart-badges { gap: 0.4rem; width: 100%; }
    .chart-countdown {
        padding: 0.35rem 0.6rem;
        min-width: 100px;
    }
    .chart-countdown .cd-label { font-size: 0.55rem; }
    .chart-countdown .cd-value { font-size: 0.95rem; }
    .chart-price-badge { padding: 0.4rem 0.7rem; }
    .chart-price-badge .price { font-size: 0.9rem; }
    .chart-price-badge .change { font-size: 0.65rem; }
    .chart-price-badge .current-price { font-size: 0.62rem; }
    .chart-canvas-wrap { height: 320px; }
    .chart-ohlc {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }
    .ohlc-item {
        padding: 0.35rem 0.5rem;
        border-radius: 0.7rem;
    }
    .ohlc-item .lbl { font-size: 0.6rem; }
    .ohlc-item .val { font-size: 0.75rem; }
    .bank-tab {
        padding: 0.4rem 0.8rem;
        font-size: 0.72rem;
    }
    .chart-offers { grid-template-columns: 1fr; }
    .offers-item { padding: 0.45rem 0.7rem; }
    .offers-item .oi-lbl { font-size: 0.68rem; }
    .offers-item .oi-val { font-size: 0.78rem; }
    .chart-months-wrap,
    .chart-type-wrap {
        padding: 0.4rem 0.55rem;
        gap: 0.4rem;
    }
    .months-label { font-size: 0.68rem; }
    .month-btn,
    .type-btn {
        padding: 0.3rem 0.65rem;
        font-size: 0.68rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cvam-chart-app * {
        transition: none !important;
        animation: none !important;
    }
}