/* 通用引擎样式文件 */

/* ========== 权限引擎样式 ========== */
.permission-disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  pointer-events: none;
}

.permission-disabled:hover {
  background-color: #f5f5f5 !important;
}

/* 权限检查提示 */
.permission-hint {
  display: inline-block;
  margin-left: 5px;
  padding: 2px 6px;
  background: #f0f0f0;
  border-radius: 3px;
  font-size: 12px;
  color: #666;
  vertical-align: middle;
}

.permission-hint.granted {
  background: #d9f7be;
  color: #389e0d;
}

.permission-hint.denied {
  background: #ffccc7;
  color: #f5222d;
}

/* ========== 验证引擎样式 ========== */
.validation-error {
  border-color: #f5222d !important;
  background-color: #fff2f0 !important;
}

.validation-success {
  border-color: #52c41a !important;
  background-color: #f6ffed !important;
}

/* 错误消息容器 */
.validation-error-message {
  margin-top: 4px;
  padding: 6px 10px;
  background: #fff2f0;
  border: 1px solid #ffccc7;
  border-radius: 4px;
  font-size: 12px;
  color: #f5222d;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}

.validation-error-message .error-icon {
  margin-right: 4px;
  font-size: 14px;
}

/* 抖动动画 */
.validation-shake {
  animation: shake 0.6s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

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

/* 工具提示样式 */
[data-validation-tooltip] {
  position: relative;
}

[data-validation-tooltip]::after {
  content: attr(data-validation-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: #f5222d;
  color: white;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 1000;
}

[data-validation-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ========== 计算引擎样式 ========== */
.calculation-result {
  font-family: 'Courier New', monospace;
  font-weight: 600;
}

.calculation-result.positive {
  color: #52c41a;
}

.calculation-result.negative {
  color: #f5222d;
}

.calculation-result.zero {
  color: #999;
}

/* 计算摘要面板 */
.calculation-summary {
  padding: 12px;
  background: #fafafa;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  margin-bottom: 16px;
}

.calculation-summary h4 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: 14px;
  font-weight: 600;
}

.calculation-summary-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
}

.calculation-summary-item:last-child {
  margin-bottom: 0;
  padding-top: 6px;
  border-top: 1px solid #e8e8e8;
  font-weight: 600;
}

.calculation-summary-label {
  color: #666;
}

.calculation-summary-value {
  color: #333;
  font-weight: 500;
}

/* 计算器按钮 */
.calculator-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  background: #1890ff;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.3s;
}

.calculator-button:hover {
  background: #40a9ff;
}

.calculator-button:disabled {
  background: #d9d9d9;
  cursor: not-allowed;
}

.calculator-button .icon {
  margin-right: 4px;
  font-size: 14px;
}

/* ========== 通用状态样式 ========== */
.engine-loading {
  position: relative;
  opacity: 0.7;
}

.engine-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #1890ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.engine-error {
  padding: 10px;
  background: #fff2f0;
  border: 1px solid #ffccc7;
  border-radius: 4px;
  color: #f5222d;
  font-size: 12px;
}

.engine-success {
  padding: 10px;
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  border-radius: 4px;
  color: #52c41a;
  font-size: 12px;
}

/* ========== 响应式样式 ========== */
@media (max-width: 768px) {
  .calculation-summary-item {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .calculation-summary-value {
    margin-top: 2px;
  }
  
  .validation-error-message {
    font-size: 11px;
    padding: 4px 8px;
  }
}

/* ========== 打印样式 ========== */
@media print {
  .validation-error-message,
  .permission-hint,
  .calculator-button,
  .calculation-summary {
    display: none !important;
  }
  
  .validation-error,
  .validation-success {
    border-color: #000 !important;
    background-color: transparent !important;
  }
}

/* ========== 高对比度模式 ========== */
@media (prefers-contrast: high) {
  .validation-error {
    border-color: #ff0000 !important;
    background-color: #fff0f0 !important;
  }
  
  .validation-success {
    border-color: #008000 !important;
    background-color: #f0fff0 !important;
  }
  
  .permission-disabled {
    opacity: 0.3;
  }
}

/* ========== 深色模式支持 ========== */
@media (prefers-color-scheme: dark) {
  .validation-error-message {
    background: #2a1215;
    border-color: #58181c;
    color: #ff7875;
  }
  
  .validation-error {
    border-color: #ff7875 !important;
    background-color: #2a1215 !important;
  }
  
  .validation-success {
    border-color: #73d13d !important;
    background-color: #162312 !important;
  }
  
  .calculation-summary {
    background: #1f1f1f;
    border-color: #434343;
  }
  
  .calculation-summary h4 {
    color: #d9d9d9;
  }
  
  .calculation-summary-label {
    color: #8c8c8c;
  }
  
  .calculation-summary-value {
    color: #d9d9d9;
  }
  
  .calculation-summary-item:last-child {
    border-color: #434343;
  }
  
  .engine-error {
    background: #2a1215;
    border-color: #58181c;
    color: #ff7875;
  }
  
  .engine-success {
    background: #162312;
    border-color: #274916;
    color: #73d13d;
  }
}