/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #1a1a2e;
    color: #eee;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* 全屏波形展示 */
#waveformChart {
    width: 100vw;
    height: 100vh;
    background-color: #16213e;
}

/* 自定义Tooltip样式 */
.custom-tooltip {
    position: fixed;
    z-index: 10000;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.98));
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    min-width: 180px;
    display: none;
}

.tooltip-header {
    font-weight: 600;
    font-size: 13px;
    color: #60a5fa;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    color: #94a3b8;
}

.tooltip-row span:last-child {
    color: #e2e8f0;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 11px;
}

.tooltip-row.highlight {
    color: #f59e0b;
    font-weight: 600;
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(245, 158, 11, 0.3);
}

.tooltip-row.highlight span:last-child {
    color: #fbbf24;
}

.tooltip-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

.tooltip-subtitle {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 4px;
    font-weight: 500;
}

/* 浮窗控制面板 */
.floating-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 40px);
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    z-index: 1000;
    overflow: hidden;
    transition: all 0.3s ease;
}

.floating-panel.collapsed .panel-content {
    max-height: 0;
    padding: 0 16px;
    overflow: hidden;
}

.floating-panel.minimized {
    transform: translateX(400px);
    opacity: 0;
    pointer-events: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: move;
    user-select: none;
}

.panel-title {
    font-weight: 600;
    font-size: 14px;
    color: #93c5fd;
}

.panel-controls {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.panel-content {
    padding: 16px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    transition: all 0.3s ease;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* 区块样式 */
.section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 10px;
}

.section-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* 配置行 */
.config-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

/* 输入框 */
.input-field {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    transition: all 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.input-field::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* 状态文本 */
.status-text {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

.status-text.success {
    color: #4ade80;
}

.status-text.error {
    color: #f87171;
}

/* 按钮样式 */
.btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-sm {
    padding: 6px 12px;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 11px;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
}

.btn-success:hover {
    background: linear-gradient(135deg, #4ade80, #22c55e);
}

.btn-purple {
    background: linear-gradient(135deg, #a855f7, #9333ea);
    color: #fff;
}

.btn-purple:hover {
    background: linear-gradient(135deg, #c084fc, #a855f7);
}

.btn-indigo {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
}

.btn-indigo:hover {
    background: linear-gradient(135deg, #818cf8, #6366f1);
}

.btn-orange {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
}

.btn-orange:hover {
    background: linear-gradient(135deg, #fb923c, #f97316);
}

.btn-red {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
}

.btn-red:hover {
    background: linear-gradient(135deg, #f87171, #ef4444);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-outline {
    background: transparent;
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* 复选框标签 */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #94a3b8;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* 脉冲点指示器 */
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4ade80;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

/* IO状态网格 */
.io-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.io-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 11px;
    transition: all 0.2s;
}

.io-item.active {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.io-item.inactive {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.io-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: all 0.3s;
}

.io-indicator.active {
    background-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.io-indicator.inactive {
    background-color: #4b5563;
}

/* 刷新信息 */
.refresh-info {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #64748b;
    margin-top: 8px;
}

/* 通道显示网格 */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.channel-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.channel-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.channel-toggle input {
    width: 12px;
    height: 12px;
    cursor: pointer;
}

.channel-toggle .color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* 标签信息 */
.marker-info {
    font-size: 11px;
    color: #94a3b8;
}

.marker-list {
    margin-top: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.marker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin-bottom: 4px;
}

.marker-item .marker-label {
    font-weight: 500;
    color: #60a5fa;
}

.marker-item .marker-time {
    color: #94a3b8;
}

.marker-item .marker-delete {
    color: #f87171;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.2s;
}

.marker-item .marker-delete:hover {
    background: rgba(248, 113, 113, 0.2);
}

.time-diff {
    margin-top: 8px;
    padding: 8px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.time-diff-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 11px;
}

.time-diff-label {
    color: #94a3b8;
}

.time-diff-value {
    color: #60a5fa;
    font-weight: 500;
    font-family: 'Monaco', 'Consolas', monospace;
}

/* 恢复按钮 */
.restore-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #93c5fd;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.restore-btn:hover {
    background: linear-gradient(135deg, rgba(40, 51, 69, 0.95), rgba(25, 33, 52, 0.95));
    transform: translateY(-2px);
}

/* 模态窗口 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(59, 130, 246, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
}

.close-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.modal-body {
    padding: 20px;
    max-height: calc(80vh - 140px);
    overflow-y: auto;
}

.hint-text {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 16px;
}

.name-config-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.name-config-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.name-config-item label {
    font-size: 12px;
    color: #94a3b8;
    min-width: 35px;
}

.name-config-item input {
    flex: 1;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
}

.name-config-item input:focus {
    outline: none;
    border-color: #3b82f6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* 帮助提示 */
.help-tooltip {
    position: fixed;
    bottom: 70px;
    right: 20px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    z-index: 999;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
}

.help-title {
    font-size: 13px;
    font-weight: 600;
    color: #93c5fd;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-item {
    font-size: 12px;
    color: #94a3b8;
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.help-item kbd {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 11px;
    color: #e2e8f0;
    min-width: 24px;
    text-align: center;
}

.help-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    z-index: 999;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.help-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

/* 时间标签标记线样式 */
.marker-line {
    stroke: #f59e0b;
    stroke-width: 2;
    stroke-dasharray: 5, 5;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .floating-panel {
        width: calc(100vw - 40px);
        max-width: 320px;
    }
    
    .io-grid, .channel-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .name-config-grid {
        grid-template-columns: 1fr;
    }
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Plotly 工具栏样式调整 */
.modebar {
    top: 10px !important;
    right: 350px !important;
}

.modebar-btn {
    color: #94a3b8 !important;
}

.modebar-btn:hover {
    color: #3b82f6 !important;
}

/* 添加时间标签模式指示器 */
.marker-mode-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 24px;
    background: rgba(245, 158, 11, 0.9);
    color: #000;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.marker-mode-indicator.show {
    opacity: 1;
}
