/* lonlontwo_gpt_databox - 深色主題管理後台 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* 深色主題配色 */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --bg-tertiary: #333333;
  --bg-hover: #3a3a3a;

  /* 橘色主題色 */
  --accent-orange: #ff6b35;
  --accent-orange-hover: #ff8555;
  --accent-orange-light: rgba(255, 107, 53, 0.1);

  /* 文字顏色 */
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #808080;

  /* 邊框 */
  --border-color: #404040;

  /* 狀態色 */
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #ef4444;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Microsoft JhengHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* 容器 */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* 頂部導航 */
.header {
  background: var(--bg-secondary);
  padding: 20px 30px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 30px;
}

.header h1 {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.header .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 標籤頁 */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0;
}

.tab {
  padding: 12px 24px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab.active {
  color: var(--accent-orange);
  border-bottom-color: var(--accent-orange);
}

/* 表單區域 */
.form-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 25px;
  margin-bottom: 20px;
}

.form-section h3 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-orange);
  background: var(--bg-secondary);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
  font-family: 'Consolas', 'Monaco', monospace;
}

/* 按鈕 */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-primary {
  background: var(--accent-orange);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-orange-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-block {
  width: 100%;
}

/* 列表項目 */
.item-list {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}

.item:last-child {
  border-bottom: none;
}

.item:hover {
  background: var(--bg-hover);
}

.item-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-right: 15px;
}

.item-content {
  flex: 1;
}

.item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.item-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.item-badge {
  display: inline-block;
  padding: 4px 10px;
  background: var(--accent-orange-light);
  color: var(--accent-orange);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
}

.item-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* 切換開關 */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.3s;
  border: 1px solid var(--border-color);
}

.toggle.active {
  background: var(--success);
  border-color: var(--success);
}

.toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}

.toggle.active::after {
  transform: translateX(20px);
}

/* 模式卡片 */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.mode-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-card:hover {
  border-color: var(--accent-orange);
  transform: translateY(-2px);
}

.mode-card.active {
  border-color: var(--accent-orange);
  background: var(--accent-orange-light);
}

.mode-card-header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.mode-icon {
  font-size: 28px;
  margin-right: 12px;
}

.mode-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.mode-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 15px;
  line-height: 1.5;
}

.mode-stats {
  display: flex;
  gap: 15px;
  font-size: 12px;
  color: var(--text-muted);
}

/* 知識庫列表 */
.knowledge-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.knowledge-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.knowledge-info {
  flex: 1;
}

.knowledge-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.knowledge-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.knowledge-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  font-size: 11px;
  margin-right: 5px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal h2 {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 25px;
  color: var(--text-primary);
}

/* 儲存空間卡片 */
.storage-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
}

.storage-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
}

.storage-header {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.storage-icon {
  font-size: 24px;
  margin-right: 10px;
}

.storage-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.storage-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.storage-used {
  height: 100%;
  background: var(--accent-orange);
  transition: width 0.3s;
}

.storage-text {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 上傳區域 */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 20px;
}

.upload-zone:hover {
  border-color: var(--accent-orange);
  background: var(--accent-orange-light);
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.upload-zone p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 5px;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* 進度條 */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: var(--accent-orange);
  transition: width 0.3s;
}

/* 響應式 */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }

  .modal-content {
    width: 95%;
    padding: 20px;
  }

  .roles-grid {
    grid-template-columns: 1fr;
  }
}

/* 滾動條樣式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bg-hover);
}

/* ============================================ */
/* 角色卡片系統 */
/* ============================================ */

.roles-section {
  margin-bottom: 30px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
}

.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
}

/* 角色卡片 */
.role-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.3s;
}

.role-card.active {
  border-color: var(--accent-orange);
  box-shadow: 0 0 20px rgba(255, 107, 53, 0.2);
}

.role-card:hover {
  transform: translateY(-2px);
}

/* 角色卡片頭部 */
.role-header {
  display: flex;
  align-items: flex-start;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.role-checkbox {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  cursor: pointer;
  margin-top: 5px;
}

.role-icon {
  font-size: 32px;
  margin-right: 12px;
}

.role-info {
  flex: 1;
}

.role-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.role-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.role-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.role-tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

.role-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  background: var(--accent-orange-light);
  color: var(--accent-orange);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

/* 知識連結列表 */
.knowledge-section {
  margin: 15px 0;
}

.knowledge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.knowledge-header h4 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.knowledge-count {
  font-size: 12px;
  color: var(--text-muted);
}

.knowledge-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.knowledge-item {
  display: flex;
  align-items: center;
  padding: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.knowledge-item:hover {
  background: var(--bg-hover);
}

.knowledge-item-checkbox {
  width: 16px;
  height: 16px;
  margin-right: 10px;
  cursor: pointer;
}

.knowledge-item-icon {
  font-size: 18px;
  margin-right: 10px;
}

.knowledge-item-info {
  flex: 1;
  min-width: 0;
}

.knowledge-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.knowledge-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.knowledge-item-actions {
  display: flex;
  gap: 5px;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-add-knowledge {
  width: 100%;
  padding: 8px;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 15px;
}

.btn-add-knowledge:hover {
  border-color: var(--accent-orange);
  color: var(--accent-orange);
  background: var(--accent-orange-light);
}

/* 角色卡片底部操作 */
.role-actions {
  display: flex;
  gap: 8px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

.role-actions .btn {
  flex: 1;
  padding: 8px 16px;
  font-size: 13px;
}

/* 空狀態 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 15px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* 載入動畫 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 提示訊息 */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}