/**
 * K线图弹窗样式
 * 支持暗色/亮色主题，响应式设计
 */

/* ============================================================
   1. 弹窗遮罩
   ============================================================ */
.nextick-kline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 99998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    will-change: opacity;
}

.nextick-kline-overlay.active {
    display: flex !important;
    animation: nextick-kline-fade-in 0.2s ease;
}

@keyframes nextick-kline-fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* ============================================================
   2. 弹窗容器
   ============================================================ */
.nextick-kline-modal {
    position: relative;
    width: 92%;
    max-width: 1200px;
    height: 85vh;
    max-height: 850px;
    background: #1a1a2e;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: nextick-kline-modal-in 0.3s ease;
    will-change: transform, opacity;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@keyframes nextick-kline-modal-in {
    0% { opacity: 0; transform: scale(0.95) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================
   3. 弹窗头部
   ============================================================ */
.nextick-kline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    min-height: 52px;
    gap: 10px;
    flex-wrap: wrap;
}

.nextick-kline-title-area {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.nextick-kline-title {
    font-size: 18px;
    font-weight: 600;
    color: #e0e0e0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nextick-kline-title .pair-name {
    color: #fff;
}

.nextick-kline-title .pair-change {
    font-size: 14px;
    font-weight: 500;
    padding: 2px 12px;
    border-radius: 12px;
}

.nextick-kline-title .pair-change.up {
    color: #26a69a;
    background: rgba(38, 166, 154, 0.12);
}

.nextick-kline-title .pair-change.down {
    color: #ef5350;
    background: rgba(239, 83, 80, 0.12);
}

.nextick-kline-title .pair-change.flat {
    color: #9e9e9e;
    background: rgba(158, 158, 158, 0.12);
}

.nextick-kline-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.nextick-kline-header-actions button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #bdbdbd;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-family: inherit;
    padding: 0;
}

.nextick-kline-header-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.15);
}

.nextick-kline-header-actions button.active {
    background: rgba(74, 108, 247, 0.2);
    border-color: #4a6cf7;
    color: #4a6cf7;
}

.nextick-kline-header-actions .btn-close {
    color: #888;
    font-size: 18px;
}

.nextick-kline-header-actions .btn-close:hover {
    color: #ef5350;
    border-color: rgba(239, 83, 80, 0.3);
    background: rgba(239, 83, 80, 0.08);
}

/* ============================================================
   4. 弹窗主体
   ============================================================ */
.nextick-kline-body {
    flex: 1;
    padding: 12px 16px 8px 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ============================================================
   5. 控制栏（周期 + 指标）
   ============================================================ */
.nextick-kline-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 6px 0 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.nextick-kline-controls .control-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nextick-kline-controls .control-label {
    font-size: 11px;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: 4px;
}

.nextick-kline-controls .period-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #888;
    padding: 3px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.nextick-kline-controls .period-btn:hover {
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.15);
}

.nextick-kline-controls .period-btn.active {
    background: #4a6cf7;
    border-color: #4a6cf7;
    color: #fff;
}

.nextick-kline-controls .period-custom {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nextick-kline-controls .period-custom input {
    width: 60px;
    padding: 3px 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: #e0e0e0;
    font-size: 12px;
    text-align: center;
    font-family: inherit;
}

.nextick-kline-controls .period-custom input:focus {
    border-color: #4a6cf7;
    outline: none;
}

.nextick-kline-controls .period-custom .unit {
    font-size: 12px;
    color: #888;
}

.nextick-kline-controls .indicator-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #888;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.nextick-kline-controls .indicator-toggle:hover {
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.15);
}

.nextick-kline-controls .indicator-toggle.active {
    background: rgba(74, 108, 247, 0.15);
    border-color: #4a6cf7;
    color: #4a6cf7;
}

.nextick-kline-controls .indicator-dropdown {
    position: relative;
    display: inline-block;
}

.nextick-kline-controls .indicator-dropdown-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #888;
    padding: 3px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nextick-kline-controls .indicator-dropdown-btn:hover {
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.15);
}

.nextick-kline-controls .indicator-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 0;
    min-width: 180px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    margin-top: 4px;
}

.nextick-kline-controls .indicator-dropdown-menu.open {
    display: block;
}

.nextick-kline-controls .indicator-dropdown-menu .menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    cursor: pointer;
    font-size: 12px;
    color: #bdbdbd;
    transition: background 0.15s;
}

.nextick-kline-controls .indicator-dropdown-menu .menu-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.nextick-kline-controls .indicator-dropdown-menu .menu-item input[type="checkbox"] {
    accent-color: #4a6cf7;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.nextick-kline-controls .indicator-dropdown-menu .menu-item .indicator-color {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #999;
}

.nextick-kline-mobile-indicator-drawer .drawer-item .color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
    border: 1px solid rgba(255,255,255,0.1);
}

.nextick-kline-controls .indicator-dropdown-menu .menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 4px 0;
}

.nextick-kline-controls .controls-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nextick-kline-data-range {
    font-size: 11px;
    color: #666;
    padding: 2px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    white-space: nowrap;
}

/* ============================================================
   6. 图表容器
   ============================================================ */
.nextick-kline-chart-container {
    flex: 1;
    min-height: 0;
    position: relative;
    margin-top: 4px;
    background: transparent;
    border-radius: 4px;
    overflow: hidden;
}

.nextick-kline-chart-container canvas,
.nextick-kline-chart-container .echarts-container {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.nextick-kline-chart-container .chart-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #666;
}

.nextick-kline-chart-container .chart-loading .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.06);
    border-top-color: #4a6cf7;
    border-radius: 50%;
    animation: nextick-kline-spin 0.8s linear infinite;
}

@keyframes nextick-kline-spin {
    to { transform: rotate(360deg); }
}

.nextick-kline-chart-container .chart-loading .progress-text {
    font-size: 13px;
    color: #888;
}

.nextick-kline-chart-container .chart-loading .progress-bar {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.nextick-kline-chart-container .chart-loading .progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, #4a6cf7, #7c4dff);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s;
}

.nextick-kline-chart-container .chart-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #ef5350;
}

.nextick-kline-chart-container .chart-error .error-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.nextick-kline-chart-container .chart-error .error-title {
    font-size: 15px;
    font-weight: 500;
}

.nextick-kline-chart-container .chart-error .error-hint {
    font-size: 13px;
    color: #888;
    margin-top: 4px;
}

.nextick-kline-chart-container .chart-error .btn-retry {
    margin-top: 12px;
    padding: 6px 24px;
    background: #4a6cf7;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.2s;
}

.nextick-kline-chart-container .chart-error .btn-retry:hover {
    background: #3a5cd7;
}

.nextick-kline-chart-container .chart-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
}

.nextick-kline-chart-container .chart-empty .empty-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

/* ============================================================
   7. 弹窗底部
   ============================================================ */
.nextick-kline-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 6px;
}

.nextick-kline-footer .footer-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: #666;
}

.nextick-kline-footer .footer-left .data-source {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nextick-kline-footer .footer-left .data-source .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.nextick-kline-footer .footer-left .data-source .dot.ecb {
    background: #4a6cf7;
}

.nextick-kline-footer .footer-left .data-source .dot.api {
    background: #f39c12;
}

.nextick-kline-footer .footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nextick-kline-footer .footer-right .shortcut-hint {
    font-size: 10px;
    color: #555;
    background: rgba(255, 255, 255, 0.03);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

/* ============================================================
   8. 全屏模式
   ============================================================ */
.nextick-kline-modal.fullscreen {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

.nextick-kline-overlay.fullscreen-blur {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ============================================================
   9. 亮色主题
   ============================================================ */
.nextick-kline-modal.light-theme {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.15);
}

.nextick-kline-modal.light-theme .nextick-kline-header {
    background: rgba(0, 0, 0, 0.02);
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

.nextick-kline-modal.light-theme .nextick-kline-title {
    color: #1a1a2e;
}

.nextick-kline-modal.light-theme .nextick-kline-title .pair-name {
    color: #1a1a2e;
}

.nextick-kline-modal.light-theme .nextick-kline-header-actions button {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
    color: #888;
}

.nextick-kline-modal.light-theme .nextick-kline-header-actions button:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #333;
}

.nextick-kline-modal.light-theme .nextick-kline-controls {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

.nextick-kline-modal.light-theme .nextick-kline-controls .period-btn {
    border-color: rgba(0, 0, 0, 0.08);
    color: #888;
}

.nextick-kline-modal.light-theme .nextick-kline-controls .period-btn:hover {
    color: #333;
    border-color: rgba(0, 0, 0, 0.15);
}

.nextick-kline-modal.light-theme .nextick-kline-controls .period-btn.active {
    background: #4a6cf7;
    border-color: #4a6cf7;
    color: #fff;
}

.nextick-kline-modal.light-theme .nextick-kline-controls .indicator-toggle {
    border-color: rgba(0, 0, 0, 0.08);
    color: #888;
}

.nextick-kline-modal.light-theme .nextick-kline-controls .indicator-toggle:hover {
    color: #333;
}

.nextick-kline-modal.light-theme .nextick-kline-controls .indicator-toggle.active {
    background: rgba(74, 108, 247, 0.1);
    border-color: #4a6cf7;
    color: #4a6cf7;
}

.nextick-kline-modal.light-theme .nextick-kline-controls .indicator-dropdown-btn {
    border-color: rgba(0, 0, 0, 0.08);
    color: #888;
}

.nextick-kline-modal.light-theme .nextick-kline-controls .indicator-dropdown-btn:hover {
    color: #333;
}

.nextick-kline-modal.light-theme .nextick-kline-controls .indicator-dropdown-menu {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
}

.nextick-kline-modal.light-theme .nextick-kline-controls .indicator-dropdown-menu .menu-item {
    color: #555;
}

.nextick-kline-modal.light-theme .nextick-kline-controls .indicator-dropdown-menu .menu-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.nextick-kline-modal.light-theme .nextick-kline-footer {
    border-top-color: rgba(0, 0, 0, 0.06);
}

.nextick-kline-modal.light-theme .nextick-kline-footer .footer-left {
    color: #999;
}

.nextick-kline-modal.light-theme .nextick-kline-data-range {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
    color: #999;
}

.nextick-kline-modal.light-theme .nextick-kline-controls .period-custom input {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
    color: #333;
}

.nextick-kline-modal.light-theme .nextick-kline-footer .footer-right .shortcut-hint {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.06);
    color: #aaa;
}

/* ============================================================
   10. 响应式适配
   ============================================================ */
@media (max-width: 992px) {
    .nextick-kline-modal {
        width: 96%;
        height: 88vh;
        max-height: 90vh;
    }
}

@media (max-width: 768px) {
    .nextick-kline-overlay {
        padding: 8px;
    }

    .nextick-kline-modal {
        width: 98%;
        height: 92vh;
        max-height: 98vh;
        border-radius: 12px;
    }

    .nextick-kline-header {
        padding: 8px 14px;
        min-height: 44px;
    }

    .nextick-kline-title {
        font-size: 15px;
    }

    .nextick-kline-title .pair-change {
        font-size: 12px;
        padding: 1px 8px;
    }

    .nextick-kline-header-actions button {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .nextick-kline-body {
        padding: 8px 10px 4px 10px;
    }

    .nextick-kline-controls {
        gap: 6px 8px;
        padding: 4px 0 6px 0;
    }

    .nextick-kline-controls .control-label {
        font-size: 10px;
    }

    .nextick-kline-controls .period-btn {
        font-size: 11px;
        padding: 2px 8px;
    }

    .nextick-kline-controls .indicator-toggle {
        font-size: 10px;
        padding: 2px 8px;
    }

    .nextick-kline-controls .indicator-dropdown-btn {
        font-size: 11px;
        padding: 2px 10px;
    }

    .nextick-kline-controls .indicator-dropdown-menu {
        min-width: 150px;
        max-height: 200px;
        right: 0;
        left: auto;
    }

    .nextick-kline-controls .period-custom input {
        width: 48px;
        font-size: 11px;
        padding: 2px 4px;
    }

    .nextick-kline-data-range {
        font-size: 10px;
        padding: 1px 6px;
    }

    .nextick-kline-footer {
        padding: 4px 12px 6px 12px;
        font-size: 10px;
    }

    .nextick-kline-footer .footer-left {
        gap: 6px;
    }

    .nextick-kline-footer .footer-right .shortcut-hint {
        font-size: 9px;
        padding: 1px 6px;
    }

    .nextick-kline-chart-container .chart-loading .progress-bar {
        width: 140px;
    }
}

@media (max-width: 480px) {
    .nextick-kline-modal {
        border-radius: 8px;
    }

    .nextick-kline-header {
        padding: 6px 10px;
        min-height: 38px;
        gap: 4px;
    }

    .nextick-kline-title {
        font-size: 13px;
    }

    .nextick-kline-title .pair-change {
        font-size: 10px;
        padding: 1px 6px;
    }

    .nextick-kline-header-actions button {
        width: 26px;
        height: 26px;
        font-size: 12px;
        border-radius: 6px;
    }

    .nextick-kline-body {
        padding: 4px 6px 2px 6px;
    }

    .nextick-kline-controls {
        gap: 4px 6px;
        padding: 3px 0 4px 0;
    }

    .nextick-kline-controls .period-btn {
        font-size: 10px;
        padding: 1px 6px;
    }

    .nextick-kline-controls .indicator-toggle {
        font-size: 9px;
        padding: 1px 6px;
    }

    .nextick-kline-controls .indicator-dropdown-btn {
        font-size: 10px;
        padding: 1px 8px;
    }

    .nextick-kline-controls .period-custom input {
        width: 40px;
        font-size: 10px;
        padding: 1px 3px;
    }

    .nextick-kline-data-range {
        font-size: 9px;
        padding: 1px 4px;
    }

    .nextick-kline-footer {
        padding: 2px 8px 4px 8px;
        font-size: 9px;
        gap: 4px;
    }

    .nextick-kline-footer .footer-left {
        flex-wrap: wrap;
        gap: 4px;
    }

    .nextick-kline-chart-container .chart-loading .progress-bar {
        width: 100px;
    }

    .nextick-kline-chart-container .chart-loading .spinner {
        width: 28px;
        height: 28px;
    }
}

/* ============================================================
   11. 滚动条美化
   ============================================================ */
.nextick-kline-controls .indicator-dropdown-menu::-webkit-scrollbar {
    width: 4px;
}

.nextick-kline-controls .indicator-dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
}

.nextick-kline-controls .indicator-dropdown-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.nextick-kline-modal.light-theme .nextick-kline-controls .indicator-dropdown-menu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}