/* ═══════════════════════════════════════════════
   NERON TRADER — Gridstack Customizations
   ═══════════════════════════════════════════════ */

.grid-stack {
    /* JS bu ölçüleri GridStack'in gerçek hücre geometrisinden günceller. */
    --grid-column-size: 8.333333%;
    --grid-row-size: 50px;
    --grid-minor-column-size: 1.388889%;
    --grid-minor-row-size: 25px;
    --grid-dot-minor-color: rgba(146, 146, 172, 0.38);
    --grid-dot-major-color: rgba(128, 110, 255, 0.7);

    position: relative;
    isolation: isolate;
    height: auto;
    min-height: 100%;
    padding-bottom: 8px;
    box-sizing: border-box;
    background: var(--bg-primary);
}

/*
 * Tek katmanlı çizim yüzeyi: büyük noktalar GridStack hücre başlangıçlarını,
 * küçük noktalar hücre içi alt bölümleri gösterir. Yüzey normal durumda da
 * görünürdür; z-index sırası noktaları grid arka planının üstünde, widget'ların
 * altında tutar.
 */
.grid-stack::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
    background-image:
        radial-gradient(circle at 1.25px 1.25px, var(--grid-dot-major-color) 1.25px, transparent 1.4px),
        radial-gradient(circle at 1px 1px, var(--grid-dot-minor-color) 0.8px, transparent 0.95px);
    background-position: 0 0, 0 0;
    background-repeat: repeat, repeat;
    background-size:
        var(--grid-column-size) var(--grid-row-size),
        var(--grid-minor-column-size) var(--grid-minor-row-size);
}

/* Açık ve cam temalarında benzer algısal kontrast korunur. */
[data-theme="light"] .grid-stack {
    --grid-dot-minor-color: rgba(55, 55, 82, 0.36);
    --grid-dot-major-color: rgba(91, 70, 220, 0.68);
}

[data-theme="glass"] .grid-stack {
    --grid-dot-minor-color: rgba(255, 255, 255, 0.36);
    --grid-dot-major-color: rgba(160, 147, 255, 0.72);
}

[data-theme="glass-green"] .grid-stack {
    --grid-dot-minor-color: rgba(220, 238, 228, 0.35);
    --grid-dot-major-color: rgba(16, 185, 129, 0.72);
}

[data-theme="glass-purple"] .grid-stack {
    --grid-dot-minor-color: rgba(240, 226, 248, 0.35);
    --grid-dot-major-color: rgba(168, 85, 247, 0.72);
}

[data-theme="glass-amber"] .grid-stack {
    --grid-dot-minor-color: rgba(248, 234, 211, 0.35);
    --grid-dot-major-color: rgba(232, 145, 58, 0.74);
}

[data-theme="glass-carbon"] .grid-stack {
    --grid-dot-minor-color: rgba(225, 225, 232, 0.36);
    --grid-dot-major-color: rgba(157, 146, 255, 0.7);
}

[data-theme="midnight"] .grid-stack {
    --grid-dot-minor-color: rgba(160, 176, 198, 0.38);
    --grid-dot-major-color: rgba(14, 165, 233, 0.7);
}

[data-theme="sunset"] .grid-stack {
    --grid-dot-minor-color: rgba(232, 213, 196, 0.36);
    --grid-dot-major-color: rgba(232, 145, 58, 0.72);
}

/* Grid item */
.grid-stack-item {
    /* Override gridstack defaults */
}

.grid-stack-item-content {
    border-radius: var(--radius);
    overflow: hidden;
}

/* Placeholder (sürükleme sırasında) */
.grid-stack-placeholder > .placeholder-content {
    background: var(--accent-muted) !important;
    border: 2px dashed var(--accent) !important;
    border-radius: var(--radius) !important;
    opacity: 0.5;
}

/* Resize handle */
.grid-stack-item > .ui-resizable-se {
    width: 14px;
    height: 14px;
    bottom: 2px;
    right: 2px;
    background: none;
}
.grid-stack-item > .ui-resizable-se::before {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    opacity: 0;
    transition: opacity var(--transition);
}
@media (hover: hover) and (pointer: fine) {
    .grid-stack-item:hover > .ui-resizable-se::before {
        opacity: 0.5;
    }
}

/* Drag animation */
.grid-stack-item.ui-draggable-dragging {
    opacity: 0.9;
    z-index: 999 !important;
}
.grid-stack-item.ui-draggable-dragging .widget-frame {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border-color: var(--accent);
}

/* Cell height override for better default sizing */
.grid-stack > .grid-stack-item {
    min-height: 0;
    z-index: 1;
}

/* GridStack etkileşim katmanlarını sabit widget yüzeyinin üstünde koru. */
.grid-stack > .grid-stack-placeholder {
    z-index: 2;
}

.grid-stack > .grid-stack-item.ui-resizable-resizing {
    z-index: 999 !important;
}

/* Gap between widgets */
.grid-stack {
    --gs-gutter: 4px;
}

.grid-stack[data-grid-density="compact"] {
    --gs-gutter: 2px;
}

/* Glass themes — grid-stack'in opak bg'si body gradient'ini örtmesin */
[data-theme="glass"] .grid-stack,
[data-theme="glass-green"] .grid-stack,
[data-theme="glass-purple"] .grid-stack,
[data-theme="glass-amber"] .grid-stack,
[data-theme="glass-carbon"] .grid-stack {
    background: transparent;
}

/* Mobile grid — tab sistemi kullanılır, gridstack tamamen devre dışı */
@media (max-width: 768px),
       (max-width: 950px) and (max-height: 600px) and (hover: none) and (pointer: coarse) {
    .grid-stack {
        display: none !important;
        --gs-gutter: 0px;
        min-height: 0 !important;
        padding-bottom: 0;
    }
    .grid-stack::before {
        content: none;
    }
    .grid-stack-item-content {
        border-radius: 0;
    }
    .grid-stack-item > .ui-resizable-se {
        display: none;
    }
    /* Gridstack placeholder & dragging — mobilde gereksiz */
    .grid-stack-placeholder,
    .grid-stack-item.ui-draggable-dragging {
        display: none !important;
    }

    /* Native accordion button, mevcut görsel dili bozmadan klavye/AT semantiği sağlar. */
    .mobile-accordion-header {
        width: 100%;
        border: 0;
        border-radius: 0;
        text-align: left;
        font: inherit;
    }

    /* Dikey scroll tarayıcıda kalır; yatay intent Pointer Events'e ayrılır. */
    .chart-panel-swipe {
        touch-action: pan-y;
        contain: layout paint;
    }

    .chart-panel-page {
        backface-visibility: hidden;
        transform: translate3d(0, 0, 0);
    }

    .mobile-split-handle,
    .chart-panel-handle {
        outline-offset: -2px;
    }
}
