/* ===== 全局样式 ===== */
:root {
  --primary: #4f6ef7;
  --primary-dark: #3b5bdb;
  --primary-light: #eef1ff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.05);
  --radius: 10px;
  --radius-sm: 6px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ===== 管理后台布局 ===== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 0 24px 24px;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
}

.sidebar-menu {
  list-style: none;
}

.sidebar-menu li {
  margin: 2px 12px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.2s;
  cursor: pointer;
}

.sidebar-menu a:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-menu a.active {
  background: var(--primary);
  color: white;
}

.sidebar-menu a .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 24px 32px;
  max-width: calc(100vw - 240px);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #d1d5db;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
}

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

/* ===== 表格 ===== */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  background: #f9fafb;
}

tr:hover {
  background: #f9fafb;
}

/* ===== 标签 ===== */
.tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  margin: 2px;
}

.tag-default {
  background: var(--success);
  color: white;
}

.tag-delete {
  cursor: pointer;
  margin-left: 4px;
  opacity: 0.6;
}

.tag-delete:hover {
  opacity: 1;
}

/* ===== 模态框 ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 560px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ===== 提示消息 ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  z-index: 2000;
  animation: slideIn 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

@keyframes slideIn {
  from { transform: translateX(400px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* ===== 播放器页面样式 ===== */
.player-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.player-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
}

.player-header {
  padding: 16px 24px;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
}

.player-header .title {
  font-size: 18px;
  font-weight: 600;
}

.player-header .link-btn {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.player-header .link-btn:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.video-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.video-container video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 语音识别状态栏 */
.speech-bar {
  padding: 10px 24px;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 16px;
  color: white;
}

.speech-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.speech-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6b7280;
  transition: all 0.3s;
}

.speech-dot.listening {
  background: var(--success);
  animation: pulse 1.5s infinite;
}

.speech-dot.error {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

.speech-text {
  flex: 1;
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  min-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speech-text .interim {
  color: rgba(255,255,255,0.4);
}

.speech-toggle {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.speech-toggle:hover {
  background: rgba(255,255,255,0.25);
}

/* 关键词命中提示 */
.keyword-alert {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
  animation: slideDown 0.3s ease;
  display: none;
}

.keyword-alert.show {
  display: block;
}

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

/* AI 对话面板 */
.chat-panel {
  width: 400px;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  transition: transform 0.3s ease;
}

.chat-panel.hidden {
  transform: translateX(100%);
  width: 0;
  border-left: none;
}

.chat-header {
  padding: 16px 20px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-close {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  align-self: flex-start;
  background: #f3f4f6;
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-message.system {
  align-self: center;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 13px;
  text-align: center;
}

.chat-typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: #f3f4f6;
  border-radius: 12px;
  display: flex;
  gap: 4px;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
}

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}

.chat-input-area input:focus {
  border-color: var(--primary);
}

.chat-send-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.chat-send-btn:hover {
  background: var(--primary-dark);
}

.chat-send-btn:disabled {
  opacity: 0.5;
}

/* 浮动按钮 - 打开聊天 */
.chat-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.chat-fab:hover {
  transform: scale(1.1);
  background: var(--primary-dark);
}

.chat-fab.hidden {
  display: none;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

/* ===== 开关组件 ===== */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}

.switch-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.switch input:checked + .switch-slider {
  background: var(--primary);
}

.switch input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* ===== 配置提示 ===== */
.config-hint {
  padding: 12px 16px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #92400e;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.config-hint.info {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }
  .sidebar-logo span {
    display: none;
  }
  .sidebar-menu a span:not(.icon) {
    display: none;
  }
  .main-content {
    margin-left: 60px;
  }
  .chat-panel {
    width: 100%;
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    z-index: 100;
  }
}
