/**
 * 通用样式文件 - Common Stylesheet
 * 整合所有页面共同需要的样式
 * 每个页面只需引用此文件即可
 */

/* ==================== 设计系统变量 ==================== */
:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #EFF6FF;
  
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --error: #EF4444;
  --error-light: #FEE2E2;
  --info: #3B82F6;
  --info-light: #DBEAFE;
  
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  
  --white: #FFFFFF;
  --black: #000000;
  
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.05);
  
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 9999;
}

/* ==================== 组件样式 ==================== */
.text-orange-500,
.material-status-processing,
[class*="processing"] .status-icon,
.material-item [class*="processing"] i {
  color: #F97316 !important;
}

.text-blue-600,
.material-status-reviewed,
.material-item [class*="reviewed"] i {
  color: #2563EB !important;
}

.bg-orange-50 {
  background-color: #FFF7ED !important;
}

/* 模态框 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30000;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}

.modal.hidden {
  display: none !important;
}

.modal.fade-out {
  animation: fadeOut 0.2s ease forwards;
}

.modal-content {
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn 0.2s ease;
  position: relative;
}

.confirm-modal {
  background: white;
  text-align: center;
  max-width: 400px;
  width: 100%;
  padding: 1.5rem !important;
}

.confirm-message {
  margin-bottom: 1.5rem;
}

.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.5rem;
}

.confirm-icon.warning {
  background: #FEF3C7;
  color: #F59E0B;
}

.confirm-icon.error {
  background: #FEE2E2;
  color: #EF4444;
}

.confirm-icon.success {
  background: #D1FAE5;
  color: #10B981;
}

.confirm-icon.info {
  background: #DBEAFE;
  color: #3B82F6;
}

/* 加载动画 */
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563EB;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* 聊天样式 */
.chat-history-wechat {
  background: #f5f5f5;
  min-height: calc(100vh - 200px);
  padding: 1rem;
  overflow-y: auto;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-avatar-wechat {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.chat-avatar-wechat img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-bubble-wechat {
  max-width: calc(100% - 55px);
  position: relative;
  word-wrap: break-word;
  word-break: break-all;
  margin-left: 0.75rem;
}

.ai-message-wechat {
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  max-width: calc(100% - 55px);
}

.ai-message-wechat::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid white;
}

.user-message-wechat {
  background: #95ec69;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  max-width: calc(100% - 55px);
}

.user-message-wechat::before {
  content: '';
  position: absolute;
  right: -6px;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid #95ec69;
}

.message-time {
  font-size: 12px;
  color: #999;
  margin-top: 0.5rem;
}

.message-time-wechat {
  font-size: 12px;
  color: #999;
  margin-top: 0.5rem;
}

.chat-message.user-message {
  flex-direction: row-reverse;
  margin-left: 55px;
}

.chat-message.user-message .chat-avatar {
  margin-left: 0.75rem;
}

.chat-message.user-message .message-bubble-wechat {
  margin-left: 0;
  margin-right: 0.75rem;
}

.chat-message.user-message .message-time {
  text-align: right;
}

.input-wrapper-wechat {
  display: flex;
  gap: 0.5rem;
  background: white;
  border-radius: 6px;
  padding: 0.5rem;
  border: 1px solid #e0e0e0;
  transition: border-color 0.2s;
}

.input-wrapper-wechat:focus-within {
  border-color: #95ec69;
}

.input-wrapper-wechat input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: none;
  font-size: 14px;
  outline: none;
  background: transparent;
  color: #333;
}

.input-wrapper-wechat input::placeholder {
  color: #999;
}

.input-wrapper-wechat button {
  background: #95ec69;
  color: #333;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.input-wrapper-wechat button:hover {
  background: #7ed957;
}

.input-wrapper-wechat button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #e0e0e0;
}

/* Toast 提示 */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast-container.hidden {
  display: none !important;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 280px;
}

.toast.hidden {
  display: none !important;
}

.toast.success {
  background: #D1FAE5;
  border: 1px solid #10B981;
  color: #10B981;
}

.toast.error {
  background: #FEE2E2;
  border: 1px solid #EF4444;
  color: #EF4444;
}

.toast.warning {
  background: #FEF3C7;
  border: 1px solid #F59E0B;
  color: #F59E0B;
}

.toast.info {
  background: #DBEAFE;
  border: 1px solid #3B82F6;
  color: #3B82F6;
}

.toast-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.125rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.toast-close:hover {
  opacity: 1;
}

/* 滚动条样式 */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 9999px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #9CA3AF;
  border-radius: 9999px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #2563EB;
}

/* ==================== 工具类样式 ==================== */
@layer utilities {
  .content-auto {
    content-visibility: auto;
  }
}

.table-container {
  max-height: 60vh;
  overflow-y: auto;
}

/* 底部导航菜单样式 */
@media (max-width: 640px) {
  nav[data-menu-container] {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  nav[data-menu-container] .justify-center {
    gap: 0.5rem;
  }
  
  nav[data-menu-container] > div > div[id$="Menu"] {
    left: 0;
    transform: none;
  }
}

.group:hover .group-hover\:flex {
  display: flex !important;
}

.group\/sub:hover .group-hover\/sub\:flex {
  display: flex !important;
}

/* ==================== 动画 ==================== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

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

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ==================== 响应式 ==================== */
@media (max-width: 767px) {
  .toast {
    min-width: auto;
    max-width: calc(100vw - 2rem);
  }
}
