/* ==========================================================================
   FinAI Bar Replay Engine Styles (TradingView 1:1 Standard)
   ========================================================================== */

/* Top Toolbar Bar Replay Trigger Button */
.bar-replay-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    background: rgba(41, 98, 255, 0.12) !important;
    color: #2962ff !important;
    border: 1px solid rgba(41, 98, 255, 0.35) !important;
    padding: 4px 10px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    margin-left: 6px !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    font-family: inherit !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    white-space: nowrap !important;
    user-select: none !important;
}

.bar-replay-btn:hover {
    background: rgba(41, 98, 255, 0.25) !important;
    color: #ffffff !important;
    border-color: #2962ff !important;
    box-shadow: 0 0 10px rgba(41, 98, 255, 0.4) !important;
}

.bar-replay-btn.active {
    background: #2962ff !important;
    color: #ffffff !important;
    border-color: #2962ff !important;
    box-shadow: 0 0 14px rgba(41, 98, 255, 0.6) !important;
}

/* ==========================================================================
   TradingView-style Floating Replay Dock (Bottom-Centered)
   ========================================================================== */
.finai-replay-dock {
    position: absolute;
    bottom: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 3px;
    background: #1e222d;
    border: 1px solid #363c4e;
    border-radius: 6px;
    padding: 3px 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), 0 0 1px rgba(255, 255, 255, 0.15);
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
    color: #d1d4dc;
    transition: box-shadow 0.2s ease, opacity 0.2s ease;
    overflow: visible; /* Cho phép các dropdown menu (Tốc độ) hiển thị trồi lên phía trên */
}

.finai-replay-dock:hover {
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.7), 0 0 1px rgba(255, 255, 255, 0.25);
}

/* Integrated Slim Scrubber Track at top edge of dock */
.replay-scrubber-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2.5px;
    background: rgba(255, 255, 255, 0.12);
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    cursor: pointer;
    transition: height 0.15s ease;
    overflow: hidden;
    z-index: 5;
}

.finai-replay-dock:hover .replay-scrubber-track {
    height: 3.5px;
}

.replay-scrubber-fill {
    height: 100%;
    background: #2962ff;
    width: 0%;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    transition: width 0.08s linear;
}

/* Drag Handle */
.tv-drag-handle {
    cursor: grab;
    color: #505668;
    font-size: 13px;
    line-height: 1;
    padding: 2px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.tv-drag-handle:hover {
    color: #94a3b8;
}

.tv-drag-handle:active {
    cursor: grabbing;
    color: #2962ff;
}

/* Base Dock Buttons */
.tv-dock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: transparent;
    color: #d1d4dc;
    border: none;
    border-radius: 4px;
    height: 28px;
    padding: 0 7px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.12s, color 0.12s;
    white-space: nowrap;
    outline: none;
}

.tv-dock-btn:hover {
    background-color: #2a2e39;
    color: #f0f3fa;
}

.tv-dock-btn:active {
    background-color: #363c4e;
}

.tv-dock-btn.icon-only {
    width: 28px;
    padding: 0;
}

/* Select Bar Button (with dropdown chevron) */
.tv-dock-btn.select-bar {
    font-weight: 600;
    padding: 0 8px;
}

.tv-dock-btn.select-bar.active {
    background-color: rgba(41, 98, 255, 0.2);
    color: #2962ff;
    box-shadow: inset 0 0 0 1px #2962ff;
}

/* Mode Button (⚡ Bar vs 🌊 Tick) */
.tv-dock-btn.mode-btn {
    font-size: 11.5px;
    font-weight: 600;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.08);
    border-radius: 4px;
    padding: 0 7px;
}

.tv-dock-btn.mode-btn:hover {
    background: rgba(56, 189, 248, 0.18);
    color: #ffffff;
}

/* Play/Pause Button */
.tv-dock-btn.play-pause {
    color: #f0f3fa;
}

.tv-dock-btn.play-pause.playing {
    color: #2962ff;
}

/* Jump to Realtime Button */
.tv-dock-btn.jump-realtime {
    color: #94a3b8;
}

.tv-dock-btn.jump-realtime:hover {
    color: #38bdf8;
}

/* Close Exit Button */
.tv-dock-btn.exit-btn:hover {
    background-color: rgba(242, 54, 69, 0.18);
    color: #f23645;
}

/* Dividers */
.tv-dock-divider {
    width: 1px;
    height: 18px;
    background-color: #363c4e;
    margin: 0 2px;
    flex-shrink: 0;
}

/* Timeframe & Counter Badges */
.tv-tf-badge {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.3px;
}

.tv-counter-text {
    font-size: 11px;
    font-family: 'JetBrains Mono', Consolas, monospace;
    color: #787b86;
    padding: 0 4px;
    white-space: nowrap;
}

/* Dropdown Wrap & Menus (Speed) */
.tv-dropdown-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tv-speed-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e222d;
    border: 1px solid #363c4e;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
    padding: 4px 0;
    min-width: 125px;
    z-index: 10005;
    display: none;
    flex-direction: column;
    pointer-events: auto;
}

.tv-speed-menu.show {
    display: flex !important;
}

.tv-speed-item {
    padding: 6px 12px;
    font-size: 12px;
    color: #d1d4dc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.1s, color 0.1s;
}

.tv-speed-item:hover {
    background-color: #2a2e39;
    color: #ffffff;
}

.tv-speed-item.active {
    color: #2962ff;
    font-weight: 700;
}

.tv-speed-item.active::after {
    content: "✓";
    font-size: 11px;
    color: #2962ff;
}

/* ==========================================================================
   TradingView-style Scissor Tool Cursor Overlay (Vertical Line + ✂ + Date)
   ========================================================================== */
.finai-replay-scissor-guide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9990;
    overflow: hidden;
}

/* Dimmed / Ghosted Future Candles Mask (TradingView Ghost Effect) */
.scissor-future-mask {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0;
    background: rgba(19, 23, 34, 0.80);
    backdrop-filter: saturate(0.5);
    -webkit-backdrop-filter: saturate(0.5);
    pointer-events: none;
    z-index: 9989;
    will-change: left, width;
}

.light-chart-theme .scissor-future-mask {
    background: rgba(255, 255, 255, 0.80) !important;
}

/* Vertical Blue Line */
.scissor-v-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1.5px;
    background: #2962ff;
    box-shadow: 0 0 6px rgba(41, 98, 255, 0.5);
    pointer-events: none;
    transform: translateX(-50%);
    transition: opacity 0.15s ease;
}

/* Scissor Icon floating on the line */
.scissor-icon-badge {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 22px;
    background: #ffffff;
    border: 1.5px solid #2962ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #000000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    z-index: 9992;
}

/* TradingView Blue Date Badge at bottom of time axis */
.scissor-date-badge {
    position: absolute;
    bottom: 24px;
    transform: translateX(-50%);
    background: #2962ff;
    color: #ffffff;
    padding: 2.5px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, sans-serif;
    letter-spacing: 0.2px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 9993;
}

/* Hint Banner at Top when in Scissor Mode */
.tv-scissor-hint-banner {
    position: absolute;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    background: rgba(30, 34, 45, 0.96);
    border: 1px solid #2962ff;
    border-radius: 6px;
    padding: 7px 16px;
    color: #f0f3fa;
    font-size: 12px;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), 0 0 12px rgba(41, 98, 255, 0.35);
    animation: tvHintFadeIn 0.2s ease-out;
    pointer-events: none;
    white-space: nowrap;
}

.tv-scissor-hint-banner.show {
    display: flex;
}

.tv-scissor-hint-banner b {
    color: #38bdf8;
}

@keyframes tvHintFadeIn {
    from { opacity: 0; transform: translate(-50%, -8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .finai-replay-dock {
        bottom: 12px;
        padding: 2px 4px;
        max-width: 96vw;
        overflow-x: auto;
    }
    .tv-dock-btn.select-bar span {
        display: none;
    }
    .tv-counter-text {
        display: none;
    }
}
