/* --- Trigger Button --- */
.gk-chart-trigger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    line-height: 1;
    position: relative; /* مهم برای تولتیپ */
}

/* --- Tooltip (کپی شده از ویجت قبلی) --- */
.gk-tooltip-container {
    --gk-tooltip-bg: #333; /* پیش‌فرض */
}

.gk-tooltip-container[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    background: var(--gk-tooltip-bg);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 1;
    visibility: visible;
    z-index: 100;
    pointer-events: none;
    line-height: 1.4;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.gk-tooltip-container[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    border: 6px solid transparent;
    z-index: 100;
    pointer-events: none;
}

/* Tooltip Positions */
.gk-tooltip-container[data-tooltip-pos="top"]:hover::after { bottom: 100%; left: 50%; transform: translateX(-50%) translateY(-10px); }
.gk-tooltip-container[data-tooltip-pos="top"]:hover::before { bottom: 100%; left: 50%; transform: translateX(-50%) translateY(-4px); border-top-color: var(--gk-tooltip-bg); }

.gk-tooltip-container[data-tooltip-pos="bottom"]:hover::after { top: 100%; left: 50%; transform: translateX(-50%) translateY(10px); }
.gk-tooltip-container[data-tooltip-pos="bottom"]:hover::before { top: 100%; left: 50%; transform: translateX(-50%) translateY(4px); border-bottom-color: var(--gk-tooltip-bg); }

.gk-tooltip-container[data-tooltip-pos="right"]:hover::after { top: 50%; left: 100%; transform: translateY(-50%) translateX(10px); }
.gk-tooltip-container[data-tooltip-pos="right"]:hover::before { top: 50%; left: 100%; transform: translateY(-50%) translateX(4px); border-right-color: var(--gk-tooltip-bg); }

.gk-tooltip-container[data-tooltip-pos="left"]:hover::after { top: 50%; right: 100%; transform: translateY(-50%) translateX(-10px); }
.gk-tooltip-container[data-tooltip-pos="left"]:hover::before { top: 50%; right: 100%; transform: translateY(-50%) translateX(-4px); border-left-color: var(--gk-tooltip-bg); }


/* --- Modal Overlay --- */
.gk-chart-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gk-chart-modal-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    transition: all 0.3s;
    cursor: pointer;
}

/* --- Modal Dialog --- */
.gk-chart-modal-dialog {
    position: relative;
    background: #fff;
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 100000;
}

/* --- Modal Header --- */
.gk-chart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.gk-chart-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.gk-chart-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gk-chart-modal-close:hover {
    color: #333;
}

/* --- Modal Body --- */
.gk-chart-modal-body {
    padding: 20px;
    min-height: 200px;
}

/* --- Loader --- */
.gk-chart-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    width: 100%;
}

.gk-chart-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #eee;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: gkSpin 1s linear infinite;
}

@keyframes gkSpin {
    to { transform: rotate(360deg); }
}

/* --- Elementor Editor Fix --- */
.elementor-editor-active .gk-chart-modal {
    position: absolute;
    z-index: 1000;
    height: auto;
    min-height: 400px;
    background: rgba(0,0,0,0.05);
}

/* 1.9.145 — unified price history UI */
.gk-price-history-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 0 0 12px;
}
.gk-price-history-ranges {
    display: inline-flex;
    gap: 4px;
    padding: 3px;
    border: 1px solid #eceff3;
    border-radius: 10px;
    background: #f7f8fa;
}
.gk-price-history-ranges button {
    min-height: 30px;
    padding: 4px 9px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #697386;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.gk-price-history-ranges button:hover { color: #243044; background: rgba(255,255,255,.72); }
.gk-price-history-ranges button.is-active {
    color: var(--gk-primary, #ed1944);
    background: #fff;
    box-shadow: 0 1px 3px rgba(15,23,42,.07);
}
.gk-price-history-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 8px;
    margin: 0 0 12px;
}
.gk-price-history-summary[hidden] { display: none !important; }
.gk-price-history-summary > div {
    min-width: 0;
    padding: 10px 11px;
    border: 1px solid #edf0f3;
    border-radius: 10px;
    background: #fbfcfd;
}
.gk-price-history-summary span,
.gk-price-history-summary strong { display: block; }
.gk-price-history-summary span { margin-bottom: 4px; color: #8a93a2; font-size: 10px; font-weight: 600; }
.gk-price-history-summary strong { overflow: hidden; color: #252d39; font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.gk-price-history-summary strong.is-up { color: #b42318; }
.gk-price-history-summary strong.is-down { color: #14804a; }
.gk-price-history-notice {
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid #edf0f3;
    border-radius: 9px;
    color: #667085;
    background: #fafbfc;
    font-size: 11px;
    line-height: 1.8;
}
.gk-price-history-notice[hidden] { display: none !important; }
.gk-native-chart-status[data-state="error"],
.gk-chart-empty-msg[data-state="error"] { color: #b42318 !important; }
.gk-native-chart-status[data-state="loading"],
.gk-chart-empty-msg[data-state="loading"] { color: #7b8491 !important; }
.gk-native-chart .apexcharts-canvas,
.gk-chart-canvas-wrapper .apexcharts-canvas { max-width: 100% !important; }

@media (max-width: 640px) {
    .gk-price-history-toolbar { overflow-x: auto; scrollbar-width: none; }
    .gk-price-history-toolbar::-webkit-scrollbar { display: none; }
    .gk-price-history-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .gk-price-history-summary > div { padding: 8px 9px; }
    .gk-price-history-ranges { width: max-content; }
}
.gk-price-history-notice:has(.gk-price-history-retry) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.gk-price-history-retry {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid color-mix(in srgb, var(--gk-primary, #ed1944) 18%, #e7eaf0);
    border-radius: 8px;
    background: #fff;
    color: var(--gk-primary, #ed1944);
    font: inherit;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}
.gk-chart-canvas-wrapper,
.gk-native-chart,
[data-gk-price-history-chart] { direction: ltr; }
.gk-price-history-toolbar,
.gk-price-history-summary,
.gk-price-history-notice { direction: rtl; }

/* 1.9.148 — ApexCharts price-history renderer. */
.gk-chart-canvas-wrapper,
.gk-native-chart,
[data-gk-price-history-chart] {
    width: 100%;
    min-height: 320px;
    direction: ltr;
}
.gk-native-chart .apexcharts-canvas,
.gk-native-chart .apexcharts-svg,
.gk-chart-canvas-wrapper .apexcharts-canvas,
.gk-chart-canvas-wrapper .apexcharts-svg,
[data-gk-price-history-chart] .apexcharts-canvas,
[data-gk-price-history-chart] .apexcharts-svg {
    max-width: 100% !important;
}
.gk-native-chart .apexcharts-text,
.gk-chart-canvas-wrapper .apexcharts-text,
[data-gk-price-history-chart] .apexcharts-text {
    font-family: inherit !important;
}
.gk-native-chart .apexcharts-yaxis-label,
.gk-chart-canvas-wrapper .apexcharts-yaxis-label,
[data-gk-price-history-chart] .apexcharts-yaxis-label {
    font-variant-numeric: tabular-nums;
}
.gk-native-chart .apexcharts-data-labels text,
.gk-chart-canvas-wrapper .apexcharts-data-labels text,
[data-gk-price-history-chart] .apexcharts-data-labels text {
    paint-order: stroke;
    stroke: rgba(255,255,255,.95);
    stroke-width: 2px;
    stroke-linejoin: round;
}
.gk-native-chart .apexcharts-tooltip,
.gk-chart-canvas-wrapper .apexcharts-tooltip,
[data-gk-price-history-chart] .apexcharts-tooltip {
    direction: rtl;
    text-align: right;
    border: 1px solid #e8ebef !important;
    border-radius: 10px !important;
    box-shadow: 0 10px 28px rgba(15,23,42,.10) !important;
}
.gk-native-chart .apexcharts-tooltip-title,
.gk-chart-canvas-wrapper .apexcharts-tooltip-title,
[data-gk-price-history-chart] .apexcharts-tooltip-title {
    background: #fafbfc !important;
    border-bottom-color: #eef0f3 !important;
}
.gk-price-history-notice { display: none !important; }

@media (max-width: 640px) {
    .gk-chart-canvas-wrapper,
    .gk-native-chart,
    [data-gk-price-history-chart] {
        min-height: 285px;
    }
}


/* 1.9.154 — guaranteed visible chart surface. */
.gk-chart-canvas-wrapper {
    display: block !important;
    width: 100% !important;
    min-height: 320px !important;
}
.gk-chart-canvas-wrapper[hidden] {
    display: block !important;
}
.gk-native-chart,
[data-gk-price-history-chart] {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    min-height: 320px !important;
    overflow: hidden !important;
    border-radius: 12px;
    background: #fff;
}
.gk-price-chart-fallback {
    position: relative !important;
    z-index: 1;
    display: block !important;
    width: 100% !important;
    min-height: 320px !important;
    overflow: hidden;
    background: linear-gradient(180deg, #fff 0%, #fcfcfd 100%);
}
.gk-price-chart-fallback[hidden] { display: none !important; }
.gk-price-chart-fallback svg {
    display: block !important;
    width: 100% !important;
    height: 300px !important;
}
.gk-price-chart-apex-host {
    position: absolute !important;
    inset: 0 !important;
    z-index: 2;
    display: block !important;
    width: 100% !important;
    min-height: 320px !important;
    background: transparent;
}
.gk-price-chart-fallback__meta {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 3px;
    direction: rtl;
    text-align: right;
    pointer-events: none;
}
.gk-price-chart-fallback__meta strong { color:#344054; font-size:13px; font-weight:800; }
.gk-price-chart-fallback__meta span { color:#98a2b3; font-size:10px; font-weight:600; }
.gk-native-chart.is-loading .gk-price-chart-fallback,
[data-gk-price-history-chart].is-loading .gk-price-chart-fallback { opacity:.82; }
@media (max-width:640px) {
    .gk-chart-canvas-wrapper,
    .gk-native-chart,
    [data-gk-price-history-chart],
    .gk-price-chart-fallback,
    .gk-price-chart-apex-host { min-height:285px !important; }
    .gk-price-chart-fallback svg { height:270px !important; }
}


/* 1.9.155 — isolate Apex/fallback SVG sizing from generic product icon rules. */
.gk-native-product .gk-native-chart .apexcharts-canvas,
.gk-native-product .gk-native-chart .apexcharts-svg,
.gk-native-chart .apexcharts-canvas,
.gk-native-chart .apexcharts-svg,
.gk-chart-canvas-wrapper .apexcharts-canvas,
.gk-chart-canvas-wrapper .apexcharts-svg,
[data-gk-price-history-chart] .apexcharts-canvas,
[data-gk-price-history-chart] .apexcharts-svg {
    display: block !important;
    width: 100% !important;
    min-width: 100% !important;
    height: 320px !important;
    min-height: 320px !important;
    max-width: none !important;
}
.gk-native-product .gk-price-chart-fallback__svg,
.gk-price-chart-fallback__svg {
    display: block !important;
    width: 100% !important;
    height: 300px !important;
    min-width: 100% !important;
    max-width: none !important;
}
@media (max-width:640px) {
    .gk-native-product .gk-native-chart .apexcharts-canvas,
    .gk-native-product .gk-native-chart .apexcharts-svg,
    .gk-native-chart .apexcharts-canvas,
    .gk-native-chart .apexcharts-svg,
    .gk-chart-canvas-wrapper .apexcharts-canvas,
    .gk-chart-canvas-wrapper .apexcharts-svg,
    [data-gk-price-history-chart] .apexcharts-canvas,
    [data-gk-price-history-chart] .apexcharts-svg {
        height: 285px !important;
        min-height: 285px !important;
    }
    .gk-native-product .gk-price-chart-fallback__svg,
    .gk-price-chart-fallback__svg { height:270px !important; }
}
