/* Text Replacer Specific Styles */

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.textarea-field {
  min-height: 200px;
  font-family: monospace;
  line-height: 1.5;
  resize: vertical;
}

.textarea-field[readonly] {
  background: #f8f9fa;
  cursor: default;
}

.rules-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.rule-item {
  background: rgba(255,255,255,0.8);
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 12px;
  transition: all 0.3s ease;
  position: relative;
}

.rule-item:hover {
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.rule-item.disabled {
  opacity: 0.6;
  background: rgba(248, 249, 250, 0.8);
}

.rule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.rule-number {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.rule-controls {
  display: flex;
  gap: 4px;
}

.btn-icon {
  background: none;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.btn-icon:hover {
  background: #f8f9fa;
  border-color: #667eea;
  color: #667eea;
}

.btn-icon.danger:hover {
  background: #f8d7da;
  border-color: #dc3545;
  color: #dc3545;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.rule-options {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.option-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: #667eea;
}

.option-item label {
  font-size: 12px;
  color: #495057;
  cursor: pointer;
  user-select: none;
}

.stats {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  font-size: 12px;
  flex-wrap: wrap;
}

.stat-item {
  background: rgba(255,255,255,0.9);
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-label {
  color: #6c757d;
  font-weight: 500;
}

.stat-value {
  font-weight: 600;
  color: #2c3e50;
  font-family: monospace;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.template-item {
  background: rgba(255,255,255,0.8);
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.template-item:hover {
  background: rgba(102, 126, 234, 0.1);
  border-color: #667eea;
  transform: translateY(-1px);
}

.template-title {
  font-size: 13px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 6px;
}

.template-desc {
  font-size: 11px;
  color: #6c757d;
  margin-bottom: 8px;
}

.template-rule {
  font-family: monospace;
  font-size: 11px;
  background: #f8f9fa;
  padding: 4px 6px;
  border-radius: 3px;
  margin-bottom: 4px;
  word-break: break-all;
}

.template-find {
  color: #dc3545;
}

.template-replace {
  color: #28a745;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

@media (max-width: 768px) {
  .templates-grid {
    grid-template-columns: 1fr;
  }
  
  .rule-options {
    justify-content: center;
  }
  
  .stats {
    justify-content: center;
  }
  
  .toolbar {
    justify-content: center;
  }
}

/* 动画效果 */
.rule-item.updated {
  animation: highlight 0.5s ease-in-out;
}

@keyframes highlight {
  0% { background: rgba(255,255,255,0.8); }
  50% { background: rgba(102, 126, 234, 0.15); }
  100% { background: rgba(255,255,255,0.8); }
}

.textarea-field.updated {
  animation: glow 0.5s ease-in-out;
}

@keyframes glow {
  0% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0); }
  50% { box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.3); }
  100% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0); }
}

/* 匹配高亮 */
.match-highlight {
  background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
  border: 1px solid #ffc107;
}

.replace-highlight {
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
  border: 1px solid #28a745;
}

/* 错误状态 */
.rule-item.error {
  border-color: #dc3545;
  background: rgba(248, 215, 218, 0.3);
}

.input-field.error {
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #6c757d;
  font-style: italic;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
  margin-bottom: 12px;
}