/* ========================================
   CloudBase Admin - Bootstrap 5 Theme
   主色: #6c5ce7 (紫) / #a29bfe (浅紫)
   ======================================== */

/* ---- 主题色覆盖 ---- */
:root {
  --bs-primary: #6c5ce7;
  --bs-primary-rgb: 108, 92, 231;
  --cb-purple: #6c5ce7;
  --cb-purple-light: #a29bfe;
  --cb-radius: 14px;
  --cb-shadow: 0 8px 30px rgba(108,92,231,.08);
  --cb-shadow-hover: 0 12px 40px rgba(108,92,231,.15);
}
.btn-primary { --bs-btn-bg: #6c5ce7; --bs-btn-border-color: #6c5ce7; --bs-btn-hover-bg: #5b4de0; --bs-btn-hover-border-color: #5b4de0; --bs-btn-active-bg: #5b4de0; --bs-btn-active-border-color: #5b4de0; }
.text-primary, .link-primary { color: #6c5ce7 !important; }
.btn-outline-primary { --bs-btn-color: #6c5ce7; --bs-btn-border-color: #6c5ce7; --bs-btn-hover-bg: #6c5ce7; --bs-btn-hover-border-color: #6c5ce7; }
.form-check-input:checked { background-color: #6c5ce7; border-color: #6c5ce7; }
a { color: #6c5ce7; }

/* ---- 全局字号（16px -> 14px） ---- */
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: -apple-system, 'Segoe UI', system-ui, sans-serif; background: #f5f6fa; }

/* ---- 页面切换 ---- */
.page { display: none !important; }
.page.active { display: flex !important; width: 100%; }
#page-login.active { align-items: center; justify-content: center; min-height: 100vh; }

/* ---- 登录页 ---- */
#page-login {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #4b3b8f 0%, #6c5ce7 45%, #a29bfe 100%);
}
#page-login .login-card {
  backdrop-filter: blur(20px);
  background: rgba(255,255,255,.97);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: loginFadeIn .5s ease;
}
#page-login .login-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  box-shadow: 0 6px 18px rgba(108,92,231,.35);
}
#page-login .login-icon-wrap i {
  font-size: 1.8rem;
  color: #fff;
}
#page-login .login-input-group .input-group-text {
  background: #f1f2f6;
  border: 1px solid #e2e4ea;
  border-right: none;
  color: #9aa0b4;
}
#page-login .login-input-group .form-control {
  border: 1px solid #e2e4ea;
  border-left: none;
  padding: .55rem .85rem;
}
#page-login .login-input-group .form-control::placeholder { color: #b0b4c5; }
#page-login .login-input-group .form-control:focus {
  border-color: #6c5ce7;
  box-shadow: none;
}
#page-login .login-input-group:focus-within .input-group-text {
  border-color: #6c5ce7;
  color: #6c5ce7;
}
#page-login #login-btn {
  border: none;
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  box-shadow: 0 4px 14px rgba(108,92,231,.35);
  letter-spacing: 2px;
}
#page-login #login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(108,92,231,.45);
}

/* 登录页浮动光球 */
.login-bg-orbs { position: absolute; inset: 0; pointer-events: none; }
.login-bg-orbs span {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: .35;
}
.login-bg-orbs span:nth-child(1) {
  width: 280px; height: 280px; top: -80px; left: -60px;
  background: #a29bfe; animation: orbFloat1 8s ease-in-out infinite;
}
.login-bg-orbs span:nth-child(2) {
  width: 220px; height: 220px; bottom: -60px; right: -40px;
  background: #6c5ce7; animation: orbFloat2 10s ease-in-out infinite;
}
.login-bg-orbs span:nth-child(3) {
  width: 180px; height: 180px; top: 40%; right: 15%;
  background: #dfe6e9; opacity: .2; animation: orbFloat1 12s ease-in-out infinite;
}
@keyframes loginFadeIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes orbFloat1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(20px,-30px); } }
@keyframes orbFloat2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-25px,20px); } }

/* ---- 侧边栏 ---- */
.sidebar {
  background: linear-gradient(180deg, #2d2640 0%, #1e1e2d 50%, #1a1a2e 100%) !important;
  box-shadow: 4px 0 24px rgba(0,0,0,.2);
  border-right: 1px solid rgba(108,92,231,.15);
  width: 230px;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1030;
  transition: transform .3s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; }
.sidebar-brand-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  box-shadow: 0 4px 12px rgba(108,92,231,.4); flex-shrink: 0;
}
.sidebar-brand-icon i { font-size: 1.3rem; color: #fff; }
.sidebar-brand h6 { font-weight: 700; margin: 0; line-height: 1.2; color: #fff; }
.sidebar-brand small { color: rgba(255,255,255,.45); font-size: .7rem; }
.sidebar .sidebar-header i { font-size: 1.5rem; }
.sidebar .nav-link {
  border-radius: 10px;
  margin: 2px 6px;
  padding: .5rem .85rem;
  transition: all .25s ease;
  font-size: .85rem;
  color: rgba(255,255,255,.55) !important;
  white-space: nowrap;
}
.sidebar .nav-link i { font-size: .95rem; width: 1.1rem; text-align: center; }
.sidebar .nav-link:hover {
  background: rgba(108,92,231,.15);
  color: #fff !important;
  transform: translateX(3px);
}
.sidebar .nav-link.active {
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%) !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(108,92,231,.4);
  font-weight: 600;
}
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.08) !important; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,.08); margin: .5rem .85rem; }

/* 移动端遮罩 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1029;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ---- 布局 ---- */
.app-layout { position: relative; }

/* ---- 响应式：>= lg 侧边栏常驻，主内容左偏移 ---- */
@media (min-width: 992px) {
  .app-main { margin-left: 230px; }
  .sidebar-overlay { display: none !important; }
  .sidebar { transform: translateX(0) !important; }
}
/* ---- 响应式：< lg 侧边栏收起，点击展开 ---- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex !important; }
}

/* ---- 顶部 header ---- */
.app-header {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(108,92,231,.1);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header .header-title { display: flex; align-items: center; gap: .5rem; }
.app-header .header-title::before {
  content: ''; width: 4px; height: 1.1rem; border-radius: 2px;
  background: linear-gradient(180deg, #6c5ce7, #a29bfe);
}

/* ---- 主内容区背景 ---- */
.app-main { background: #f5f6fa; min-width: 0; flex: 1 1 auto; width: calc(100% - 230px); max-width: calc(100% - 230px); }
.app-main #page-content { max-width: 100%; margin: 0; }
#page-content .row > [class*="col-"] { display: flex; }
#page-content .row > [class*="col-"] > .card { width: 100%; }
#page-content .row > .col-md-7 > .card,
#page-content .row > .col-md-5 > .card { height: auto; }

/* ---- 页面标题 ---- */
.page-header { background: linear-gradient(to right, #fff, #f8f9fc); }

/* ---- 统计卡片 ---- */
.stat-card {
  transition: all .3s ease;
  border: none;
  border-radius: var(--cb-radius);
  position: relative;
  overflow: visible;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #6c5ce7, #a29bfe);
  opacity: 0; transition: opacity .3s;
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--cb-shadow-hover); }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -.5px; color: #2d2640; }
.stat-card .stat-label { font-size: .72rem; color: #9aa0b4; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }

/* ---- 卡片 ---- */
.card {
  border: none;
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  transition: box-shadow .3s ease, transform .3s ease;
  height: 100%;
  overflow: visible;
}
.card:hover { box-shadow: var(--cb-shadow-hover); }
.card-header {
  background: transparent;
  border-bottom: 1px solid rgba(108,92,231,.08);
  font-weight: 600;
  padding: .75rem 1.1rem;
  font-size: .9rem;
}

/* ---- 表格 ---- */
.table { --bs-table-hover-bg: rgba(108,92,231,.04); margin-bottom: 0; }
.table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: #9aa0b4; font-weight: 600; border-bottom: 1px solid rgba(108,92,231,.1) !important; padding: .6rem .85rem; }
.table td { vertical-align: middle; padding: .55rem .85rem; font-size: .85rem; border-color: rgba(0,0,0,.04); white-space: nowrap; }
.table tbody tr { transition: background .15s; }

/* ---- 空状态 ---- */
.empty { text-align: center; padding: 3rem 0; color: #b0b4c5; }
.empty i { color: #d5d8e0; }

/* ---- 按钮 ---- */
.btn { border-radius: 8px; font-weight: 500; transition: all .2s; }
.btn-sm { border-radius: 6px; font-size: .78rem; }
.btn-primary { background: linear-gradient(135deg, #6c5ce7 0%, #7d6ff0 100%); border: none; box-shadow: 0 3px 10px rgba(108,92,231,.3); }
.btn-primary:hover { box-shadow: 0 5px 18px rgba(108,92,231,.4); transform: translateY(-1px); background: linear-gradient(135deg, #5b4de0 0%, #6c5ce7 100%); }
.btn-outline-primary { border-color: #6c5ce7; color: #6c5ce7; }
.btn-outline-primary:hover { background: #6c5ce7; border-color: #6c5ce7; }
.btn-outline-secondary { color: #8a8fa3; border-color: #e2e4ea; }
.btn-outline-secondary:hover { background: #f1f2f6; border-color: #d5d8e0; color: #6c5ce7; }
.btn-outline-danger { color: #e74c5c; border-color: #f0c8cc; }
.btn-outline-danger:hover { background: #e74c5c; border-color: #e74c5c; }

/* ---- 表单 ---- */
.form-control, .form-select { border-radius: 8px; border-color: #e2e4ea; transition: border-color .2s, box-shadow .2s; font-size: .85rem; }
.form-control:focus, .form-select:focus { border-color: #6c5ce7; box-shadow: 0 0 0 3px rgba(108,92,231,.12); }
.form-control::placeholder { color: #b0b4c5; }
.input-group-text { background: #f5f6fa; border-color: #e2e4ea; color: #9aa0b4; font-size: .85rem; }
.form-label { font-size: .8rem; font-weight: 500; color: #6c5e7a; margin-bottom: .3rem; }

/* ---- JSON 高亮 ---- */
.json-key   { color: #6c5ce7; font-weight: 500; }
.json-string{ color: #0a3069; }
.json-number{ color: #e17055; }
.json-bool  { color: #00b894; }
.json-null  { color: #9aa0b4; }

/* ---- JSON 结果视图（深色终端风） ---- */
.json-view {
  background: #2d2640;
  border: 1px solid rgba(108,92,231,.2);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: .8rem;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
  line-height: 1.7;
  color: #dfe6e9;
}
.json-view .json-key { color: #a29bfe; }
.json-view .json-string { color: #55efc4; }
.json-view .json-number { color: #ffeaa7; }
.json-view .json-bool { color: #fab1a0; }
.json-view .json-null { color: #636e72; }

/* ---- AI / Agent 聊天 ---- */
.chat-area { display: flex; flex-direction: column; height: calc(100vh - 120px); overflow: hidden; }
.chat-area .card-header { border-bottom: 1px solid rgba(108,92,231,.08); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1.1rem;
  background: #f5f6fa;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(108,92,231,.2); border-radius: 3px; }

.chat-msg {
  margin-bottom: .75rem; padding: .65rem 1rem;
  border-radius: 14px; max-width: 78%; line-height: 1.6;
  font-size: .85rem; animation: fadeInUp .3s ease;
}
.chat-msg.user {
  margin-left: auto;
  background: linear-gradient(135deg, #6c5ce7 0%, #7d6ff0 100%);
  color: #fff; box-shadow: 0 3px 12px rgba(108,92,231,.25);
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.05);
  border-bottom-left-radius: 4px;
}
.chat-input-area {
  display: flex; gap: .5rem; margin-top: .6rem;
  padding: .75rem .25rem 0;
  border-top: 1px solid rgba(108,92,231,.08);
}
.chat-input-area textarea {
  flex: 1; border-radius: 10px; padding: .55rem .8rem; resize: none;
  border: 1px solid #e2e4ea; font-size: .85rem; transition: border-color .2s;
}
.chat-input-area textarea:focus { border-color: #6c5ce7; outline: none; box-shadow: 0 0 0 3px rgba(108,92,231,.1); }

/* ---- 动画 ---- */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

/* ---- 存储上传拖拽 ---- */
.upload-zone {
  border: 2px dashed #dee2e6;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all .25s ease;
  background: var(--bs-light);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), .05);
  box-shadow: inset 0 0 0 1px rgba(var(--bs-primary-rgb),.1);
}

/* ---- 右击菜单 / badge 美化 ---- */
.badge {
  font-weight: 500;
  font-size: .75rem;
  padding: .35em .65em;
  border-radius: 6px;
}

/* ---- 滚动条 ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.2); }
