/**
 * 基础工具类
 * 提供常用的样式工具类
 * @author 前端架构师
 */

/* ===== 卡片工具类 ===== */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--spacing-6);
  transition: all var(--duration-200) var(--ease-out);

  &:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
  }

  /* 卡片变体 */
  &--flat {
    box-shadow: none;
    border: 1px solid var(--color-border-secondary);

    &:hover {
      box-shadow: var(--shadow-sm);
      transform: none;
    }
  }

  &--elevated {
    box-shadow: var(--shadow-lg);

    &:hover {
      box-shadow: var(--shadow-xl);
    }
  }

  &--compact {
    padding: var(--spacing-4);
  }

  &--spacious {
    padding: var(--spacing-8);
  }

  /* 卡片头部 */
  &__header {
    border-bottom: 1px solid var(--color-border-secondary);
    margin: calc(var(--spacing-6) * -1) calc(var(--spacing-6) * -1) var(--spacing-4);
    padding: var(--spacing-4) var(--spacing-6);

    &-title {
      color: var(--color-text-primary);
      font-size: var(--font-size-lg);
      font-weight: var(--font-weight-semibold);
      margin: 0;
      line-height: var(--line-height-tight);
    }

    &-subtitle {
      color: var(--color-text-secondary);
      font-size: var(--font-size-sm);
      margin: var(--spacing-1) 0 0;
      line-height: var(--line-height-normal);
    }

    &-extra {
      display: flex;
      align-items: center;
      gap: var(--spacing-2);
      margin-left: auto;
    }
  }

  /* 卡片内容 */
  &__content {
    color: var(--color-text-primary);
    line-height: var(--line-height-relaxed);
  }

  /* 卡片底部 */
  &__footer {
    border-top: 1px solid var(--color-border-secondary);
    margin: var(--spacing-4) calc(var(--spacing-6) * -1) calc(var(--spacing-6) * -1);
    padding: var(--spacing-4) var(--spacing-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

/* ===== 文本工具类 ===== */
.muted {
  color: var(--color-text-tertiary) !important;
}

.text-primary {
  color: var(--color-text-primary) !important;
}

.text-secondary {
  color: var(--color-text-secondary) !important;
}

.text-tertiary {
  color: var(--color-text-tertiary) !important;
}

.text-quaternary {
  color: var(--color-text-quaternary) !important;
}

.text-success {
  color: var(--color-success) !important;
}

.text-warning {
  color: var(--color-warning) !important;
}

.text-danger {
  color: var(--color-danger) !important;
}

.text-info {
  color: var(--color-primary) !important;
}

/* 字体大小 */
.text-xs {
  font-size: var(--font-size-xs) !important;
}

.text-sm {
  font-size: var(--font-size-sm) !important;
}

.text-base {
  font-size: var(--font-size-base) !important;
}

.text-lg {
  font-size: var(--font-size-lg) !important;
}

.text-xl {
  font-size: var(--font-size-xl) !important;
}

.text-2xl {
  font-size: var(--font-size-2xl) !important;
}

/* 字体粗细 */
.font-thin {
  font-weight: var(--font-weight-thin) !important;
}

.font-light {
  font-weight: var(--font-weight-light) !important;
}

.font-normal {
  font-weight: var(--font-weight-normal) !important;
}

.font-medium {
  font-weight: var(--font-weight-medium) !important;
}

.font-semibold {
  font-weight: var(--font-weight-semibold) !important;
}

.font-bold {
  font-weight: var(--font-weight-bold) !important;
}

/* 文本对齐 */
.text-left {
  text-align: left !important;
}

.text-center {
  text-align: center !important;
}

.text-right {
  text-align: right !important;
}

.text-justify {
  text-align: justify !important;
}

/* ===== 紧凑布局工具类 ===== */
.compact {
  /* 紧凑间距 */
  &-spacing {
    > * + * {
      margin-top: var(--spacing-2) !important;
    }
  }

  /* 紧凑表单 */
  &-form {
    .el-form-item {
      margin-bottom: var(--spacing-4) !important;
    }

    .el-input,
    .el-select,
    .el-textarea {
      .el-input__inner,
      .el-textarea__inner {
        padding: var(--spacing-2) var(--spacing-3) !important;
        font-size: var(--font-size-sm) !important;
      }
    }

    .el-button {
      padding: var(--spacing-2) var(--spacing-4) !important;
      font-size: var(--font-size-sm) !important;
    }
  }

  /* 紧凑表格 */
  &-table {
    .el-table {
      th,
      td {
        padding: var(--spacing-2) var(--spacing-3) !important;
        font-size: var(--font-size-sm) !important;
      }
    }
  }

  /* 紧凑按钮组 */
  &-buttons {
    display: flex;
    gap: var(--spacing-2);

    .el-button {
      padding: var(--spacing-2) var(--spacing-3) !important;
      font-size: var(--font-size-sm) !important;
    }
  }
}

/* ===== 间距工具类 ===== */
/* 外边距 */
.m-0 { margin: 0 !important; }
.m-1 { margin: var(--spacing-1) !important; }
.m-2 { margin: var(--spacing-2) !important; }
.m-3 { margin: var(--spacing-3) !important; }
.m-4 { margin: var(--spacing-4) !important; }
.m-5 { margin: var(--spacing-5) !important; }
.m-6 { margin: var(--spacing-6) !important; }
.m-8 { margin: var(--spacing-8) !important; }

/* 水平外边距 */
.mx-0 { margin-left: 0 !important; margin-right: 0 !important; }
.mx-1 { margin-left: var(--spacing-1) !important; margin-right: var(--spacing-1) !important; }
.mx-2 { margin-left: var(--spacing-2) !important; margin-right: var(--spacing-2) !important; }
.mx-3 { margin-left: var(--spacing-3) !important; margin-right: var(--spacing-3) !important; }
.mx-4 { margin-left: var(--spacing-4) !important; margin-right: var(--spacing-4) !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }

/* 垂直外边距 */
.my-0 { margin-top: 0 !important; margin-bottom: 0 !important; }
.my-1 { margin-top: var(--spacing-1) !important; margin-bottom: var(--spacing-1) !important; }
.my-2 { margin-top: var(--spacing-2) !important; margin-bottom: var(--spacing-2) !important; }
.my-3 { margin-top: var(--spacing-3) !important; margin-bottom: var(--spacing-3) !important; }
.my-4 { margin-top: var(--spacing-4) !important; margin-bottom: var(--spacing-4) !important; }

/* 内边距 */
.p-0 { padding: 0 !important; }
.p-1 { padding: var(--spacing-1) !important; }
.p-2 { padding: var(--spacing-2) !important; }
.p-3 { padding: var(--spacing-3) !important; }
.p-4 { padding: var(--spacing-4) !important; }
.p-5 { padding: var(--spacing-5) !important; }
.p-6 { padding: var(--spacing-6) !important; }
.p-8 { padding: var(--spacing-8) !important; }

/* 水平内边距 */
.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-1 { padding-left: var(--spacing-1) !important; padding-right: var(--spacing-1) !important; }
.px-2 { padding-left: var(--spacing-2) !important; padding-right: var(--spacing-2) !important; }
.px-3 { padding-left: var(--spacing-3) !important; padding-right: var(--spacing-3) !important; }
.px-4 { padding-left: var(--spacing-4) !important; padding-right: var(--spacing-4) !important; }

/* 垂直内边距 */
.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-1 { padding-top: var(--spacing-1) !important; padding-bottom: var(--spacing-1) !important; }
.py-2 { padding-top: var(--spacing-2) !important; padding-bottom: var(--spacing-2) !important; }
.py-3 { padding-top: var(--spacing-3) !important; padding-bottom: var(--spacing-3) !important; }
.py-4 { padding-top: var(--spacing-4) !important; padding-bottom: var(--spacing-4) !important; }

/* ===== 布局工具类 ===== */
.flex {
  display: flex !important;
}

.inline-flex {
  display: inline-flex !important;
}

.flex-col {
  flex-direction: column !important;
}

.flex-row {
  flex-direction: row !important;
}

.flex-wrap {
  flex-wrap: wrap !important;
}

.flex-nowrap {
  flex-wrap: nowrap !important;
}

.items-start {
  align-items: flex-start !important;
}

.items-center {
  align-items: center !important;
}

.items-end {
  align-items: flex-end !important;
}

.items-stretch {
  align-items: stretch !important;
}

.justify-start {
  justify-content: flex-start !important;
}

.justify-center {
  justify-content: center !important;
}

.justify-end {
  justify-content: flex-end !important;
}

.justify-between {
  justify-content: space-between !important;
}

.justify-around {
  justify-content: space-around !important;
}

.justify-evenly {
  justify-content: space-evenly !important;
}

.flex-1 {
  flex: 1 1 0% !important;
}

.flex-auto {
  flex: 1 1 auto !important;
}

.flex-none {
  flex: none !important;
}

.grow {
  flex-grow: 1 !important;
}

.grow-0 {
  flex-grow: 0 !important;
}

.shrink {
  flex-shrink: 1 !important;
}

.shrink-0 {
  flex-shrink: 0 !important;
}

/* ===== 显示工具类 ===== */
.block {
  display: block !important;
}

.inline-block {
  display: inline-block !important;
}

.inline {
  display: inline !important;
}

.hidden {
  display: none !important;
}

.invisible {
  visibility: hidden !important;
}

.visible {
  visibility: visible !important;
}

/* ===== 位置工具类 ===== */
.relative {
  position: relative !important;
}

.absolute {
  position: absolute !important;
}

.fixed {
  position: fixed !important;
}

.sticky {
  position: sticky !important;
}

.static {
  position: static !important;
}

/* ===== 圆角工具类 ===== */
.rounded-none {
  border-radius: var(--radius-none) !important;
}

.rounded-sm {
  border-radius: var(--radius-sm) !important;
}

.rounded {
  border-radius: var(--radius-base) !important;
}

.rounded-md {
  border-radius: var(--radius-md) !important;
}

.rounded-lg {
  border-radius: var(--radius-lg) !important;
}

.rounded-xl {
  border-radius: var(--radius-xl) !important;
}

.rounded-2xl {
  border-radius: var(--radius-2xl) !important;
}

.rounded-full {
  border-radius: var(--radius-full) !important;
}

/* ===== 阴影工具类 ===== */
.shadow-none {
  box-shadow: var(--shadow-none) !important;
}

.shadow-sm {
  box-shadow: var(--shadow-sm) !important;
}

.shadow {
  box-shadow: var(--shadow-base) !important;
}

.shadow-md {
  box-shadow: var(--shadow-md) !important;
}

.shadow-lg {
  box-shadow: var(--shadow-lg) !important;
}

.shadow-xl {
  box-shadow: var(--shadow-xl) !important;
}

.shadow-2xl {
  box-shadow: var(--shadow-2xl) !important;
}

.shadow-card {
  box-shadow: var(--shadow-card) !important;
}

/* ===== 边框工具类 ===== */
.border {
  border: 1px solid var(--color-border-primary) !important;
}

.border-0 {
  border: 0 !important;
}

.border-t {
  border-top: 1px solid var(--color-border-primary) !important;
}

.border-r {
  border-right: 1px solid var(--color-border-primary) !important;
}

.border-b {
  border-bottom: 1px solid var(--color-border-primary) !important;
}

.border-l {
  border-left: 1px solid var(--color-border-primary) !important;
}

.border-primary {
  border-color: var(--color-primary) !important;
}

.border-success {
  border-color: var(--color-success) !important;
}

.border-warning {
  border-color: var(--color-warning) !important;
}

.border-danger {
  border-color: var(--color-danger) !important;
}

/* ===== 背景工具类 ===== */
.bg-transparent {
  background-color: transparent !important;
}

.bg-primary {
  background-color: var(--color-bg-primary) !important;
}

.bg-secondary {
  background-color: var(--color-bg-secondary) !important;
}

.bg-tertiary {
  background-color: var(--color-bg-tertiary) !important;
}

.bg-card {
  background-color: var(--color-bg-card) !important;
}

.bg-success {
  background-color: var(--color-success) !important;
  color: var(--color-text-inverse) !important;
}

.bg-warning {
  background-color: var(--color-warning) !important;
  color: var(--color-text-inverse) !important;
}

.bg-danger {
  background-color: var(--color-danger) !important;
  color: var(--color-text-inverse) !important;
}

.bg-info {
  background-color: var(--color-primary) !important;
  color: var(--color-text-inverse) !important;
}

/* ===== 宽高工具类 ===== */
.w-full {
  width: 100% !important;
}

.w-auto {
  width: auto !important;
}

.h-full {
  height: 100% !important;
}

.h-auto {
  height: auto !important;
}

.min-h-0 {
  min-height: 0 !important;
}

.min-h-full {
  min-height: 100% !important;
}

/* ===== 溢出工具类 ===== */
.overflow-hidden {
  overflow: hidden !important;
}

.overflow-visible {
  overflow: visible !important;
}

.overflow-scroll {
  overflow: scroll !important;
}

.overflow-auto {
  overflow: auto !important;
}

.overflow-x-hidden {
  overflow-x: hidden !important;
}

.overflow-y-hidden {
  overflow-y: hidden !important;
}

.overflow-x-scroll {
  overflow-x: scroll !important;
}

.overflow-y-scroll {
  overflow-y: scroll !important;
}

.overflow-x-auto {
  overflow-x: auto !important;
}

.overflow-y-auto {
  overflow-y: auto !important;
}

/* ===== 光标工具类 ===== */
.cursor-auto {
  cursor: auto !important;
}

.cursor-default {
  cursor: default !important;
}

.cursor-pointer {
  cursor: pointer !important;
}

.cursor-wait {
  cursor: wait !important;
}

.cursor-text {
  cursor: text !important;
}

.cursor-move {
  cursor: move !important;
}

.cursor-help {
  cursor: help !important;
}

.cursor-not-allowed {
  cursor: not-allowed !important;
}

/* ===== 用户选择工具类 ===== */
.select-none {
  user-select: none !important;
}

.select-text {
  user-select: text !important;
}

.select-all {
  user-select: all !important;
}

.select-auto {
  user-select: auto !important;
}

/* ===== 过渡动画工具类 ===== */
.transition {
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
  transition-timing-function: var(--ease-in-out);
  transition-duration: var(--duration-150);
}

.transition-none {
  transition-property: none !important;
}

.transition-all {
  transition-property: all !important;
  transition-timing-function: var(--ease-in-out);
  transition-duration: var(--duration-150);
}

.transition-colors {
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-timing-function: var(--ease-in-out);
  transition-duration: var(--duration-150);
}

.transition-opacity {
  transition-property: opacity;
  transition-timing-function: var(--ease-in-out);
  transition-duration: var(--duration-150);
}

.transition-shadow {
  transition-property: box-shadow;
  transition-timing-function: var(--ease-in-out);
  transition-duration: var(--duration-150);
}

.transition-transform {
  transition-property: transform;
  transition-timing-function: var(--ease-in-out);
  transition-duration: var(--duration-150);
}

/* 过渡时长 */
.duration-75 {
  transition-duration: var(--duration-75) !important;
}

.duration-100 {
  transition-duration: var(--duration-100) !important;
}

.duration-150 {
  transition-duration: var(--duration-150) !important;
}

.duration-200 {
  transition-duration: var(--duration-200) !important;
}

.duration-300 {
  transition-duration: var(--duration-300) !important;
}

.duration-500 {
  transition-duration: var(--duration-500) !important;
}

/* 过渡缓动 */
.ease-linear {
  transition-timing-function: var(--ease-linear) !important;
}

.ease-in {
  transition-timing-function: var(--ease-in) !important;
}

.ease-out {
  transition-timing-function: var(--ease-out) !important;
}

.ease-in-out {
  transition-timing-function: var(--ease-in-out) !important;
}

/* ===== 响应式工具类 ===== */
@media (max-width: 639px) {
  .sm\:hidden {
    display: none !important;
  }
  
  .sm\:block {
    display: block !important;
  }
  
  .sm\:flex {
    display: flex !important;
  }
  
  .sm\:text-sm {
    font-size: var(--font-size-sm) !important;
  }
  
  .sm\:p-4 {
    padding: var(--spacing-4) !important;
  }
}

@media (min-width: 640px) and (max-width: 767px) {
  .md\:hidden {
    display: none !important;
  }
  
  .md\:block {
    display: block !important;
  }
  
  .md\:flex {
    display: flex !important;
  }
}

@media (min-width: 768px) {
  .lg\:hidden {
    display: none !important;
  }
  
  .lg\:block {
    display: block !important;
  }
  
  .lg\:flex {
    display: flex !important;
  }
  
  .lg\:text-base {
    font-size: var(--font-size-base) !important;
  }
  
  .lg\:p-6 {
    padding: var(--spacing-6) !important;
  }
}

/* ===== 打印工具类 ===== */
@media print {
  .print\:hidden {
    display: none !important;
  }
  
  .print\:block {
    display: block !important;
  }
  
  .print\:text-black {
    color: #000000 !important;
  }
  
  .print\:bg-white {
    background-color: #ffffff !important;
  }
}

/* ===== 可访问性工具类 ===== */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.not-sr-only {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}

/* 聚焦可见性 */
.focus\:outline-none:focus {
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
}

.focus\:ring:focus {
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 3px var(--color-primary-100) !important;
}

.focus\:ring-primary:focus {
  box-shadow: 0 0 0 3px var(--color-primary-100) !important;
}

.focus\:ring-success:focus {
  box-shadow: 0 0 0 3px var(--color-success-100) !important;
}

.focus\:ring-warning:focus {
  box-shadow: 0 0 0 3px var(--color-warning-100) !important;
}

.focus\:ring-danger:focus {
  box-shadow: 0 0 0 3px var(--color-danger-100) !important;
}
