/**
 * 订单详情弹窗样式
 */

/* ========== 弹窗遮罩层（高效能版本 - 无背景） ========== */
.modal-overlay {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* 移除背景色，与chart.html其他弹窗保持一致 */
  z-index: 10100; /* 确保在所有其他内容之上（高于交易面板的10000） */
  align-items: center;
  justify-content: center;
}

/* ========== 弹窗基础（深色主题） ========== */
.order-detail-modal-content {
  position: relative;
  width: 900px;
  max-width: 90vw;
  height: 85vh; /* ⭐ 固定高度，避免切换Tab时跳动 */
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary, #161b22);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color, #30363d);
  z-index: 10101; /* 确保弹窗内容在遮罩之上 */
}

.fill-modal-content {
  position: relative;
  max-width: 1000px;
  max-height: 80vh;
  background: var(--bg-secondary, #161b22);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color, #30363d);
  display: flex;
  flex-direction: column;
  z-index: 10102; /* 成交明細弹窗在订单详情之上 */
}

.fill-modal-content .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #30363d);
  background: var(--bg-primary, #0d1117);
  border-radius: 8px 8px 0 0;
}

.fill-modal-content .modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #c9d1d9);
}

.fill-modal-content .modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary, #8b949e);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
}

.fill-modal-content .modal-close:hover {
  color: var(--text-primary, #c9d1d9);
}

.fill-modal-content .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-secondary, #161b22);
}

.order-detail-modal-content .modal-header {
  flex-shrink: 0; /* ⭐ 头部不收缩 */
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #30363d);
  background: var(--bg-primary, #0d1117);
  border-radius: 8px 8px 0 0;
}

.order-detail-modal-content .modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #c9d1d9);
}

.order-detail-modal-content .modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary, #8b949e);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
}

.order-detail-modal-content .modal-close:hover {
  color: var(--text-primary, #c9d1d9);
}

.order-detail-modal-content .modal-body {
  flex: 1; /* ⭐ 自动填充剩余空间 */
  overflow-y: auto; /* ⭐ 内容区域独立滚动 */
  padding: 20px;
  background: var(--bg-secondary, #161b22);
}

/* 滚动条样式 */
.order-detail-modal-content .modal-body::-webkit-scrollbar {
  width: 6px;
}

.order-detail-modal-content .modal-body::-webkit-scrollbar-track {
  background: var(--bg-primary, #0d1117);
}

.order-detail-modal-content .modal-body::-webkit-scrollbar-thumb {
  background: var(--border-color, #30363d);
  border-radius: 3px;
}

.order-detail-modal-content .modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary, #8b949e);
}

/* ========== Tab 切换导航（深色主题） ========== */
.order-detail-tabs {
  flex-shrink: 0; /* ⭐ Tab栏不收缩 */
  display: flex;
  gap: 0;
  background: var(--bg-primary, #0d1117);
  border-bottom: 1px solid var(--border-color, #30363d);
}

.order-detail-tabs .tab-btn {
  flex: 1;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-color, #30363d);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary, #8b949e);
  transition: all 0.2s;
}

.order-detail-tabs .tab-btn:last-child {
  border-right: none;
}

.order-detail-tabs .tab-btn:hover {
  background: rgba(177, 186, 196, 0.12);
  color: var(--text-primary, #c9d1d9);
}

.order-detail-tabs .tab-btn.active {
  background: var(--bg-secondary, #161b22);
  color: var(--accent-color, #58a6ff);
  border-bottom: 2px solid var(--accent-color, #58a6ff);
}

/* ========== Tab 内容容器 ========== */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ========== 对冲订单标识 ========== */
.hedge-badge {
  display: inline-block;
  margin-left: 12px;
  padding: 4px 12px;
  background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
  color: #333;
  border-radius: 12px;
  font-size: 13px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(255, 165, 0, 0.3);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 2px 4px rgba(255, 165, 0, 0.3);
  }
  50% {
    box-shadow: 0 2px 8px rgba(255, 165, 0, 0.6);
  }
}

.hedge-info-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: rgba(255, 193, 7, 0.1);
  border-left: 3px solid #ffc107;
  border-radius: 6px;
}

.hedge-info-icon {
  font-size: 24px;
  animation: rotate-pulse 3s ease-in-out infinite;
}

@keyframes rotate-pulse {
  0%, 100% {
    transform: rotate(0deg) scale(1);
  }
  25% {
    transform: rotate(-10deg) scale(1.1);
  }
  75% {
    transform: rotate(10deg) scale(1.1);
  }
}

.hedge-info-content {
  flex: 1;
}

.hedge-info-title {
  font-size: 14px;
  font-weight: 600;
  color: #ffc107;
  margin-bottom: 4px;
}

.hedge-info-desc {
  font-size: 13px;
  color: var(--text-secondary, #8b949e);
  line-height: 1.5;
}

/* ========== Section 基础样式（深色主题） ========== */
.order-detail-section {
  background: var(--bg-primary, #0d1117);
  border: 1px solid var(--border-color, #30363d);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
}

.order-detail-section:last-child {
  margin-bottom: 0;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #c9d1d9);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color, #30363d);
}

/* ========== 信息网格（统一使用） ========== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 24px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.info-label {
  color: var(--text-secondary, #8b949e);
  font-weight: 500;
  font-size: 14px;
}

.info-value {
  color: var(--text-primary, #c9d1d9);
  font-weight: 600;
  font-size: 14px;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ========== 内联明细按钮 ========== */
.btn-show-fills-inline {
  padding: 4px 10px;
  background: var(--accent-color, #58a6ff);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-show-fills-inline:hover {
  background: #4493f8;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* ========== 消息提示 ========== */
.pnl-message {
  text-align: center;
  color: var(--text-secondary, #8b949e);
  padding: 20px;
  font-style: italic;
}

.hedge-notice {
  margin-top: 12px;
  padding: 12px;
  background: rgba(33, 150, 243, 0.1);
  border-left: 3px solid #2196f3;
  color: #58a6ff;
  font-size: 13px;
}

/* ========== 保护措施 ========== */
.protection-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.protection-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.protection-label {
  min-width: 100px;
  color: var(--text-secondary, #8b949e);
  font-weight: 500;
  font-size: 14px;
}

.protection-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #30363d);
  border-radius: 4px;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  background: var(--bg-secondary, #161b22);
  color: var(--text-primary, #c9d1d9);
}

.protection-input:focus {
  outline: none;
  border-color: var(--accent-color, #58a6ff);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.1);
}

.protection-value {
  flex: 1;
  color: var(--text-primary, #c9d1d9);
  font-weight: 600;
  font-size: 14px;
  font-family: 'Courier New', monospace;
}

.btn-protection-save {
  padding: 10px 20px;
  background: var(--accent-color, #58a6ff);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-protection-save:hover {
  background: #4493f8;
  transform: translateY(-1px);
}

/* ========== 平仓记录表格 ========== */
.close-history-table {
  overflow-x: auto;
}

.close-history-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.close-history-table th {
  background: rgba(110, 118, 129, 0.1);
  color: var(--text-secondary, #8b949e);
  font-weight: 600;
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border-color, #30363d);
  white-space: nowrap;
}

.close-history-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
  font-family: 'Courier New', monospace;
  color: var(--text-primary, #c9d1d9);
}

.close-history-table tbody tr:hover {
  background: rgba(177, 186, 196, 0.08);
}

.no-records {
  text-align: center;
  color: var(--text-secondary, #8b949e);
  padding: 30px;
  font-style: italic;
}

/* ========== 成交明細按钮（深色主题） ========== */
.btn-show-fills {
  width: 100%;
  padding: 12px;
  background: var(--accent-color, #58a6ff);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  transition: all 0.2s;
}

.btn-show-fills:hover {
  background: #4493f8;
  transform: translateY(-1px);
}

/* ========== 仓位调整 ========== */
.adjustment-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.adjustment-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.adjustment-input-group label {
  min-width: 100px;
  color: var(--text-secondary, #8b949e);
  font-weight: 500;
  font-size: 14px;
}

.adjustment-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border-color, #30363d);
  border-radius: 4px;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  background: var(--bg-secondary, #161b22);
  color: var(--text-primary, #c9d1d9);
}

.adjustment-input:focus {
  outline: none;
  border-color: var(--accent-color, #58a6ff);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.1);
}

/* ⭐ 调整按钮（内联在输入框后面 - 深色主题） */
.order-detail-section .adjustment-input-group .btn-adjust-inline {
  padding: 8px 12px;
  background: var(--accent-color, #58a6ff);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.order-detail-section .adjustment-input-group .btn-adjust-inline:hover {
  background: #4493f8;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.adjustment-hint-text {
  color: var(--text-secondary, #8b949e);
  font-size: 12px;
  margin-left: 112px; /* 对齐输入框 */
}

.adjustment-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* ⭐ 改为3列 */
  gap: 12px;
}

/* ⭐ 仓位调整的按钮样式（深色主题） */
.order-detail-section .adjustment-buttons .btn-adjust {
  padding: 10px 14px;
  background: var(--accent-color, #58a6ff);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.order-detail-section .adjustment-buttons .btn-adjust:hover {
  background: #4493f8;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.order-detail-section .adjustment-buttons .btn-reverse {
  background: #ffa502;
}

.order-detail-section .adjustment-buttons .btn-reverse:hover {
  background: #e69500;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.order-detail-section .adjustment-buttons .btn-close {
  background: var(--red-color, #ef5350);
}

.order-detail-section .adjustment-buttons .btn-close:hover {
  background: #e63946;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.adjustment-tips {
  padding: 12px 16px;
  background: rgba(255, 193, 7, 0.1);
  border-left: 3px solid #ffc107;
  border-radius: 4px;
}

.tip-title {
  font-weight: 600;
  color: #ffc107;
  margin-bottom: 6px;
  font-size: 13px;
}

.tip-item {
  color: var(--text-secondary, #8b949e);
  font-size: 12px;
  line-height: 1.8;
}

/* ========== 成交明細弹窗 ========== */
.fills-table {
  overflow-x: auto;
}

.fills-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.fills-table th {
  background: rgba(110, 118, 129, 0.1);
  color: var(--text-secondary, #8b949e);
  font-weight: 600;
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border-color, #30363d);
  white-space: nowrap;
}

.fills-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
  font-family: 'Courier New', monospace;
  color: var(--text-primary, #c9d1d9);
}

.fills-table tbody tr:hover {
  background: rgba(177, 186, 196, 0.08);
}

.fills-table .total-row {
  background: rgba(110, 118, 129, 0.15);
  font-weight: 600;
}

.fills-table .total-row td {
  border-top: 1px solid var(--border-color, #30363d);
  border-bottom: 1px solid var(--border-color, #30363d);
  padding: 12px 8px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .order-detail-modal-content {
    width: 95%;
    height: 95vh; /* ⭐ 移动端也固定高度 */
    margin: 10px;
  }
  
  .info-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .adjustment-buttons {
    grid-template-columns: 1fr;
  }
  
  .btn-adjust-inline {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .adjustment-hint-text {
    margin-left: 0;
  }
  
  .close-history-table,
  .fills-table {
    font-size: 11px;
  }
  
  .close-history-table th,
  .close-history-table td,
  .fills-table th,
  .fills-table td {
    padding: 6px 4px;
  }
}

/* ========== 滚动条优化（深色主题） ========== */
.order-detail-modal-content::-webkit-scrollbar,
.fills-table::-webkit-scrollbar,
.close-history-table::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.order-detail-modal-content::-webkit-scrollbar-track,
.fills-table::-webkit-scrollbar-track,
.close-history-table::-webkit-scrollbar-track {
  background: var(--bg-primary, #0d1117);
  border-radius: 4px;
}

.order-detail-modal-content::-webkit-scrollbar-thumb,
.fills-table::-webkit-scrollbar-thumb,
.close-history-table::-webkit-scrollbar-thumb {
  background: var(--border-color, #30363d);
  border-radius: 4px;
}

.order-detail-modal-content::-webkit-scrollbar-thumb:hover,
.fills-table::-webkit-scrollbar-thumb:hover,
.close-history-table::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary, #8b949e);
}

/* ========== 🆕 对手订单简化样式（无底色，纯文字） ========== */
.counterparty-simple {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--text-primary, #c9d1d9);
}

.counterparty-simple.clickable {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  color: #58a6ff;
}

.counterparty-simple.clickable:hover {
  color: #1f6feb;
}

/* ========== 🆕 市场快照样式 ========== */
.market-snapshot {
  background: rgba(110, 118, 129, 0.08);
  border: 1px solid var(--border-color, #30363d);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 20px;
}

.market-snapshot .snapshot-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #c9d1d9);
  margin-bottom: 12px;
}

.market-snapshot .snapshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.market-snapshot .snapshot-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.market-snapshot .snapshot-item .label {
  font-size: 12px;
  color: var(--text-secondary, #8b949e);
}

.market-snapshot .snapshot-item .value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #c9d1d9);
  font-family: 'Courier New', monospace;
}

/* ========== 🆕 费用汇总样式 ========== */
.fee-summary {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(110, 118, 129, 0.08);
  border: 1px solid var(--border-color, #30363d);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 20px;
  gap: 16px;
}

.fee-summary .summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.fee-summary .summary-item .label {
  font-size: 11px;
  color: var(--text-secondary, #8b949e);
  text-transform: uppercase;
}

.fee-summary .summary-item .value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary, #c9d1d9);
}

/* ========== 🆕 角色徽章样式 ========== */
.role-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
}

.role-badge.role-taker {
  background: #ff4444;
  color: white;
}

.role-badge.role-maker {
  background: #4ade80;
  color: black;
}

/* 向下兼容（不带role-前缀） */
.role-badge.taker {
  background: #ff4444;
  color: white;
}

.role-badge.maker {
  background: #4ade80;
  color: black;
}

/* ========== 🆕 对手订单ID样式（3种颜色） ========== */
.counterparty-id {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: bold;
  transition: all 0.2s;
}

/* 流动性订单 - 蓝色 */
.counterparty-id[data-type="liquidity"] {
  background: #00d4ff;
  color: #000;
  cursor: pointer;
}

/* 限价订单 - 黄色 */
.counterparty-id[data-type="limit"] {
  background: #fbbf24;
  color: #000;
  cursor: pointer;
}

/* 虚拟订单 - 灰色 */
.counterparty-id[data-type="virtual"] {
  background: #6b7280;
  color: #fff;
  cursor: default;
}

/* 悬停效果（虚拟订单不适用） */
.counterparty-id[data-type="liquidity"]:hover,
.counterparty-id[data-type="limit"]:hover {
  opacity: 0.9;
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 🆕 可点击样式 */
.counterparty-id.clickable {
  cursor: pointer;
  user-select: none;
}

.counterparty-id.clickable:active {
  transform: scale(0.98);
}

/* ========== 响应式优化 ========== */
@media (max-width: 768px) {
  .market-snapshot .snapshot-grid {
    grid-template-columns: 1fr;
  }
  
  .fee-summary {
    flex-direction: column;
    gap: 8px;
  }
  
  .counterparty-id {
    font-size: 10px;
    padding: 3px 6px;
  }
}

