/* public/css/style.css */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Microsoft YaHei', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 10px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

h1 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
}

h2 {
  color: #555;
  margin-bottom: 15px;
  border-left: 4px solid #667eea;
  padding-left: 10px;
}

section {
  margin-bottom: 30px;
  padding: 20px;
  background: #f9f9f9;
  border-radius: 8px;
}

.collector-form, .query-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.input {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.btn-success { background: #28a745; color: white; }
.btn-danger { background: #dc3545; color: white; }
.btn-primary { background: #007bff; color: white; }
.btn-info { background: #17a2b8; color: white; }

.status-box {
  padding: 15px;
  background: #e9ecef;
  border-radius: 5px;
  white-space: pre-wrap;
  font-family: monospace;
}

.danmu-container {
  max-height: 400px;
  overflow-y: auto;
  background: #000;
  color: #0f0;
  padding: 15px;
  border-radius: 5px;
  font-family: monospace;
}

.danmu-item {
  padding: 5px 0;
  border-bottom: 1px solid #333;
  animation: fadeIn 0.3s;
}

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

.danmu-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.danmu-table th, .danmu-table td {
  padding: 10px;
  border: 1px solid #ddd;
  text-align: left;
}

.danmu-table th {
  background: #667eea;
  color: white;
}

.danmu-table tr:nth-child(even) {
  background: #f2f2f2;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.pagination-total {
  margin-right: 16px;
  color: #666;
  font-size: 14px;
}

.pagination-current {
  padding: 8px 16px;
  font-weight: bold;
  color: #667eea;
  font-size: 14px;
  background: #f0f0ff;
  border-radius: 4px;
  min-width: 80px;
  text-align: center;
}

.btn-pagination {
  padding: 8px 16px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-pagination:hover:not(:disabled) {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

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

.loading-row {
  text-align: center;
  padding: 20px;
  color: #667eea;
  font-size: 15px;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 日期选择器 */
.date-picker-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.date-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.date-btn {
  padding: 5px 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  white-space: nowrap;
}

.date-btn:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.date-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.toggle-btn {
  color: #667eea;
  border-color: #667eea;
}

.date-range-display {
  font-size: 13px;
  color: #666;
  padding: 2px 0;
}

.more-date-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.more-date-panel.show {
  display: block;
}

.more-date-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.more-date-row span {
  font-size: 13px;
  color: #888;
  min-width: 28px;
}

.more-date-row .date-btn {
  padding: 4px 10px;
  font-size: 12px;
}

.more-date-divider {
  justify-content: center;
  color: #ccc;
  margin: 4px 0;
}

.custom-date {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.input-date {
  padding: 4px 8px;
  width: 120px;
  font-size: 12px;
}

/* 房间监控 tab 布局 */
.monitor-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.monitor-section {
  padding: 20px;
  background: #f9f9f9;
  border-radius: 8px;
}

.section-desc {
  color: #888;
  font-size: 13px;
  margin: -5px 0 15px 0;
}

/* 房间列表 */

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
}
.status-running {
  background: #28a745;
  color: white;
}
.status-stopped {
  background: #6c757d;
  color: white;
}

/* Tab 导航 */
.tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
  border-bottom: 2px solid #ddd;
}

.tab-btn {
  padding: 12px 24px;
  border: none;
  background: #f0f0f0;
  cursor: pointer;
  font-size: 15px;
  border-radius: 8px 8px 0 0;
  transition: all 0.3s;
}

.tab-btn:hover {
  background: #e0e0e0;
}

.tab-btn.active {
  background: #667eea;
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* 测试采集按钮 */
.btn-warning {
  background: #ffc107;
  color: #333;
}

.btn-warning:hover {
  background: #e0a800;
}

/* 模态框 */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 10px;
  width: 80%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #ddd;
}

.modal-header h3 {
  margin: 0;
  color: #333;
}

.preview-count {
  font-size: 14px;
  color: #666;
}

.preview-danmu-container {
  flex: 1;
  overflow-y: auto;
  background: #000;
  color: #0f0;
  padding: 15px;
  font-family: monospace;
  min-height: 300px;
  max-height: 50vh;
}

.preview-danmu-container .danmu-item {
  padding: 5px 0;
  border-bottom: 1px solid #333;
  animation: fadeIn 0.3s;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  border-top: 1px solid #ddd;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success { background: #28a745; }
.toast-error { background: #dc3545; }
.toast-info { background: #007bff; }

/* 按钮加载动画 */
.btn { position: relative; }
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}
.btn.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* 移动端优化 */
@media (max-width: 768px) {
  /* 隐藏用户ID和房间号列 */
  .danmu-table th:nth-child(1),
  .danmu-table td:nth-child(1),
  .danmu-table th:nth-child(4),
  .danmu-table td:nth-child(4) {
    display: none;
  }

  /* 昵称列强制每个字换行 */
  .danmu-table th:nth-child(2),
  .danmu-table td:nth-child(2) {
    max-width: 3em;
    word-break: break-all;
    white-space: normal;
    font-size: 12px;
    padding-right: 10px;
  }

  .container {
    padding: 15px;
  }

  .query-form {
    flex-direction: column;
  }

  .input {
    width: 100%;
  }

  .date-picker-wrapper {
    width: 100%;
  }

  .date-buttons {
    gap: 4px;
  }

  .date-btn {
    padding: 4px 8px;
    font-size: 12px;
  }

  .more-date-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    max-height: 60vh;
    overflow-y: auto;
  }

  .collector-form {
    flex-direction: column;
  }
}

/* 消息记录样式 */
.chat-panel {
  padding: 20px;
  background: #fff;
}

.chat-filter {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.input-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  min-width: 150px;
}

.btn-sort {
  padding: 8px 16px;
  border: 1px solid #667eea;
  background: white;
  color: #667eea;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-sort:hover {
  background: #667eea;
  color: white;
}

.chat-container {
  max-height: 70vh;
  overflow-y: auto;
  padding: 10px;
  background: #fafafa;
  border-radius: 8px;
}

.chat-divider {
  text-align: center;
  color: #999;
  font-size: 12px;
  margin: 15px 0;
  position: relative;
}

.chat-divider::before,
.chat-divider::after {
  content: '';
  display: inline-block;
  width: 30%;
  height: 1px;
  background: #eee;
  vertical-align: middle;
  margin: 0 10px;
}

.chat-message {
  margin-bottom: 8px;
  padding: 4px 0;
  line-height: 1.5;
}

.chat-username {
  color: #667eea;
  font-weight: bold;
  white-space: nowrap;
  margin-right: 5px;
}

.chat-text {
  color: #333;
  word-break: break-word;
}

.load-more-btn {
  text-align: center;
  padding: 15px;
  color: #667eea;
  cursor: pointer;
  font-size: 14px;
  border-top: 1px solid #eee;
  transition: background 0.2s;
  position: relative;
}

.load-more-btn:hover {
  background: #f0f0ff;
}

.load-more-btn.loading {
  color: #999;
  cursor: wait;
}

.load-more-btn.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid rgba(102, 126, 234, 0.3);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  vertical-align: middle;
}

.load-more-btn.disabled {
  color: #ccc;
  cursor: default;
  pointer-events: none;
}

/* 移动端适配消息记录 */
@media (max-width: 768px) {
  .chat-filter {
    flex-direction: column;
    align-items: stretch;
  }
  .input-select {
    width: 100%;
  }
}
