/**
 * K线图弹窗 - 移动端增强样式
 * 手势支持、触屏优化、底部抽屉式指标选择器
 */

/* ============================================================
   1. 移动端底部抽屉式指标选择器
   ============================================================ */
.nextick-kline-mobile-indicator-drawer {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a2e;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px 16px 0 0;
    max-height: 55vh;
    z-index: 99999;
    padding: 16px 20px 24px 20px;
    animation: nextick-kline-drawer-up 0.3s ease;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.4);
    overflow-y: auto;
}

.nextick-kline-mobile-indicator-drawer.open {
    display: block;
}

@keyframes nextick-kline-drawer-up {
    0% { transform: translateY(100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.nextick-kline-mobile-indicator-drawer .drawer-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    margin: 0 auto 12px auto;
    flex-shrink: 0;
}

.nextick-kline-mobile-indicator-drawer .drawer-title {
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nextick-kline-mobile-indicator-drawer .drawer-title .drawer-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}

.nextick-kline-mobile-indicator-drawer .drawer-section {
    margin-bottom: 12px;
}

.nextick-kline-mobile-indicator-drawer .drawer-section .section-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    margin-bottom: 6px;
}

.nextick-kline-mobile-indicator-drawer .drawer-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.nextick-kline-mobile-indicator-drawer .drawer-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    color: #888;
}

.nextick-kline-mobile-indicator-drawer .drawer-item:active {
    transform: scale(0.96);
}

.nextick-kline-mobile-indicator-drawer .drawer-item.active {
    background: rgba(74, 108, 247, 0.12);
    border-color: #4a6cf7;
    color: #4a6cf7;
}

.nextick-kline-mobile-indicator-drawer .drawer-item .color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.nextick-kline-mobile-indicator-drawer .drawer-item .item-label {
    font-size: 11px;
}

/* 亮色主题 */
.nextick-kline-modal.light-theme .nextick-kline-mobile-indicator-drawer {
    background: #ffffff;
    border-top-color: rgba(0, 0, 0, 0.08);
}

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

.nextick-kline-modal.light-theme .nextick-kline-mobile-indicator-drawer .drawer-item {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
    color: #888;
}

.nextick-kline-modal.light-theme .nextick-kline-mobile-indicator-drawer .drawer-item.active {
    background: rgba(74, 108, 247, 0.08);
    border-color: #4a6cf7;
    color: #4a6cf7;
}

.nextick-kline-modal.light-theme .nextick-kline-mobile-indicator-drawer .drawer-handle {
    background: rgba(0, 0, 0, 0.12);
}

/* ============================================================
   2. 触屏优化
   ============================================================ */
.nextick-kline-modal {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.nextick-kline-chart-container {
    touch-action: pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
}

/* 点击高亮效果 */
.nextick-kline-trigger-highlight {
    transition: background 0.15s, box-shadow 0.15s;
    cursor: pointer;
    position: relative;
}

.nextick-kline-trigger-highlight:active {
    background: rgba(74, 108, 247, 0.12) !important;
    box-shadow: inset 0 0 0 2px rgba(74, 108, 247, 0.3);
}

.nextick-kline-trigger-highlight .click-hint {
    display: none;
    font-size: 10px;
    color: #4a6cf7;
    margin-left: 6px;
    opacity: 0.6;
}

.nextick-kline-trigger-highlight:hover .click-hint {
    display: inline;
}

/* 触屏长按提示 */
.nextick-kline-trigger-highlight .touch-hint {
    display: none;
    position: absolute;
    top: -20px;
    right: -4px;
    font-size: 8px;
    color: #888;
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 6px;
    border-radius: 4px;
}

@media (hover: none) and (pointer: coarse) {
    .nextick-kline-trigger-highlight .click-hint {
        display: none !important;
    }
    .nextick-kline-trigger-highlight .touch-hint {
        display: block;
    }
}

/* ============================================================
   3. 全屏模式下的缩放控制
   ============================================================ */
.nextick-kline-zoom-controls {
    position: absolute;
    bottom: 80px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 5;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.nextick-kline-zoom-controls:hover {
    opacity: 1;
}

.nextick-kline-zoom-controls button {
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: #bdbdbd;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.nextick-kline-zoom-controls button:hover {
    background: rgba(74, 108, 247, 0.2);
    border-color: #4a6cf7;
    color: #fff;
}

.nextick-kline-zoom-controls button:active {
    transform: scale(0.92);
}

/* 全屏时缩放控制位置调整 */
.nextick-kline-modal.fullscreen .nextick-kline-zoom-controls {
    bottom: 100px;
    right: 24px;
}

/* 亮色主题 */
.nextick-kline-modal.light-theme .nextick-kline-zoom-controls button {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.08);
    color: #666;
}

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

/* ============================================================
   4. 移动端弹窗尺寸优化
   ============================================================ */
@media (max-width: 768px) {
    .nextick-kline-modal {
        width: 95% !important;
        max-width: 95% !important;
        height: 90vh !important;
        max-height: 92vh !important;
        border-radius: 12px;
    }

    .nextick-kline-overlay {
        padding: 6px;
    }

    /* 移动端控制栏折叠 */
    .nextick-kline-controls {
        gap: 4px 6px;
        padding: 4px 0 6px 0;
    }

    .nextick-kline-controls .control-group.period-group {
        flex-wrap: wrap;
    }

    .nextick-kline-controls .control-group.indicator-group {
        flex-wrap: wrap;
    }

    /* 移动端数据范围信息单独一行 */
    .nextick-kline-data-range {
        font-size: 9px;
        padding: 1px 6px;
        white-space: normal;
        word-break: break-all;
    }

    /* 移动端指标下拉菜单调整 */
    .nextick-kline-controls .indicator-dropdown-menu {
        min-width: 140px;
        max-height: 160px;
        left: auto;
        right: 0;
    }

    /* 底部footer紧凑 */
    .nextick-kline-footer {
        padding: 3px 10px 5px 10px;
        gap: 3px;
    }

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

    .nextick-kline-footer .footer-right .shortcut-hint {
        display: none;
    }

    /* 缩放控制变小 */
    .nextick-kline-zoom-controls {
        bottom: 60px;
        right: 10px;
        gap: 3px;
    }

    .nextick-kline-zoom-controls button {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .nextick-kline-modal.fullscreen .nextick-kline-zoom-controls {
        bottom: 70px;
        right: 16px;
    }
}

/* ============================================================
   5. 超小屏手机 (iPhone SE 等)
   ============================================================ */
@media (max-width: 420px) {
    .nextick-kline-modal {
        width: 98% !important;
        max-width: 98% !important;
        height: 94vh !important;
        max-height: 96vh !important;
        border-radius: 8px;
    }

    .nextick-kline-header {
        padding: 4px 8px;
        min-height: 34px;
    }

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

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

    .nextick-kline-header-actions button {
        width: 24px;
        height: 24px;
        font-size: 11px;
        border-radius: 4px;
    }

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

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

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

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

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

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

    .nextick-kline-controls .period-custom input {
        width: 34px;
        font-size: 9px;
        padding: 1px 2px;
    }

    .nextick-kline-footer {
        padding: 2px 6px 3px 6px;
        font-size: 8px;
    }

    .nextick-kline-footer .footer-left .data-source {
        font-size: 8px;
    }

    .nextick-kline-zoom-controls {
        bottom: 50px;
        right: 6px;
    }

    .nextick-kline-zoom-controls button {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }

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

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

    .nextick-kline-chart-container .chart-loading .progress-text {
        font-size: 11px;
    }
}

/* ============================================================
   6. 横屏模式适配
   ============================================================ */
@media (orientation: landscape) and (max-height: 500px) {
    .nextick-kline-modal {
        height: 96vh !important;
        max-height: 98vh !important;
    }

    .nextick-kline-header {
        padding: 4px 12px;
        min-height: 32px;
    }

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

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

    .nextick-kline-controls {
        padding: 2px 0 4px 0;
    }

    .nextick-kline-footer {
        padding: 2px 10px 3px 10px;
    }

    .nextick-kline-zoom-controls {
        bottom: 40px;
        right: 8px;
    }
}

/* ============================================================
   7. 移动端抽屉遮罩
   ============================================================ */
.nextick-kline-drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99998;
}

.nextick-kline-drawer-overlay.open {
    display: block;
}

@media (max-width: 768px) {
    .nextick-kline-drawer-overlay {
        display: none;
    }
    .nextick-kline-drawer-overlay.open {
        display: block;
    }
}