/* Uses .panda-container from panda-shared.css */
/* Uses .hidden from panda-shared.css */

.ai-upload-area {
  position: relative;
}

/* Processing Overlay Styles */
.ai-processing-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.ai-processing-overlay.hidden {
  display: none;
}

.ai-processing-dialog {
  background-color: #fff;
  border-radius: 12px;
  padding: 0;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
  animation: ai-dialog-enter 0.3s ease-out;
}

@keyframes ai-dialog-enter {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.ai-dialog-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e5e1db;
  border-collapse: separate;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.ai-dialog-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  flex: 1;
  text-align: center;
}

.ai-overlay-close {
  background: none;
  border: none !important;
  outline: none !important;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 0 !important;
  min-width: unset !important;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  transition: color 0.2s;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: none !important;
}

.ai-overlay-close:hover {
  color: #333;
}

.ai-overlay-close:active {
  color: #000;
}

.ai-overlay-close:focus {
  outline: none !important;
  box-shadow: none !important;
}

.ai-overlay-close:disabled,
.ai-overlay-close[disabled] {
  opacity: 0.3;
  cursor: not-allowed;
  color: #ccc;
}

.ai-dialog-content {
  padding: 40px 24px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.ai-dialog-controls {
  padding: 0;
}

.ai-dialog-controls .panda-section {
  margin: 0;
  border: none;
  background-color: transparent;
  padding: 0;
  border-bottom: 1px solid #e5e1db;
}

.ai-dialog-controls .panda-section:last-child {
  border-bottom: none;
}

.ai-dialog-controls .control-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.ai-dialog-controls .control-checkbox {
  margin-top: 2px;
  flex-shrink: 0;
}

.ai-dialog-controls .control-description {
  font-size: 12px;
  color: #666;
  line-height: 1.4;
}

.ai-dialog-footer {
  padding: 20px 24px;
  border-top: 1px solid #e5e1db;
  background-color: #f9f7f4;
}

/* Loading state styles */
.ai-dialog-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
}

.ai-spinner-large {
  width: 100px;
  height: 100px;
  position: relative;
  animation: ai-bounce 1.2s ease-in-out infinite;
}

/* Panda face with rotating elements */
.ai-spinner-large::before {
  content: '🐼';
  font-size: 80px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: ai-panda-rotate 2s linear infinite;
}

@keyframes ai-panda-rotate {
  0% {
    transform: translate(-50%, -50%) rotateZ(0deg);
  }

  100% {
    transform: translate(-50%, -50%) rotateZ(360deg);
  }
}

@keyframes ai-bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-15px);
  }
}

/* Floating elements around spinner */
.ai-spinner-large::after {
  content: '✨';
  position: absolute;
  font-size: 24px;
  animation: ai-orbit 3s linear infinite;
}

@keyframes ai-orbit {
  0% {
    transform: rotate(0deg) translateX(50px) rotate(0deg);
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    transform: rotate(360deg) translateX(50px) rotate(-360deg);
    opacity: 1;
  }
}

.ai-progress-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.ai-progress-percentage {
  font-size: 56px;
  font-weight: 800;
  color: #333;
  line-height: 1;
  letter-spacing: -2px;
}

.ai-progress-label {
  font-size: 16px;
  color: #666;
  font-weight: 600;
  min-height: 24px;
  animation: ai-pulse-text 2s ease-in-out infinite;
}

@keyframes ai-pulse-text {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

.ai-progress-bar {
  width: 100%;
  max-width: 320px;
  height: 6px;
  background-color: #e5e1db;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 12px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #333 0%, #666 50%, #333 100%);
  background-size: 200% 100%;
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 3px;
  animation: ai-shimmer 1.5s ease-in-out infinite;
}

@keyframes ai-shimmer {

  0%,
  100% {
    background-position: 200% center;
  }

  50% {
    background-position: -200% center;
  }
}

/* Result state styles */
.ai-dialog-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.ai-result-image {
  width: 100%;
  max-width: 300px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e5e1db;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ai-result-image img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* Desktop: larger image preview in result dialog */
@media (min-width: 768px) {
  .ai-result-image {
    max-width: 550px;
  }
}

.ai-result-text {
  text-align: center;
}

.ai-result-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.ai-result-description {
  margin: 0;
  font-size: 14px;
  color: #666;
}

.ai-file-input {
  display: none;
}

.ai-upload-label {
  display: block;
  border: 2px dashed #d1ccc4;
  border-radius: 6px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: #fff;
}

.ai-upload-label:hover {
  border-color: #a39d93;
  background-color: #fefdfb;
}

.ai-upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ai-upload-icon {
  color: #666;
}

.ai-upload-text {
  color: #333;
  font-size: 14px;
}

.ai-processing-content {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.ai-image-preview {
  position: relative;
  display: inline-block;
  border-radius: 6px;
  overflow: hidden;
  background-color: #fff;
  border: 1px solid #e5e1db;
  flex-shrink: 0;
}

.ai-image-preview img {
  display: block;
  max-width: 200px;
  max-height: 200px;
  object-fit: contain;
}

.ai-remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  min-width: unset;
  padding: unset;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.95);
  color: #333;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-remove-btn:hover {
  background-color: #ef4444;
  color: white;
  border-color: #ef4444;
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.ai-loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-width: 200px;
}

.ai-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e1db;
  border-top-color: #666;
  border-radius: 50%;
  animation: ai-spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes ai-spin {
  to {
    transform: rotate(360deg);
  }
}

.ai-loading-text {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin: 0 0 8px 0;
  text-align: center;
}

.ai-loading-percentage {
  font-size: 24px;
  font-weight: 700;
  color: #666;
  margin: 8px 0;
  text-align: center;
}

.ai-loading-subtext {
  font-size: 12px;
  color: #666;
  margin: 8px 0 0 0;
  text-align: center;
}

.ai-add-to-cart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  background-color: #333;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.ai-processing-dialog .ai-add-to-cart-btn {
  margin-top: 0;
}

.ai-add-to-cart-btn:hover:not(:disabled) {
  background-color: #000;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  color: white;
}

.ai-add-to-cart-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-add-to-cart-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-add-to-cart-btn svg {
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .ai-processing-content {
    flex-direction: column;
    align-items: center;
  }

  .ai-loading-indicator {
    width: 100%;
  }
}

/* Cropper Modal Styles */
.ai-cropper-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.ai-cropper-modal-content {
  background-color: #fff;
  border-radius: 12px;
  max-width: 90vw;
  max-height: 90vh;
  width: 800px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.ai-cropper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e1db;
}

.ai-cropper-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.ai-cropper-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1;
}

.ai-cropper-close:hover {
  background-color: #f3f1ed;
  color: #333;
}

.ai-cropper-body {
  padding: 24px;
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-cropper-container {
  max-width: 100%;
  max-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-cropper-container img {
  max-width: 100%;
  max-height: 60vh;
  display: block;
}

.ai-cropper-footer {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #e5e1db;
  justify-content: flex-end;
}

.ai-cropper-btn {
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.ai-cropper-btn-secondary {
  background-color: #f3f1ed;
  color: #333;
}

.ai-cropper-btn-secondary:hover {
  background-color: #e5e1db;
}

.ai-cropper-btn-primary {
  background-color: #333;
  color: white;
}

.ai-cropper-btn-primary:hover {
  background-color: #000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@media (max-width: 640px) {
  .ai-cropper-modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .ai-cropper-container {
    max-height: 50vh;
  }

  .ai-cropper-container img {
    max-height: 50vh;
  }

  .ai-cropper-footer {
    flex-direction: column;
  }

  .ai-cropper-btn {
    width: 100%;
  }
}

/* Controls Dialog Styles */
.ai-controls-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.ai-controls-dialog.hidden {
  display: none;
}

.ai-controls-dialog-content {
  background-color: #fff;
  border-radius: 12px;
  padding: 0;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
  animation: ai-dialog-enter 0.3s ease-out;
}

.ai-controls-dialog-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e5e1db;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-controls-dialog-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  flex: 1;
  text-align: center;
}

.ai-controls-dialog-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-controls-dialog-subtitle {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.ai-controls-description {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
  margin: 0;
}

.ai-controls-dialog-footer {
  padding: 20px 24px;
  border-top: 1px solid #e5e1db;
  background-color: #f9f7f4;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-controls-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.ai-controls-btn-yes {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.ai-controls-btn-yes:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.ai-controls-btn-yes:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.ai-controls-btn-no {
  background-color: #f3f1ed;
  color: #666;
  border: 2px solid #e5e1db;
}

.ai-controls-btn-no:hover:not(:disabled) {
  background-color: #e5e1db;
  color: #333;
  border-color: #d1ccc4;
}

.ai-controls-btn-no:active:not(:disabled) {
  background-color: #d1ccc4;
}

.ai-controls-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

@media (max-width: 640px) {
  .ai-controls-dialog-content {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .ai-controls-dialog-body {
    padding: 20px 16px;
  }
}