@tailwind base;
@tailwind components;
@tailwind utilities;

/* Align a captured admin notice's first line with its 36px icon badge. */
.xht-admin-notice-content {
  padding-block: max(0px, calc((2.25rem - 1.625em) / 2));
  overflow-wrap: anywhere;
}

.xht-admin-notice-content p {
  font-size: inherit;
  line-height: inherit;
}

/* 移除所有按钮和链接的焦点状态效果 */
a,
button {
  -webkit-tap-highlight-color: transparent;
}

a:focus,
button:focus,
.xht-focus-none:focus {
  outline: none !important;
  box-shadow: none !important;
}

img {
  display: inline
}

/* 在文件末尾添加 */
.xht-outside-circle::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  right: -20px;
  top: 0;
  background: radial-gradient(circle at 100% 100%, transparent 20px, theme('colors.blue.400') 21px);
}

/* 隐藏滚动条但保持滚动功能 */
.xht-scrollbar-hide {
  -ms-overflow-style: none;
  /* IE and Edge */
  scrollbar-width: none;
  /* Firefox */
}

.xht-scrollbar-hide::-webkit-scrollbar {
  display: none;
  /* Chrome, Safari and Opera */
}

.xht-xhtheme-aitool-settingpage .components-radio-control {
  margin-top: -5px;
}

.xht-xhtheme-aitool-settingpage .components-radio-control .components-radio-control__input {
  transform: translateY(2px);
}

.xht-radio-horizontal .components-flex {
  flex-direction: row;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 20px;
}

.xht-radio-horizontal .components-radio-control__input-container {
  display: inline-flex;
  align-items: center;
}

@keyframes xht-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.xht-animate-fade-in {
  animation: xht-fade-in 0.4s;
}

/* 自定义美化滚动条样式 */
.xht-custom-scrollbar {
  scrollbar-width: thin;
  /* Firefox */
  scrollbar-color: #dddddd transparent;
  /* Firefox - 滚动条颜色 背景颜色 */
}

/* Webkit 浏览器 (Chrome, Safari, Edge) */
.xht-custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.xht-custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 4px;
}

.xht-custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.xht-custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: #cfcdcd;
}

.xht-custom-scrollbar::-webkit-scrollbar-thumb:active {
  background-color: #cfcdcd;
}

body.toplevel_page_xhtheme-ai-toolbox {
  background: #f5f7fb;
}

body.toplevel_page_xhtheme-ai-toolbox #wpcontent {
  padding-left: 0 !important;
}

body.toplevel_page_xhtheme-ai-toolbox #wpbody-content {
  padding-bottom: 0 !important;
}

body.toplevel_page_xhtheme-ai-toolbox #wpfooter {
  display: none !important;
}

body.xht-admin-shell-page #wpfooter,
body.xht-admin-shell-page #wpbody-content .notice,
body.xht-admin-shell-page #wpbody-content .updated,
body.xht-admin-shell-page #wpbody-content .update-nag,
body.xht-admin-shell-page #wpbody-content .error {
  display: none !important;
}

body.xht-admin-shell-page #wpbody-content {
  padding-bottom: 0 !important;
}

body.xht-admin-shell-page .wrap {
  margin: 0;
}

body.xht-admin-shell-page #wpcontent {
  padding-left: 0 !important;
}

body.toplevel_page_xhtheme-ai-toolbox .wrap {
  margin: 0;
}

.xht-dashboard-sticky {
  position: sticky;
  top: 32px;
}

.xht-modal-handle {
  display: none;
}

@keyframes xht-modal-sheet-up {
  from {
    opacity: 0.92;
    transform: translateY(28px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes xht-modal-backdrop-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@media screen and (max-width: 639px) {
  .xht-modal-shell {
    align-items: flex-end;
    padding: 0;
  }

  .xht-modal-backdrop {
    background: rgba(15, 23, 42, 0.38);
    animation: xht-modal-backdrop-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .xht-modal-panel {
    width: 100%;
    max-width: none;
    max-height: 88vh;
    max-height: 88dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -24px 52px rgba(15, 23, 42, 0.18);
    animation: xht-modal-sheet-up 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom center;
  }

  .xht-modal-handle {
    display: block;
    flex: 0 0 auto;
    width: 38px;
    height: 4px;
    margin: 10px auto 0;
    border-radius: 999px;
    background: #cbd5e1;
  }

  .xht-modal-header {
    padding-top: 16px;
  }

  .xht-modal-header > button {
    min-width: 40px;
    min-height: 40px;
  }

  .xht-modal-scrollarea {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .xht-modal-footer {
    padding-bottom: 1.5rem;
    padding-bottom: max(1.5rem, calc(1.5rem + env(safe-area-inset-bottom)));
    background: rgba(255, 255, 255, 0.96);
  }

  .xht-dashboard-language-help-card {
    top: auto !important;
    right: 12px;
    bottom: max(16px, calc(16px + env(safe-area-inset-bottom)));
    left: 12px !important;
    width: auto;
    max-height: min(70vh, 460px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .xht-dashboard-language-help-arrow {
    display: none;
  }
}

@media screen and (max-width: 639px) and (prefers-reduced-motion: reduce) {
  .xht-modal-backdrop,
  .xht-modal-panel {
    animation: none;
  }
}

@media screen and (max-width: 782px) {
  .xht-dashboard-sticky {
    top: 46px;
  }
}

.xht-dashboard-range::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(90deg, #0f172a 0%, #334155 100%);
  border-radius: 999px;
}

.xht-dashboard-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #0f172a;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2);
}

.xht-dashboard-range::-moz-range-track {
  height: 8px;
  background: linear-gradient(90deg, #0f172a 0%, #334155 100%);
  border: 0;
  border-radius: 999px;
}

.xht-dashboard-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #0f172a;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2);
}

.xht-dashboard-range-ghost {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 100%;
  background: transparent;
  pointer-events: none;
}

.xht-dashboard-range-ghost:focus {
  outline: none;
}

.xht-dashboard-range-ghost::-webkit-slider-runnable-track {
  height: 8px;
  background: transparent;
  border: 0;
}

.xht-dashboard-range-ghost::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #0f172a;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2);
  pointer-events: auto;
  cursor: pointer;
}

.xht-dashboard-range-ghost::-moz-range-track {
  height: 8px;
  background: transparent;
  border: 0;
}

.xht-dashboard-range-ghost::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #0f172a;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2);
  pointer-events: auto;
  cursor: pointer;
}

/* Reserve breathing room for task lists only when the card itself is wide. */
.xht-rule-card {
  container: xht-rule-card / inline-size;
}

.xht-rule-card-features {
  min-width: 0;
}

@container xht-rule-card (min-width: 800px) {
  .xht-rule-card-features {
    padding-inline-end: clamp(80px, 10cqi, 144px);
  }
}

/* Header actions and the task list have independent widths in every state. */
.xht-rule-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 12px;
}

.xht-rule-card-title {
  display: flex;
  flex: 1 1 12rem;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-left: 16px;
  overflow-wrap: anywhere;
}

.xht-rule-card-title h3 {
  margin: 0;
}

.xht-quota-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}

.xht-quota-values,
.xht-quota-usage {
  display: flex;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px 8px;
}

.xht-quota-values {
  margin-inline-start: auto;
}

.xht-quota-row > span,
.xht-quota-usage > span,
.xht-quota-value {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.xht-quota-action {
  width: auto;
  min-width: 40px;
  flex-shrink: 0;
  white-space: nowrap;
}

.xht-rule-card-actions {
  display: flex;
  flex: 0 0 auto;
  max-width: 100%;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-left: auto;
}

.xht-rule-card-actions > button {
  min-height: 44px;
}

button.xht-rule-card-action {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 6px 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  text-decoration: none;
  text-underline-offset: 3px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 150ms ease;
}

button.xht-rule-card-action:hover {
  background: transparent;
  box-shadow: none;
}

.xht-rule-card-action-edit {
  color: #2563eb;
}

.xht-rule-card-action-delete {
  color: #dc2626;
}

.xht-rule-card-action:not(:disabled):hover {
  text-decoration: underline;
}

.xht-rule-card-action-edit:not(:disabled):hover {
  color: #1e40af;
}

.xht-rule-card-action-delete:not(:disabled):hover {
  color: #991b1b;
}

.xht-rule-card-action:disabled {
  opacity: 0.65;
  cursor: wait;
}

.xht-rule-card-actions > button:not(.xht-rule-status-toggle):focus-visible {
  outline: 2px solid #2563eb !important;
  outline-offset: 2px;
}

button.xht-rule-status-toggle {
  display: inline-flex;
  flex-shrink: 0;
  min-height: 44px;
  align-items: center;
  margin-left: 4px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  cursor: pointer;
}

.xht-rule-status-track {
  position: relative;
  display: grid;
  min-width: 56px;
  height: 24px;
  align-items: center;
  overflow: hidden;
  border-radius: 999px;
  background: #f87171;
  color: #fff;
  box-shadow: inset 0 -1px 0 rgb(0 0 0 / 8%);
  transition: background-color 180ms ease;
}

.xht-rule-status-toggle[aria-checked="true"] .xht-rule-status-track {
  background: #2563eb;
  color: #fff;
}

.xht-rule-status-toggle:not(:disabled):hover .xht-rule-status-track {
  background: #f56565;
}

.xht-rule-status-toggle[aria-checked="true"]:not(:disabled):hover .xht-rule-status-track {
  background: #1d4ed8;
}

/* Put focus on the capsule so the shared button focus reset cannot hide it. */
.xht-rule-status-toggle:focus-visible .xht-rule-status-track {
  outline: 2px solid #2563eb;
  outline-offset: 3px;
}

.xht-rule-status-toggle:disabled {
  cursor: wait;
}

.xht-rule-status-toggle:disabled:not([aria-busy="true"]) .xht-rule-status-track {
  opacity: 0.65;
}

.xht-rule-status-measure {
  display: grid;
  visibility: hidden;
  padding: 0 24px 0 8px;
  white-space: nowrap;
}

.xht-rule-status-measure > span {
  grid-area: 1 / 1;
}

.xht-rule-status-label {
  position: absolute;
  top: 4px;
  right: 8px;
  left: 24px;
  text-align: center;
  white-space: nowrap;
}

.xht-rule-status-toggle[aria-checked="true"] .xht-rule-status-label {
  right: 24px;
  left: 8px;
}

.xht-rule-status-thumb-slot {
  position: absolute;
  inset: 3px;
  pointer-events: none;
  transition: transform 180ms ease;
}

.xht-rule-status-toggle[aria-checked="true"] .xht-rule-status-thumb-slot {
  transform: translateX(calc(100% - 18px));
}

.xht-rule-status-thumb {
  display: flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  color: #c42b36;
  box-shadow: 0 1px 3px rgb(15 23 42 / 18%);
}

.xht-rule-status-toggle[aria-checked="true"] .xht-rule-status-thumb {
  color: #2563eb;
}

.xht-rule-status-spinner {
  width: 11px;
  height: 11px;
  animation: xht-rule-status-spin 800ms linear infinite;
}

@keyframes xht-rule-status-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .xht-rule-card-action,
  .xht-rule-status-track,
  .xht-rule-status-thumb-slot {
    transition: none;
  }

  .xht-rule-status-spinner {
    animation: none;
  }
}
