/* Image Crop Modal Styles */
.image-crop-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  z-index: 9999;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(2px);
}

.image-crop-modal.active {
  display: flex;
}

.crop-container {
  background: white;
  padding: 30px;
  border-radius: 12px;
  max-width: 90%;
  max-height: 90%;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: cropModalIn 0.3s ease-out;
}

@keyframes cropModalIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.crop-container h3 {
  margin: 0 0 20px 0;
  text-align: center;
  color: #333;
  font-size: 18px;
  font-weight: 600;
}

.crop-area {
  position: relative;
  overflow: hidden;
  border: 3px solid #007cba;
  margin-bottom: 25px;
  background: #f8f9fa;
  border-radius: 8px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 350px;
}

.crop-area::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px dashed rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  pointer-events: none;
  z-index: 1;
}

.crop-image {
  display: block;
  cursor: move;
  user-select: none;
  transition: none;
  position: absolute;
  z-index: 0;
  min-width: 110%;
  min-height: 110%;
  object-fit: cover;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.crop-image:hover {
  cursor: grab;
}

.crop-image:active {
  cursor: grabbing;
}

.crop-controls {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 20px;
}

.crop-btn {
  background: #007cba;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  flex: 1;
  max-width: 120px;
}

.crop-btn:hover {
  background: #005a87;
  transform: translateY(-1px);
}

.crop-btn:active {
  transform: translateY(0);
}

.crop-btn.secondary {
  background: #6c757d;
}

.crop-btn.secondary:hover {
  background: #545b62;
}

.crop-help-text {
  text-align: center;
  color: #666;
  font-size: 13px;
  margin-bottom: 15px;
  line-height: 1.4;
  padding: 10px;
  background: #f0f7ff;
  border-radius: 6px;
  border-left: 4px solid #007cba;
}

.crop-help-text::before {
  content: "💡 ";
  margin-right: 8px;
}

/* Loại bỏ viền đen bằng cách đảm bảo container không có padding/margin internal */
.crop-area * {
  box-sizing: border-box;
}

.crop-area img {
  vertical-align: top;
  border: none;
  outline: none;
}
.crop-container.loading {
  pointer-events: none;
  opacity: 0.7;
}

.crop-container.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #007cba;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
  .crop-container {
    padding: 20px;
    margin: 20px;
  }

  .crop-controls {
    flex-direction: column;
  }

  .crop-btn {
    max-width: none;
  }

  .crop-area {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .crop-container {
    padding: 15px;
    margin: 10px;
  }

  .crop-container h3 {
    font-size: 16px;
  }

  .crop-help-text {
    font-size: 12px;
  }
}

/* Upload button loading state enhancement */
.upload-image-btn.loading {
  position: relative;
  pointer-events: none;
}

.upload-image-btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
