/* ============================================================
   Oletrak Image Editor Modal Styles — full-screen, touch-friendly
   ============================================================ */

.image-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.image-editor-modal.open {
  display: flex;
}

.image-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.image-editor-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  background: #1a1a2e;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: none;
  animation: none;
  z-index: 1;
}

/* Header */
.image-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: var(--neutral-900, var(--neutral-900));
  flex-shrink: 0;
  min-height: 48px;
}

.image-editor-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--neutral-50);
}

.image-editor-actions {
  display: flex;
  gap: 0.5rem;
}

/* Buttons */
.ie-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.ie-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ie-btn-primary {
  background: var(--brand-orange-500, var(--brand-orange-500));
  color: #1a0d00;
  border-color: var(--brand-orange-500, var(--brand-orange-500));
}

.ie-btn-primary:hover:not(:disabled) {
  background: #e86c0e;
  border-color: #e86c0e;
}

.ie-btn-secondary {
  background: rgba(255,255,255,0.1);
  color: var(--neutral-200);
  border-color: rgba(255,255,255,0.15);
}

.ie-btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.25);
}

.ie-btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  background: rgba(255,255,255,0.08);
  color: var(--neutral-200);
  border-color: rgba(255,255,255,0.12);
  border-radius: 10px;
}

.ie-btn-icon:hover:not(:disabled) {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.25);
  color: var(--white);
}

.ie-btn-icon svg {
  width: 20px;
  height: 20px;
}

/* Toolbar — horizontal scroll on small screens */
.image-editor-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--neutral-900, var(--neutral-900));
  border-bottom: 1px solid rgba(255,255,255,0.08);
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.image-editor-toolbar::-webkit-scrollbar {
  display: none;
}

.ie-toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.ie-toolbar-group:not(:last-child)::after {
  content: '';
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.12);
  margin-left: 0.375rem;
}

#ie-aspect-ratio {
  padding: 0.5rem 2.5rem 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--neutral-200);
  background: rgba(255,255,255,0.08) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 0.5rem center;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  min-width: 130px;
}

#ie-aspect-ratio:hover {
  border-color: rgba(255,255,255,0.25);
}

#ie-aspect-ratio:focus {
  outline: none;
  border-color: var(--brand-orange-500, var(--brand-orange-500));
  box-shadow: 0 0 0 3px rgba(255, 127, 17, 0.2);
}

/* Canvas area — takes ALL remaining space */
.image-editor-canvas {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0d1a;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

#ie-image {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* Cropper.js overrides — maximize the crop area */
.cropper-container {
  width: 100% !important;
  height: 100% !important;
  min-height: 200px;
}

.cropper-view-box,
.cropper-face {
  border-radius: 4px;
}

.cropper-dashed.dashed-h,
.cropper-dashed.dashed-v {
  opacity: 0.4;
}

.cropper-center {
  width: 8px;
  height: 8px;
  background: var(--brand-orange-500, var(--brand-orange-500));
  opacity: 0.85;
}

.cropper-center::before {
  border: 1px solid var(--brand-orange-500, var(--brand-orange-500));
}

/* Make crop handles bigger for touch */
.cropper-line,
.cropper-point {
  width: 14px !important;
  height: 14px !important;
}

.cropper-line::after {
  background: var(--brand-orange-500, var(--brand-orange-500));
}

.cropper-point::after {
  background: var(--brand-orange-500, var(--brand-orange-500));
  border-radius: 2px;
}

/* Footer */
.image-editor-footer {
  padding: 0.4rem 1rem;
  background: var(--neutral-900, var(--neutral-900));
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.ie-hint {
  display: block;
  font-size: 0.7rem;
  color: #6b7280;
  text-align: center;
}

/* Toast notifications */
.ie-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--white);
  background: #1f2937;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 11000;
  animation: toastIn 0.3s ease forwards;
}

.ie-toast-error {
  background: var(--danger-600, var(--danger-600));
}

@keyframes toastIn {
  to { transform: translateX(-50%) translateY(0); }
}

/* ---- Mobile: full-screen, touch-optimized ---- */
@media (max-width: 640px) {
  .image-editor-container {
    border-radius: 0;
  }

  .image-editor-header {
    padding: 0.5rem 0.75rem;
    min-height: 44px;
  }

  .image-editor-header h2 {
    font-size: 0.9rem;
  }

  .ie-btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.8rem;
  }

  .image-editor-toolbar {
    padding: 0.4rem 0.5rem;
    gap: 0.4rem;
  }

  .ie-toolbar-group:not(:last-child)::after {
    display: none;
  }

  .ie-btn-icon {
    width: 44px;
    height: 44px;
  }

  #ie-aspect-ratio {
    min-width: auto;
    flex: 1;
    text-align: center;
  }

  .image-editor-canvas {
    min-height: 0;
  }

  .image-editor-footer {
    padding: 0.3rem 0.75rem;
  }

  .ie-hint {
    font-size: 0.65rem;
  }

  /* Bigger touch targets on mobile */
  .cropper-line,
  .cropper-point {
    width: 20px !important;
    height: 20px !important;
  }
}

/* ---- Tablet ---- */
@media (min-width: 641px) and (max-width: 1024px) {
  .image-editor-canvas {
    min-height: 0;
  }
}

/* Dark mode (already dark, but keep consistent) */
@media (prefers-color-scheme: dark) {
  /* Already dark by default — no changes needed */
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .ie-btn-primary {
    background: var(--brand-orange-500, var(--brand-orange-500));
    border-width: 2px;
  }

  .ie-btn-icon {
    border-width: 2px;
  }

  .cropper-center {
    background: var(--brand-orange-500, var(--brand-orange-500));
    border: 2px solid var(--white);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .image-editor-backdrop,
  .image-editor-container,
  .ie-toast {
    animation: none;
  }
}
