/* ============================================================
 * 灵音托管引擎自动化工作台 - 操作统计可视化看板 (comp-operation-dashboard.css)
 * 赛博朋克风格，展示今日/昨日/近7天操作日志统计
 * 数据来源：window.TrackerAPI（由 comp-tracker.js 提供）
 * ============================================================ */

/* ===== 页面容器 ===== */
.op-dashboard-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  flex: 1; min-height: 0;
  background: var(--bg-card);
  animation: opSlideUp 0.5s ease-out;
}

@keyframes opSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
 * 顶部筛选栏
 * ============================================================ */
.op-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

/* 数据源筛选下拉 */
.op-source-select-wrap {
  flex-shrink: 0;
}

.op-source-select {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.op-source-select:focus {
  border-color: var(--accent-blue);
}

/* 日期切换按钮组 */
.op-date-group {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border-color);
}

.op-date-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
  z-index: 1;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.op-date-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.op-date-btn.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(6, 182, 212, 0.2));
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.12);
  font-weight: 600;
}

/* 搜索框 */
.op-search-box {
  flex: 1;
  min-width: 180px;
  position: relative;
}

.op-search-box .op-search-input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.op-search-box .op-search-input::placeholder {
  color: var(--text-muted);
}

.op-search-box .op-search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.12);
}

.op-search-box .op-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

/* 导出按钮 */
.op-export-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: linear-gradient(135deg, rgba(34,197,94,0.15), rgba(16,185,129,0.1));
  color: var(--accent-green);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.op-export-btn:hover {
  background: linear-gradient(135deg, rgba(34,197,94,0.25), rgba(16,185,129,0.18));
  border-color: var(--accent-green);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.2);
  transform: translateY(-1px);
}

.op-export-btn:active {
  transform: scale(0.96);
}

.op-export-btn i {
  font-size: 13px;
}

/* 清空按钮 */
.op-clear-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: linear-gradient(135deg, rgba(239,68,68,0.12), rgba(220,38,38,0.08));
  color: var(--accent-red);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.op-clear-btn:hover {
  background: linear-gradient(135deg, rgba(239,68,68,0.22), rgba(220,38,38,0.16));
  border-color: var(--accent-red);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.2);
  transform: translateY(-1px);
}

.op-clear-btn:active {
  transform: scale(0.96);
}

.op-clear-btn i {
  font-size: 13px;
}

/* ============================================================
 * 统计卡片区域
 * ============================================================ */
.op-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.op-stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(0, 217, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

/* 霓虹发光边框 */
.op-stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  padding: 1px;
  background: linear-gradient(135deg, rgba(0,217,255,0.15), rgba(59,130,246,0.05), rgba(139,92,246,0.1));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.op-stat-card:hover {
  border-color: rgba(0, 217, 255, 0.3);
  transform: translateY(-2px);
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.3),
    0 0 16px rgba(0, 217, 255, 0.06),
    inset 0 1px 0 var(--bg-hover);
}

.op-stat-card:hover::before {
  opacity: 1;
}

/* 卡片图标 */
.op-stat-card .op-stat-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: 10px;
}

/* 卡片标签 */
.op-stat-card .op-stat-label {
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 卡片数值 */
.op-stat-card .op-stat-value {
  font-size: 26px;
  font-weight: 700;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  color: var(--accent-cyan);
  line-height: 1.2;
}
}

/* 卡片辅助信息 */
.op-stat-card .op-stat-extra {
  font-size: 11px;
  margin-top: 6px;
  color: var(--text-muted);
}

/* 高频功能TOP5特殊样式 */
.op-stat-card.op-top5-card {
  grid-column: span 2;
}

.op-stat-card.op-top5-card .op-top5-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.op-stat-card.op-top5-card .op-top5-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.op-stat-card.op-top5-card .op-top5-rank {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.op-stat-card.op-top5-card .op-top5-rank.rank-1 {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: var(--text-primary);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.35);
}

.op-stat-card.op-top5-card .op-top5-rank.rank-2 {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: var(--text-primary);
}

.op-stat-card.op-top5-card .op-top5-rank.rank-3 {
  background: linear-gradient(135deg, #b45309, #92400e);
  color: var(--text-primary);
}

.op-stat-card.op-top5-card .op-top5-rank.rank-other {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.op-stat-card.op-top5-card .op-top5-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
}

.op-stat-card.op-top5-card .op-top5-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.op-stat-card.op-top5-card .op-top5-count {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 28px;
  text-align: right;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* ============================================================
 * 日志列表表格区域
 * ============================================================ */
.op-log-panel {
  background: var(--bg-card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(0, 217, 255, 0.1);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
}

/* 表格头部 */
.op-log-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.op-log-header .op-log-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.op-log-header .op-log-title i {
  color: var(--accent-cyan);
  font-size: 14px;
}

.op-log-header .op-log-count {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* 表格容器 */
.op-log-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.op-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.op-log-table thead {
  background: var(--bg-secondary);
}

.op-log-table thead th {
  padding: 10px 16px;
  text-align: left;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  user-select: none;
}

.op-log-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

.op-log-table tbody tr:hover {
  background: rgba(0, 217, 255, 0.03);
}

.op-log-table tbody tr:last-child {
  border-bottom: none;
}

.op-log-table tbody td {
  padding: 10px 16px;
  color: var(--text-secondary);
  vertical-align: middle;
}

/* 时间列 */
.op-log-table .op-col-time {
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.op-log-table .op-col-time .op-log-date {
  color: var(--text-secondary);
  font-weight: 500;
}

/* 功能名称列 */
.op-log-table .op-col-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

/* 操作内容列 */
.op-log-table .op-col-content {
  color: var(--text-secondary);
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 执行结果列 */
.op-log-table .op-col-result {
  white-space: nowrap;
}

.op-result-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.op-result-tag.success {
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.op-result-tag.error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.op-result-tag.unknown {
  background: rgba(139, 164, 199, 0.08);
  color: var(--text-muted);
  border: 1px solid rgba(139, 164, 199, 0.15);
}

/* ============================================================
 * 分页区域
 * ============================================================ */
.op-pagination {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 10px;
  flex-wrap: wrap;
}

.op-pagination .op-page-info {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

.op-pagination .op-page-btns {
  display: flex;
  gap: 6px;
}

.op-page-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  z-index: 1;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.op-page-btn:hover:not(:disabled) {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.op-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.op-page-btn.active-page {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(6, 182, 212, 0.15));
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

/* ============================================================
 * 空状态
 * ============================================================ */
.op-empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.op-empty-state i {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.3;
  display: block;
}

.op-empty-state p {
  font-size: 13px;
}

/* ============================================================
 * 加载骨架屏
 * ============================================================ */
.op-skeleton-row td {
  padding: 12px 16px;
}

.op-skeleton-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(59,130,246,0.08) 25%, rgba(6,182,212,0.12) 50%, rgba(59,130,246,0.08) 75%);
  background-size: 200% 100%;
  animation: opShimmer 1.5s infinite;
}

@keyframes opShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
 * 侧边栏菜单入口（全局共用）
 * ============================================================ */
.op-sidebar-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 44px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  white-space: nowrap;
  position: relative;
}

.op-sidebar-entry:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.op-sidebar-entry.active {
  background: var(--bg-active);
  color: var(--accent-cyan);
}

.op-sidebar-entry.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent-cyan);
  border-radius: 0 2px 2px 0;
}

.op-sidebar-entry i {
  width: 20px;
  font-size: 16px;
  flex-shrink: 0;
  text-align: center;
}

.op-sidebar-entry .op-menu-label {
  margin-left: 10px;
  font-size: 14px;
  flex: 1;
}

.op-sidebar-entry .op-menu-badge {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* ============================================================
 * 响应式样式
 * ============================================================ */

/* 平板横屏 */
@media (max-width: 1024px) {
  .op-dashboard-container {
    padding: 16px;
    gap: 12px;
  }

  .op-stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .op-stat-card.op-top5-card {
    grid-column: span 1;
  }

  .op-stat-card .op-stat-value {
    font-size: 22px;
  }

  .op-log-table .op-col-content {
    max-width: 200px;
  }
}

/* 平板/移动端 */
@media (max-width: 768px) {
  .op-dashboard-container {
    padding: 12px;
    gap: 10px;
  }

  .op-filter-bar {
    padding: 10px 12px;
    gap: 8px;
  }

  .op-source-select-wrap {
    width: 100%;
  }

  .op-source-select {
    width: 100%;
    padding: 8px 10px;
  }

  .op-date-group {
    width: 100%;
    display: flex;
  }

  .op-date-btn {
    flex: 1;
    text-align: center;
    padding: 7px 8px;
  }

  .op-search-box {
    width: 100%;
  }

  .op-export-btn {
    width: 100%;
    justify-content: center;
  }

  .op-clear-btn {
    width: 100%;
    justify-content: center;
  }

  .op-stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .op-stat-card {
    padding: 14px;
  }

  .op-stat-card .op-stat-value {
    font-size: 20px;
  }

  .op-stat-card.op-top5-card {
    grid-column: span 2;
  }

  .op-stat-card.op-top5-card .op-top5-list {
    display: none;
  }

  .op-log-table thead {
    display: none;
  }

  .op-log-table tbody tr {
    display: block;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
  }

  .op-log-table tbody td {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border: none;
  }

  .op-log-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: 8px;
  }

  .op-log-table .op-col-content {
    max-width: none;
    white-space: normal;
  }

  .op-pagination {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .op-pagination .op-page-btns {
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* 小手机 */
@media (max-width: 480px) {
  .op-dashboard-container {
    padding: 10px;
    gap: 8px;
  }

  .op-stats-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .op-stat-card {
    padding: 12px;
  }

  .op-stat-card .op-stat-value {
    font-size: 22px;
  }

  .op-stat-card.op-top5-card {
    grid-column: span 1;
  }

  .op-stat-card.op-top5-card .op-top5-list {
    display: none;
  }

  .op-log-table tbody td {
    font-size: 12px;
  }
}
