/* OpenClaw shell: unified dark chrome, sticky nav, drawers, responsive */

:root {
  --oc-chrome-bg: #14213d;
  --oc-chrome-fg: #f8fafc;
  --oc-chrome-muted: #9db0c9;
  --oc-chrome-active: rgba(255, 255, 255, 0.14);
  --oc-chrome-border: rgba(255, 255, 255, 0.12);
  --oc-topbar-h: 66px;
  --oc-accent: #07c160;
}

html, body.oc-shell {
  height: 100%;
  overflow: hidden;
}

body.oc-shell {
  margin: 0;
  background: var(--app-bg, #f4f7fb);
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--app-bg, #f4f7fb);
}

/* Topbar + sidebar: same dark blue */
.app-shell .app-topbar {
  flex: 0 0 var(--oc-topbar-h);
  height: var(--oc-topbar-h);
  background: var(--oc-chrome-bg) !important;
  color: var(--oc-chrome-fg) !important;
  border-bottom: 1px solid var(--oc-chrome-border) !important;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.22);
  position: relative;
  z-index: 1040;
}

.app-shell .app-topbar .brand-name,
.app-shell .app-topbar .user-copy strong,
.app-shell .app-topbar .user-menu-button {
  color: var(--oc-chrome-fg) !important;
}

.app-shell .app-topbar .brand-copy span,
.app-shell .app-topbar .user-copy small,
.app-shell .app-topbar .user-menu-button::after {
  color: var(--oc-chrome-muted) !important;
}

.app-shell .sidebar-toggle {
  border: 1px solid var(--oc-chrome-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--oc-chrome-fg);
  border-radius: 10px;
  cursor: pointer;
}

.app-shell .sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.16);
}

.brand-mark-wechat,
.login-mark.brand-mark-wechat {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--oc-accent);
  color: #fff !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  text-decoration: none;
}

.brand-mark-wechat:hover {
  color: #fff !important;
  filter: brightness(1.05);
}

.user-avatar {
  background: rgba(7, 193, 96, 0.18) !important;
  color: #86efac !important;
  font-size: 18px;
}

.user-menu-button {
  gap: 10px;
  padding: 4px 8px;
  border-radius: 10px;
}

.user-menu-button:hover,
.user-menu-button.show {
  background: rgba(255, 255, 255, 0.08) !important;
}

.user-dropdown-menu {
  min-width: 180px;
  border-radius: 10px;
  padding: 6px;
}

.user-dropdown-menu .dropdown-item {
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}

.user-dropdown-menu .dropdown-item i {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.app-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
  position: relative;
}

.app-shell .app-sidebar {
  flex: 0 0 244px;
  width: 244px;
  max-width: 244px;
  height: 100%;
  min-height: 0;
  background: var(--oc-chrome-bg) !important;
  color: var(--oc-chrome-fg) !important;
  border-right: 1px solid var(--oc-chrome-border) !important;
  padding: 0;
  overflow: hidden;
  position: relative;
  z-index: 1030;
  transition: width .2s ease, flex-basis .2s ease, transform .2s ease, max-width .2s ease;
}

.app-sidebar-inner {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 14px 12px 24px;
  -webkit-overflow-scrolling: touch;
}

.app-shell .sidebar-label {
  color: var(--oc-chrome-muted) !important;
}

.app-shell .sidebar-divider {
  list-style: none;
  margin: 14px 10px 8px;
  padding: 8px 4px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  text-align: center;
  line-height: 1.2;
  pointer-events: none;
  user-select: none;
}

.app-shell .sidebar-divider span {
  display: inline-block;
  color: var(--oc-chrome-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

body.sidebar-collapsed .app-shell .sidebar-divider {
  margin: 10px 6px;
  padding: 6px 0 2px;
}

body.sidebar-collapsed .app-shell .sidebar-divider span {
  font-size: 0;
  letter-spacing: 0;
}

body.sidebar-collapsed .app-shell .sidebar-divider span::before {
  content: '·';
  font-size: 14px;
  color: var(--oc-chrome-muted);
}

.app-shell .sidebar-item > a {
  color: var(--oc-chrome-fg) !important;
}

.app-shell .sidebar-item > a:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #fff !important;
}

.app-shell .sidebar-item.active > a {
  background: var(--oc-chrome-active) !important;
  color: #fff !important;
}

.app-shell .sidebar-group-header {
  color: var(--oc-chrome-fg) !important;
}

.app-shell .sidebar-group-header:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #fff !important;
}

.app-shell .sidebar-group.active > .sidebar-group-header {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #fff !important;
}

.app-shell .sidebar-group.active {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.app-shell .sidebar-subitem > a {
  color: var(--oc-chrome-fg) !important;
}

.app-shell .sidebar-subitem.active > a {
  background: var(--oc-chrome-active) !important;
  color: #fff !important;
}

.app-shell .app-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 22px 26px 40px;
  -webkit-overflow-scrolling: touch;
}

body.sidebar-collapsed .app-shell .app-sidebar {
  width: 76px;
  flex-basis: 76px;
  max-width: 76px;
}

body.sidebar-collapsed .app-shell .sidebar-label span,
body.sidebar-collapsed .app-shell .sidebar-item span {
  display: none;
}

body.sidebar-collapsed .app-shell .sidebar-item > a {
  justify-content: center;
  padding: 0;
}

.app-sidebar-backdrop {
  display: none;
}

.offcanvas.app-drawer {
  width: min(520px, 100vw);
  z-index: 1080;
}

.offcanvas-backdrop {
  z-index: 1070;
}

.app-drawer .drawer-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: #fff;
  border-top: 1px solid var(--app-line, #e5eaf3);
  margin: 24px -22px -22px;
  padding: 16px 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-grid .card {
  margin: 0;
}

.app-toast-info {
  border-left-color: #0ea5e9;
}

.app-toast-info .app-toast-icon {
  color: #0284c8;
}

/* —— 自研右侧抽屉（不依赖 Bootstrap Offcanvas CSS） —— */
.offcanvas.app-drawer,
.app-drawer.offcanvas {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  width: min(520px, 100vw);
  max-width: 100vw;
  background: #fff;
  background-clip: padding-box;
  outline: 0;
  border-left: 1px solid var(--app-line, #e5eaf3);
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.18);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform .28s ease, visibility .28s ease;
  overflow: hidden;
}

.offcanvas.app-drawer.show,
.app-drawer.offcanvas.show {
  transform: translateX(0);
  visibility: visible;
}

.app-drawer .offcanvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--app-line, #e5eaf3);
  min-height: 64px;
}

.app-drawer .offcanvas-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--app-ink, #0f172a);
}

.app-drawer .offcanvas-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.app-drawer .btn-close,
button.btn-close {
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 0;
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1rem auto no-repeat;
  opacity: .7;
  cursor: pointer;
}

.app-drawer .btn-close:hover,
button.btn-close:hover {
  opacity: 1;
}

.oc-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1070;
  background: rgba(15, 23, 42, 0.45);
  border: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease;
}

.oc-drawer-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.oc-drawer-backdrop[hidden] {
  display: none !important;
}

body.oc-drawer-open {
  overflow: hidden;
}

/* 用户下拉（兜底，不依赖 BS Dropdown 动画） */
.topbar-user-dropdown {
  position: relative;
}

.topbar-user-dropdown .dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 1050;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
}

.topbar-user-dropdown.show .dropdown-menu,
.topbar-user-dropdown .dropdown-menu.show {
  display: block;
}

.user-menu-button.dropdown-toggle::after {
  display: inline-block;
  margin-left: 6px;
  vertical-align: .15em;
  content: '';
  border-top: .35em solid;
  border-right: .35em solid transparent;
  border-bottom: 0;
  border-left: .35em solid transparent;
}

/* —— 自定义确认弹窗 —— */
.oc-dialog {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.oc-dialog.is-open {
  display: flex;
}

.oc-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
}

.oc-dialog-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
  padding: 28px 24px 20px;
  text-align: center;
  animation: ocDialogIn .18s ease-out;
}

@keyframes ocDialogIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.oc-dialog-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: rgba(7, 193, 96, 0.12);
  color: #07c160;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.oc-dialog-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.oc-dialog-message {
  margin: 0 0 22px;
  color: #475569;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.oc-dialog-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.oc-dialog-actions .btn {
  min-width: 96px;
}

body.oc-dialog-open {
  overflow: hidden;
}

/* 兜底：任何残留 Bootstrap 遮罩都压住并隐藏 */
body.oc-shell .offcanvas-backdrop,
body.oc-shell .modal-backdrop {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

@media (max-width: 1199px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 991px) {
  .app-shell .app-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-105%);
    box-shadow: 12px 0 32px rgba(15, 23, 42, 0.28);
    width: min(280px, 86vw) !important;
    flex-basis: min(280px, 86vw) !important;
    max-width: min(280px, 86vw) !important;
  }

  body:not(.sidebar-collapsed) .app-shell .app-sidebar {
    transform: translateX(0);
  }

  body.sidebar-collapsed .app-shell .app-sidebar {
    transform: translateX(-105%);
    width: min(280px, 86vw) !important;
    max-width: min(280px, 86vw) !important;
  }

  body.sidebar-collapsed .app-shell .sidebar-label span,
  body.sidebar-collapsed .app-shell .sidebar-item span {
    display: inline;
  }

  body.sidebar-collapsed .app-shell .sidebar-item > a {
    justify-content: flex-start;
    padding: 0 12px;
  }

  body:not(.sidebar-collapsed) .app-sidebar-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1025;
    border: 0;
    padding: 0;
    width: 100%;
    cursor: pointer;
  }

  .app-shell .app-main {
    padding: 16px;
  }

  .brand-copy {
    display: none;
  }
}

@media (max-width: 575px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .app-shell .app-main {
    padding: 12px;
  }

  .page-heading h1 {
    font-size: 20px;
  }

  .user-copy {
    display: none;
  }

  .app-toast-stack {
    top: 72px;
    right: 10px;
    left: 10px;
    width: auto;
  }
}

/* 复选框可见性：避免 Bootstrap appearance:none + CSS 变量缺失导致“看不见” */
body.oc-shell .form-check:not(.form-switch) {
  min-height: 1.5rem;
  padding-left: 1.75rem;
  display: block;
  position: relative;
}

body.oc-shell .form-check:not(.form-switch) .form-check-input {
  float: none;
  position: absolute;
  left: 0;
  top: 0.2rem;
  margin: 0 !important;
  margin-left: 0 !important;
  width: 1.15rem !important;
  height: 1.15rem !important;
  appearance: auto !important;
  -webkit-appearance: checkbox !important;
  background-image: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  background-color: #fff !important;
  border: 1.5px solid #94a3b8 !important;
  border-radius: 0.25rem;
  accent-color: #07c160;
  cursor: pointer;
  z-index: 1;
  filter: none !important;
  transform: none !important;
}

body.oc-shell .form-check:not(.form-switch) .form-check-input:checked {
  background-color: #07c160 !important;
  border-color: #07c160 !important;
}

body.oc-shell .form-check .form-check-label {
  display: inline-block;
  padding-left: 0.15rem;
  cursor: pointer;
  user-select: none;
  color: #334155;
  font-weight: 600;
}

/* label 包住 input 的旧写法：强制露出内部 checkbox */
body.oc-shell .form-check-label > .form-check-input {
  position: static !important;
  display: inline-block !important;
  vertical-align: -0.15rem;
  margin-right: 0.45rem !important;
  margin-left: 0 !important;
  float: none !important;
}

/* form-switch：保证轨道可见 */
body.oc-shell .form-switch {
  padding-left: 2.75rem;
  min-height: 1.75rem;
}

body.oc-shell .form-switch .form-check-input {
  width: 2.25rem !important;
  height: 1.2rem !important;
  margin-left: -2.75rem !important;
  background-color: #cbd5e1 !important;
  border: 1px solid #94a3b8 !important;
  background-image: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  cursor: pointer;
  appearance: none !important;
  -webkit-appearance: none !important;
  border-radius: 2rem !important;
  background-position: left center;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

body.oc-shell .form-switch .form-check-input:checked {
  background-color: #07c160 !important;
  border-color: #07c160 !important;
}

