/* ===== IMAGE EDITOR MODAL ===== */

.img-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  padding: 16px;
  animation: ieFadeIn 0.2s ease;
}

@keyframes ieFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.img-editor-modal {
  background: #1a1a1d;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
  max-width: 560px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ieSlideUp 0.25s ease;
}

@keyframes ieSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.img-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.img-editor-title {
  font-size: 16px;
  font-weight: 600;
  color: #fafafa;
  margin: 0;
}

.img-editor-close {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}
.img-editor-close:hover { color: #fff; }

/* Cropper container */
.img-editor-container {
  position: relative;
  width: 100%;
  max-height: 55vh;
  overflow: hidden;
  background: #000;
}

.img-editor-container img {
  display: block;
  max-width: 100%;
}

/* Toolbar */
.img-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.ie-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #ccc;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 18px;
}
.ie-tool-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
.ie-tool-btn:active {
  transform: scale(0.95);
}

.ie-tool-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 4px;
}

/* Actions */
.img-editor-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  justify-content: flex-end;
}

.ie-btn {
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-family: inherit;
}

.ie-btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: #ccc;
}
.ie-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.ie-btn-save {
  background: #c8ff00;
  color: #111;
}
.ie-btn-save:hover {
  background: #d4ff33;
}
.ie-btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading state */
.ie-btn-save .ie-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: #111;
  border-radius: 50%;
  animation: ieSpin 0.6s linear infinite;
  margin-right: 6px;
}

.ie-btn-save.ie-loading .ie-spinner { display: inline-block; }
.ie-btn-save.ie-loading { pointer-events: none; opacity: 0.7; }

@keyframes ieSpin {
  to { transform: rotate(360deg); }
}

/* Aspect ratio indicator */
.img-editor-ratio {
  text-align: center;
  padding: 6px;
  font-size: 12px;
  color: #666;
}

/* Toast notification */
.ie-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a1d;
  color: #fafafa;
  padding: 12px 24px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
  font-weight: 500;
  z-index: 3000;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.ie-toast.ie-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ie-toast.ie-toast-success {
  border-color: #c8ff00;
}
.ie-toast.ie-toast-error {
  border-color: #ef4444;
}

/* Cropper.js theme overrides for dark mode */
.cropper-modal {
  background-color: rgba(0, 0, 0, 0.7) !important;
}
.cropper-view-box {
  outline: 2px solid #c8ff00 !important;
  outline-color: rgba(200, 255, 0, 0.75) !important;
}
.cropper-line {
  background-color: #c8ff00 !important;
  opacity: 0.3 !important;
}
.cropper-point {
  background-color: #c8ff00 !important;
  width: 8px !important;
  height: 8px !important;
  opacity: 0.9 !important;
}
.cropper-dashed {
  border-color: rgba(200, 255, 0, 0.4) !important;
}

/* ===== LIGHT MODE ===== */
[data-admin-theme="light"] .img-editor-modal {
  background: #fff;
  border-color: rgba(0,0,0,.1);
}
[data-admin-theme="light"] .img-editor-header {
  border-bottom-color: rgba(0,0,0,.08);
}
[data-admin-theme="light"] .img-editor-title {
  color: #1a1a1a;
}
[data-admin-theme="light"] .img-editor-close {
  color: #999;
}
[data-admin-theme="light"] .img-editor-close:hover {
  color: #333;
}
[data-admin-theme="light"] .img-editor-toolbar {
  border-color: rgba(0,0,0,.08);
}
[data-admin-theme="light"] .ie-tool-btn {
  border-color: rgba(0,0,0,.1);
  background: rgba(0,0,0,.03);
  color: #555;
}
[data-admin-theme="light"] .ie-tool-btn:hover {
  background: rgba(0,0,0,.08);
  color: #222;
  border-color: rgba(0,0,0,.15);
}
[data-admin-theme="light"] .ie-btn-cancel {
  background: rgba(0,0,0,.06);
  color: #555;
}
[data-admin-theme="light"] .ie-btn-cancel:hover {
  background: rgba(0,0,0,.1);
  color: #222;
}
[data-admin-theme="light"] .ie-btn-save {
  background: #16a34a;
  color: #fff;
}
[data-admin-theme="light"] .ie-btn-save:hover {
  background: #15803d;
}
[data-admin-theme="light"] .ie-toast {
  background: #fff;
  color: #1a1a1a;
  border-color: rgba(0,0,0,.1);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
[data-admin-theme="light"] .ie-toast.ie-toast-success {
  border-color: #16a34a;
}
[data-admin-theme="light"] .cropper-view-box {
  outline-color: rgba(22,163,74,.75) !important;
}
[data-admin-theme="light"] .cropper-line {
  background-color: #16a34a !important;
}
[data-admin-theme="light"] .cropper-point {
  background-color: #16a34a !important;
}
[data-admin-theme="light"] .cropper-dashed {
  border-color: rgba(22,163,74,.4) !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .img-editor-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .img-editor-modal {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 16px 16px 0 0;
    animation: ieSlideUpMobile 0.3s ease;
  }
  @keyframes ieSlideUpMobile {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .img-editor-container {
    max-height: 50vh;
  }
  .ie-tool-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  .ie-btn {
    padding: 10px 18px;
    font-size: 13px;
  }
}
