/* 流量消失器 - Material Design 融合样式 */

/* 基础样式 */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #f3f4f6; /* 浅色模式默认背景 */
}

html.dark body {
    background-color: #111827; /* 深色模式背景 */
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* 动画 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

/* 卡片样式增强 */
.card {
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
}

/* 节点状态指示器 */
.node-status-dot {
    position: relative;
}

.node-status-dot::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.node-status-dot.valid {
    color: #22c55e;
}

.node-status-dot.invalid {
    color: #ef4444;
}

.node-status-dot.checking {
    color: #eab308;
    animation: pulse 1.5s infinite;
}

/* 速度数字动画 */
.speed-value {
    transition: all 0.5s ease;
}

.speed-value.increase {
    color: #22c55e;
}

.speed-value.decrease {
    color: #ef4444;
}

/* 按钮点击效果 */
.btn-click {
    position: relative;
    overflow: hidden;
}

.btn-click::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn-click:active::after {
    width: 200%;
    height: 200%;
}

/* 输入框焦点样式 */
input:focus,
select:focus {
    outline: none;
    ring: 2px;
    ring-color: #3b82f6;
}

/* 图表容器 */
.chart-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* 响应式增强 */
@media (max-width: 640px) {
    /* 移动端优化 */
    .stat-value {
        font-size: 1.5rem;
    }

    .thread-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* 移动端隐藏部分元素 */
    .hide-mobile {
        display: none;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    /* 平板优化 */
    .stat-value {
        font-size: 1.75rem;
    }

    .thread-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (min-width: 1025px) {
    /* 桌面端优化 */
    .stat-value {
        font-size: 2rem;
    }

    .thread-grid {
        grid-template-columns: repeat(8, 1fr);
    }
}

/* 深色模式增强 */
.dark {
    /* 深色模式下的阴影调整 */
    .shadow-sm {
        box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    }

    .shadow-lg {
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    }

    .shadow-xl {
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    }
}

/* 渐变背景 */
.gradient-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Toast 消息样式 */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: #1f2937;
    color: white;
    border-radius: 8px;
    font-size: 14px;
    z-index: 100;
    animation: fadeIn 0.3s ease-out;
}

.toast.success {
    background: #059669;
}

.toast.error {
    background: #dc2626;
}

.toast.warning {
    background: #d97706;
}

/* 加载状态 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.dark .loading-overlay {
    background: rgba(0, 0, 0, 0.8);
}

/* 进度条样式 */
.progress-bar {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    transition: width 0.3s ease;
}

/* 节点卡片样式 */
.node-card {
    position: relative;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.node-card:hover {
    transform: scale(1.02);
}

.node-card.selected {
    border: 2px solid #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

/* 统计卡片动画 */
.stat-card {
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.1);
}

.dark .stat-card:hover {
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.3);
}

/* 运行状态指示器 */
.running-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.running-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 1.5s infinite;
}

.running-indicator.stopped .dot {
    background: #94a3b8;
    animation: none;
}

/* 数字跳动效果 */
@keyframes numberJump {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.number-jump {
    animation: numberJump 0.3s ease;
}

/* 节点列表滚动优化 */
.node-list-scroll {
    scrollbar-width: thin;
    scrollbar-color: #3b82f6 transparent;
}

.node-list-scroll::-webkit-scrollbar {
    width: 4px;
}

.node-list-scroll::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 2px;
}

/* 移动端底部导航 */
@media (max-width: 640px) {
    .mobile-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 8px;
        display: flex;
        justify-content: space-around;
        z-index: 50;
    }

    .dark .mobile-nav {
        background: #1f2937;
        border-top-color: #374151;
    }

    body {
        padding-bottom: 60px;
    }
}

/* 模态框动画 */
.modal-enter {
    animation: modalEnter 0.3s ease-out;
}

.modal-exit {
    animation: modalExit 0.3s ease-in;
}

@keyframes modalEnter {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes modalExit {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* 选择框高亮 */
.highlight-selection {
    position: relative;
}

.highlight-selection::after {
    content: '';
    position: absolute;
    inset: -2px;
    border: 2px solid #3b82f6;
    border-radius: 10px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.highlight-selection:hover::after,
.highlight-selection:focus::after {
    opacity: 1;
}

/* 历史记录条目 */
.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.history-item:hover {
    background: #f3f4f6;
}

.dark .history-item {
    background: rgba(55, 65, 81, 0.5);
}

.dark .history-item:hover {
    background: rgba(55, 65, 81, 0.7);
}

/* 图表网格线 */
.chart-grid-line {
    stroke: #e5e7eb;
    stroke-width: 1;
}

.dark .chart-grid-line {
    stroke: #374151;
}

/* 线程状态可视化 */
.thread-active {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

.thread-idle {
    background: #f3f4f6;
    color: #94a3b8;
}

.dark .thread-idle {
    background: rgba(55, 65, 81, 0.5);
    color: #64748b;
}

/* 流量上限警告 */
.limit-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.limit-warning.dark {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

/* ============================================ */
/* Material Design 模拟样式 */
/* ============================================ */

/* FAB 迷你按钮 */
.fab-mini {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.fab-mini:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

.fab-mini:active {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
}

/* FAB 扩展按钮 */
.fab-extended {
    height: 48px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 24px;
    border: none;
    cursor: pointer;
    color: white;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

.fab-extended:hover {
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.fab-extended:active {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transform: translateY(0);
}

.fab-icon {
    width: 24px;
    height: 24px;
}

/* Material 开关 */
.material-switch {
    position: relative;
    width: 36px;
    height: 14px;
    cursor: pointer;
}

.switch-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #9e9e9e;
    border-radius: 7px;
    transition: background 0.2s ease;
}

.switch-thumb {
    position: absolute;
    top: -3px;
    left: -2px;
    width: 20px;
    height: 20px;
    background: #fafafa;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.material-switch.active .switch-track {
    background: rgba(98, 0, 238, 0.5);
}

.material-switch.active .switch-thumb {
    left: 18px;
    background: #6200ee;
}

.dark .switch-thumb {
    background: #e0e0e0;
}

.dark .material-switch.active .switch-thumb {
    background: #bb86fc;
}

/* Material 滑块容器 */
.material-slider-container {
    position: relative;
    height: 40px;
    margin-top: 8px;
}

/* 原生滑块隐藏样式 */
.material-slider {
    position: absolute;
    width: 100%;
    height: 40px;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

/* 滑块轨道 */
.slider-track {
    position: absolute;
    top: 16px;
    left: 0;
    right: 0;
    height: 2px;
    background: #e0e0e0;
    border-radius: 1px;
}

.dark .slider-track {
    background: #4a4a4a;
}

/* 滑块填充 */
.slider-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #6200ee;
    border-radius: 1px;
    transition: width 0.1s ease;
}

.dark .slider-fill {
    background: #bb86fc;
}

/* 滑块刻度标记 */
.slider-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
}

.slider-marker {
    width: 2px;
    height: 2px;
    background: #9e9e9e;
    border-radius: 50%;
    margin-top: -1px;
}

.dark .slider-marker {
    background: #6a6a6a;
}

/* 滑块拇指 */
.slider-thumb {
    position: absolute;
    top: 10px;
    width: 12px;
    height: 12px;
    background: #6200ee;
    border-radius: 50%;
    transform: translateX(-50%);
    transition: left 0.1s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.dark .slider-thumb {
    background: #bb86fc;
}

/* 滑块数值气泡 */
.slider-pin {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 4px 8px;
    background: #6200ee;
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dark .slider-pin {
    background: #bb86fc;
}

.material-slider:hover ~ .slider-track .slider-thumb .slider-pin,
.material-slider:focus ~ .slider-track .slider-thumb .slider-pin {
    opacity: 1;
}

/* Snackbar */
.snackbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 24px;
    background: #323232;
    color: white;
    font-size: 14px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    animation: snackbarEnter 0.3s ease;
}

.snackbar.success {
    background: #4caf50;
}

.snackbar.error {
    background: #f44336;
}

.snackbar.warning {
    background: #ff9800;
}

.snackbar.info {
    background: #2196f3;
}

@keyframes snackbarEnter {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 进度条 */
.progress-bar {
    background: linear-gradient(90deg, #6200ee 0%, #bb86fc 100%);
    transition: width 0.3s ease;
}

.dark .progress-bar {
    background: linear-gradient(90deg, #bb86fc 0%, #6200ee 100%);
}

/* Material 输入框增强 */
.material-input input {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.material-input input:focus {
    border-color: #6200ee;
    box-shadow: 0 0 0 2px rgba(98, 0, 238, 0.2);
}

.dark .material-input input:focus {
    border-color: #bb86fc;
    box-shadow: 0 0 0 2px rgba(187, 134, 252, 0.2);
}

/* 深色模式 Material 调整 */
.dark .fab-mini {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.dark .fab-extended {
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.5);
}

/* 展开/折叠面板增强 */
details[open] summary ~ * {
    animation: sweep 0.3s ease-in-out;
}

@keyframes sweep {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 线程状态网格优化 */
.thread-grid-item {
    transition: all 0.2s ease;
}

.thread-grid-item:hover {
    transform: scale(1.05);
}

/* 响应式Material调整 */
@media (max-width: 640px) {
    .fab-extended {
        height: 56px;
        border-radius: 28px;
        font-size: 16px;
    }

    .fab-mini {
        width: 48px;
        height: 48px;
    }

    .snackbar {
        width: calc(100% - 32px);
        left: 16px;
        right: 16px;
        transform: none;
        text-align: center;
    }
}