/* 入口控制管理后台样式 */

/* ========== 标签页导航 ========== */
.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  border-radius: 0.5rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #374151;
  background-color: #f3f4f6;
}

.tab-btn.active {
  color: #2563eb;
  background-color: #eff6ff;
}

.tab-btn svg {
  flex-shrink: 0;
}

/* ========== 弹窗 ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background-color: white;
  border-radius: 0.75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-md {
  max-width: 36rem;
}

.modal-lg {
  max-width: 56rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e5e7eb;
  background-color: #f9fafb;
  flex-shrink: 0;
}

.modal-close-x {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  color: #9ca3af;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
}

.modal-close-x:hover {
  color: #4b5563;
  background-color: #f3f4f6;
}

/* ========== 按钮 ========== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: white;
  background-color: #3b82f6;
  border-radius: 0.5rem;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background-color: #2563eb;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  background-color: white;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background-color: #f9fafb;
}

.btn-success {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: white;
  background-color: #22c55e;
  border-radius: 0.5rem;
  transition: all 0.15s ease;
}

.btn-success:hover {
  background-color: #16a34a;
}

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  border: none;
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-edit {
  background-color: #dbeafe;
  color: #1d4ed8;
}

.btn-edit:hover {
  background-color: #bfdbfe;
}

.btn-delete {
  background-color: #fee2e2;
  color: #b91c1c;
}

.btn-delete:hover {
  background-color: #fecaca;
}

.btn-toggle {
  background-color: #f3f4f6;
  color: #374151;
}

.btn-toggle:hover {
  background-color: #e5e7eb;
}

/* ========== 表单 ========== */
.form-section {
  background-color: #f9fafb;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.375rem;
}

.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
  background-color: white;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder {
  color: #9ca3af;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #374151;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  cursor: pointer;
}

.form-checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: #4b5563;
  cursor: pointer;
}

.form-checkbox-inline input[type="checkbox"] {
  width: 0.875rem;
  height: 0.875rem;
  cursor: pointer;
}

/* ========== 卡片 ========== */
.card {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  padding: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.card-title {
  font-weight: 500;
  color: #111827;
}

.card-subtitle {
  font-size: 0.875rem;
  color: #6b7280;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
}

/* ========== 状态标签 ========== */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-enabled {
  background-color: #dcfce7;
  color: #166534;
}

.status-disabled {
  background-color: #f3f4f6;
  color: #6b7280;
}

/* ========== Toast 提示 ========== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  color: white;
  z-index: 100;
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
}

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

.toast.hidden {
  display: none;
}

.toast.success {
  background-color: #22c55e;
}

.toast.error {
  background-color: #ef4444;
}

.toast.info {
  background-color: #3b82f6;
}

/* ========== 配置开关组 ========== */
.config-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.config-group-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.config-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.config-item:last-child {
  border-bottom: none;
}

.config-item-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.config-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
}

.config-checkbox-label input[type="checkbox"] {
  width: 0.875rem;
  height: 0.875rem;
  margin: 0;
  cursor: pointer;
  accent-color: #3b82f6;
}

.config-checkbox-label.deliver-label {
  color: #9ca3af;
  font-size: 0.75rem;
  min-width: 3rem;
}

.config-checkbox-label.value-label {
  color: #374151;
  font-weight: 500;
}

.config-checkbox-label.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.config-checkbox-label.disabled input[type="checkbox"] {
  cursor: not-allowed;
}

/* ========== 人群卡片 ========== */
.audience-card {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  padding: 1rem 1.25rem;
  border-left: 4px solid;
  transition: all 0.15s ease;
}

.audience-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.audience-card.enabled {
  border-left-color: #22c55e;
}

.audience-card.disabled {
  border-left-color: #d1d5db;
  opacity: 0.7;
}

.audience-priority {
  font-size: 0.75rem;
  color: #9ca3af;
  font-weight: 500;
}

.audience-conditions {
  font-size: 0.8125rem;
  color: #6b7280;
  margin-top: 0.5rem;
  line-height: 1.5;
}

/* ========== 设备卡片 ========== */
.device-card {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  padding: 1rem;
  transition: all 0.15s ease;
}

.device-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.device-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  font-size: 0.875rem;
}

.device-info-label {
  color: #6b7280;
}

.device-info-value {
  color: #111827;
  font-weight: 500;
}

/* ========== 匹配类型标签 ========== */
.match-type {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.match-type-whitelist {
  background-color: #f3e8ff;
  color: #7c3aed;
}

.match-type-user_override {
  background-color: #ffedd5;
  color: #ea580c;
}

.match-type-audience {
  background-color: #dbeafe;
  color: #2563eb;
}

.match-type-default {
  background-color: #f3f4f6;
  color: #6b7280;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #6b7280;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
}

.empty-state-desc {
  font-size: 0.875rem;
  color: #9ca3af;
}

/* ========== 加载状态 ========== */
.loading {
  text-align: center;
  padding: 3rem 0;
  color: #6b7280;
}

.loading::after {
  content: '';
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

.loading-placeholder {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* 新的 loading 状态样式 */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.loading-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* 错误状态样式 */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  background-color: #fef2f2;
  border-radius: 0.5rem;
  border: 1px solid #fecaca;
}

.error-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

/* ========== 列表容器样式 ========== */
#audiences-list,
#whitelist-list,
#user-overrides-list,
#devices-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ========== 响应式调整 ========== */
@media (max-width: 640px) {
  .tab-btn span {
    display: none;
  }

  .tab-btn {
    padding: 0.625rem;
  }

  .modal-content {
    margin: 0.5rem;
    max-height: 95vh;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 0.75rem 1rem;
  }

  .grid.grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 640px) {
  .modal-md {
    max-width: 36rem;
  }

  .modal-lg {
    max-width: 56rem;
  }
}

/* ========== 滚动条样式 ========== */
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

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

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

/* ========== 调试页面样式 ========== */

/* 模式切换按钮 */
.debug-mode-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: transparent;
}

.debug-mode-btn:hover {
  color: #374151;
}

.debug-mode-btn.active {
  background: white;
  color: #3b82f6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 设备项样式 */
.debug-device-item:hover {
  transform: translateX(2px);
}

/* 日志项样式 */
.debug-log-item:hover {
  transform: translateX(2px);
}

/* 匹配结果代码块 */
#debug-result pre {
  background: #f8fafc;
  border-radius: 0.375rem;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

/* 列表滚动条 */
#debug-device-list::-webkit-scrollbar,
#debug-log-list::-webkit-scrollbar {
  width: 4px;
}

#debug-device-list::-webkit-scrollbar-track,
#debug-log-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 2px;
}

#debug-device-list::-webkit-scrollbar-thumb,
#debug-log-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 2px;
}

#debug-device-list::-webkit-scrollbar-thumb:hover,
#debug-log-list::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* 响应式调整 */
@media (max-width: 1024px) {
  #tab-debug .grid {
    grid-template-columns: 1fr;
  }

  #tab-debug .lg\:col-span-2 {
    grid-column: span 1;
  }
}
