/* ============================================
   Image Editor — Full-screen Light Theme CSS
   ============================================ */

/* Full-screen body */
body.ie-fullscreen {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  background: #f0f0f0;
}
body.ie-fullscreen .video-background,
body.ie-fullscreen .video-overlay {
  display: none;
}

/* ---- Upload Overlay ---- */
.ie-upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
}
.ie-upload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 480px;
  max-width: 90vw;
  padding: 48px 40px;
  background: #fff;
  border-radius: 20px;
  border: 2px dashed #ddd;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-align: center;
}
.ie-upload-card:hover,
.ie-upload-card.dragover {
  border-color: #111;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}
.ie-upload-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: #fff;
  border-radius: 16px;
  font-size: 1.8rem;
  margin-bottom: 20px;
}
.ie-upload-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #111;
  margin: 0 0 8px;
  font-family: 'Nunito', sans-serif;
}
.ie-upload-hint {
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
  margin: 0 0 6px;
}
.ie-upload-formats {
  font-size: 0.8rem;
  color: #999;
  margin: 0 0 24px;
}
.ie-upload-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #999;
  text-decoration: none;
  transition: color 0.15s;
}
.ie-upload-back:hover { color: #333; }

/* ---- Editor App (full screen) ---- */
.ie-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---- Top Bar ---- */
.ie-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  padding: 0 12px;
  height: 44px;
  flex-shrink: 0;
  gap: 8px;
}
/* Logo in topbar */
.ie-logo {
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: #111;
  text-decoration: none;
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.ie-topbar-left, .ie-topbar-center, .ie-topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ie-topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.ie-topbar-btn i { font-size: 1.1rem; }
.ie-topbar-btn:hover { background: #f0f0f0; color: #111; }
.ie-topbar-btn:disabled { opacity: 0.35; cursor: default; }
.ie-topbar-btn:disabled:hover { background: none; color: #555; }
.ie-topbar-divider {
  width: 1px;
  height: 20px;
  background: #e0e0e0;
  margin: 0 4px;
}
.ie-zoom-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #333;
  min-width: 44px;
  text-align: center;
  user-select: none;
}
.ie-status {
  font-size: 0.78rem;
  color: #888;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- Main Editor Area ---- */
.ie-main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ---- Left Toolbar ---- */
.ie-toolbar {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e5e5e5;
  padding: 8px 4px;
  gap: 2px;
  width: 56px;
  flex-shrink: 0;
  align-items: center;
  overflow-y: auto;
}
.ie-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 44px;
  height: 44px;
  padding: 4px;
  border: none;
  background: none;
  border-radius: 10px;
  cursor: pointer;
  color: #888;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  justify-content: center;
}
.ie-tool-btn i { font-size: 1.2rem; }
.ie-tool-btn span { font-size: 0.6rem; font-weight: 600; line-height: 1; }
.ie-tool-btn:hover { background: #f0f0f0; color: #333; }
.ie-tool-btn.active { background: #111; color: #fff; }
.ie-tool-divider {
  width: 36px;
  height: 1px;
  background: #e5e5e5;
  margin: 4px 0;
}

/* ---- Canvas Area ---- */
.ie-canvas-area {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8e8e8;
  /* Checkerboard background for transparency */
  background-image:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  cursor: default;
}
.ie-canvas-area.panning { cursor: grab; }
.ie-canvas-area.panning:active { cursor: grabbing; }
.ie-canvas-area.crosshair { cursor: crosshair; }

.ie-canvas-container {
  position: relative;
  transform-origin: center center;
  box-shadow: 0 2px 20px rgba(0,0,0,0.1);
}
.ie-canvas-container canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}
#mainCanvas { position: relative; }
#overlayCanvas { pointer-events: none; }

/* ---- Right Panel ---- */
.ie-panel {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid #e5e5e5;
  overflow: hidden;
}
.ie-panel-section {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ie-panel-section.ie-props {
  flex: 1;
  min-height: 0;
}
/* Language switcher in topbar */
.ie-topbar .language-switcher { position: relative; }
.ie-topbar .language-menu { z-index: 200; }
.ie-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
}
.ie-panel-header h3 {
  font-size: 0.82rem;
  font-weight: 700;
  color: #333;
  margin: 0;
}
.ie-panel-body {
  padding: 12px 14px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.ie-panel-empty {
  font-size: 0.78rem;
  color: #aaa;
  text-align: center;
  padding: 20px 0;
}

/* Panel Controls */
.ie-control-group {
  margin-bottom: 12px;
}
.ie-control-group:last-child { margin-bottom: 0; }
.ie-control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}
.ie-control-label span:last-child {
  color: #999;
  font-weight: 500;
}
.ie-control-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ie-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #e0e0e0;
  outline: none;
}
.ie-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #333;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.ie-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #333;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.ie-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  color: #333;
  background: #fafafa;
  outline: none;
  transition: border-color 0.15s;
}
.ie-input:focus { border-color: #333; }
.ie-input-sm {
  width: 60px;
  padding: 4px 6px;
  text-align: center;
}
.ie-select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  color: #333;
  background: #fafafa;
  cursor: pointer;
}
.ie-color-input {
  width: 32px;
  height: 32px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  background: none;
}
.ie-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
}
.ie-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: #fff;
  color: #333;
  transition: all 0.15s;
}
.ie-btn:hover { background: #f5f5f5; border-color: #ccc; }
.ie-btn-primary {
  background: #111;
  color: #fff;
  border-color: #111;
}
.ie-btn-primary:hover { background: #333; }
.ie-btn-sm {
  padding: 5px 10px;
  font-size: 0.75rem;
}
.ie-btn-block { width: 100%; }
.ie-btn-group {
  display: flex;
  gap: 4px;
}
.ie-btn-group .ie-btn { flex: 1; }
.ie-btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  color: #555;
  font-size: 1rem;
  transition: all 0.15s;
}
.ie-btn-icon:hover { background: #f0f0f0; color: #111; }
.ie-btn-icon.active { background: #111; color: #fff; border-color: #111; }

/* Filter Presets Grid */
.ie-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.ie-filter-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.ie-filter-item:hover { border-color: #ccc; }
.ie-filter-item.active { border-color: #111; }
.ie-filter-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
}
.ie-filter-name {
  font-size: 0.65rem;
  font-weight: 600;
  color: #555;
  text-align: center;
}

/* ---- Layers Panel ---- */
.ie-layers {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #e5e5e5;
}
.ie-layers-actions {
  display: flex;
  gap: 4px;
}
.ie-layers-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #f0f0f0;
  border-radius: 6px;
  cursor: pointer;
  color: #666;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.ie-layers-btn:hover { background: #e0e0e0; color: #111; }
.ie-layers-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.ie-layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.ie-layer-item:last-child { border-bottom: none; }
.ie-layer-item:hover { background: #f8f8f8; }
.ie-layer-item.active { background: #f0f0f0; }
.ie-layer-item.dragging { opacity: 0.5; }
.ie-layer-visibility {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
}
.ie-layer-visibility:hover { color: #333; }
.ie-layer-visibility.hidden { color: #ccc; }
.ie-layer-lock {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
}
.ie-layer-lock:hover { color: #888; }
.ie-layer-lock.locked { color: #e53935; }
.ie-layer-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  flex-shrink: 0;
  overflow: hidden;
}
.ie-layer-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.ie-layer-name {
  flex: 1;
  font-size: 0.75rem;
  font-weight: 600;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ie-layer-type {
  font-size: 0.65rem;
  color: #aaa;
  font-weight: 500;
}

/* ---- Export Modal ---- */
.ie-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ie-modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  overflow: hidden;
}
.ie-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
}
.ie-modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: #111;
}
.ie-modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #f0f0f0;
  border-radius: 8px;
  cursor: pointer;
  color: #555;
  font-size: 1.1rem;
}
.ie-modal-close:hover { background: #e0e0e0; }
.ie-modal-body { padding: 20px; }
.ie-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  justify-content: flex-end;
}
.ie-export-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.ie-export-row:last-child { margin-bottom: 0; }
.ie-export-row label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #333;
  min-width: 70px;
  flex-shrink: 0;
}
.ie-export-row select, .ie-export-row input[type="text"] {
  flex: 1;
}
.ie-export-row input[type="range"] { flex: 1; }
.ie-export-row span {
  font-size: 0.78rem;
  font-weight: 600;
  color: #888;
  min-width: 36px;
}
.ie-export-preview {
  margin-top: 12px;
  padding: 10px;
  background: #f8f8f8;
  border-radius: 8px;
  text-align: center;
  font-size: 0.78rem;
  color: #666;
  font-weight: 600;
}

/* ---- Mobile Bottom Toolbar ---- */
.ie-mobile-toolbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid #e5e5e5;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  gap: 4px;
  justify-content: space-around;
  z-index: 100;
}
.ie-mobile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: none;
  background: none;
  border-radius: 10px;
  color: #888;
  font-size: 1.3rem;
  cursor: pointer;
}
.ie-mobile-btn.active { background: #111; color: #fff; }

/* ---- Mobile Panel Drawer ---- */
.ie-panel-drawer {
  display: none;
  position: fixed;
  bottom: 60px;
  left: 0;
  right: 0;
  max-height: 50vh;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  z-index: 99;
  overflow-y: auto;
  padding: 16px;
}
.ie-panel-drawer.open { display: block; }

/* ---- Crop Overlay ---- */
.ie-crop-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.ie-crop-mask {
  fill: rgba(0,0,0,0.45);
}
.ie-crop-border {
  stroke: #fff;
  stroke-width: 2;
  fill: none;
}
.ie-crop-handle {
  width: 10px;
  height: 10px;
  background: #fff;
  border: 2px solid #333;
  border-radius: 2px;
  position: absolute;
  pointer-events: all;
  cursor: nwse-resize;
}

/* ============================================
   Responsive
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
  .ie-panel { width: 210px; }
  .ie-tool-btn span { display: none; }
  .ie-tool-btn { height: 38px; }
}

/* Mobile */
@media (max-width: 768px) {
  .ie-topbar { padding: 0 8px; height: 40px; }
  .ie-topbar-btn span { display: none; }
  .ie-toolbar { display: none; }
  .ie-panel { display: none; }
  .ie-mobile-toolbar { display: flex; }
  .ie-app { padding-bottom: 56px; }
}

/* Floating Selection Toolbar */
.ie-sel-toolbar {
  position: fixed;
  z-index: 1000;
  display: flex;
  gap: 2px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 3px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  pointer-events: auto;
}
.ie-sel-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #444;
  transition: background 0.15s, color 0.15s;
}
.ie-sel-btn:hover {
  background: #f0f0f0;
  color: #111;
}
.ie-sel-btn-danger:hover {
  background: #fee;
  color: #d33;
}

@media (max-width: 480px) {
  .ie-topbar-center { display: none; }
  .ie-topbar-right .ie-status { display: none; }
  .ie-upload-card { padding: 32px 20px; }
  .ie-upload-title { font-size: 1.2rem; }
}
