/* Wareed Live Editor overlay — mobile-friendly */

.le-edit-toggle {
  display: none !important;
  position: fixed;
  top: 72px;
  right: 14px;
  z-index: 2800;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  background: #1a1a1a;
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  min-height: 44px;
}
.le-edit-toggle.is-on { background: var(--wareed-red, #d00018); }
.le-edit-toggle[hidden] { display: none !important; }

body.le-edit-mode .le-editable {
  outline: 1px dashed rgba(208, 0, 24, 0.55);
  outline-offset: 3px;
  position: relative;
}
body.le-edit-mode .le-editable:hover,
body.le-edit-mode .le-editable.le-active {
  outline: 2px solid var(--wareed-red, #d00018);
  background: rgba(208, 0, 24, 0.04);
}

.le-toolbar {
  display: none;
  position: absolute;
  top: auto;
  bottom: calc(100% + 8px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 80;
  gap: 6px;
  padding: 6px;
  background: rgba(17, 17, 17, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  flex-wrap: nowrap;
  align-items: center;
  max-width: calc(100vw - 24px);
}
.le-toolbar.le-tb-below {
  bottom: auto;
  top: calc(100% + 8px);
}

body.le-edit-mode .le-editable:hover > .le-toolbar,
body.le-edit-mode .le-editable:focus-within > .le-toolbar,
body.le-edit-mode .le-img-host:hover > .le-toolbar,
body.le-edit-mode .le-editable.le-active > .le-toolbar,
body.le-edit-mode .le-img-host.le-active > .le-toolbar {
  display: inline-flex;
}

.le-tb-btn,
.le-sec-btn {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}
.le-tb-btn:hover,
.le-sec-btn:hover,
.le-tb-btn:active,
.le-sec-btn:active {
  background: rgba(255, 255, 255, 0.22);
}

.le-drag-handle {
  display: none;
  position: absolute;
  top: 4px;
  inset-inline-start: -4px;
  cursor: grab;
  font-size: 0.75rem;
  color: var(--wareed-red, #d00018);
  background: #fff;
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 44px;
  min-height: 44px;
  z-index: 40;
  user-select: none;
  align-items: center;
  justify-content: center;
}
body.le-edit-mode .le-editable:hover > .le-drag-handle,
body.le-edit-mode .le-img-host:hover > .le-drag-handle,
body.le-edit-mode .le-editable.le-active > .le-drag-handle,
body.le-edit-mode .le-img-host.le-active > .le-drag-handle {
  display: inline-flex;
}
.le-dragging { opacity: 0.55; }

.le-section-bar {
  display: none;
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  z-index: 60;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(26, 26, 26, 0.92);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  flex-wrap: wrap;
  max-width: calc(100% - 16px);
}
body.le-edit-mode [data-le-section] > .le-section-bar,
body.le-edit-mode [data-editable-section] > .le-section-bar {
  display: inline-flex;
}
.le-sec-label {
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  margin-inline-end: 4px;
  text-transform: uppercase;
}

.le-section-hidden-admin {
  outline: 2px dashed #999 !important;
  opacity: 0.55;
}
.le-hidden-el {
  outline: 1px dashed #999 !important;
  opacity: 0.4;
}
body:not(.le-edit-mode) .le-hidden-el { display: none !important; }
body:not(.le-edit-mode) [data-le-hidden="1"] { display: none !important; }

.le-img-host { max-width: 100%; }
body.le-edit-mode .le-img-host {
  outline: 1px dashed rgba(208, 0, 24, 0.55);
  outline-offset: 3px;
}

.le-custom-section {
  background: #fff8f8;
  border-top: 1px dashed var(--border, #e5e5e5);
}

.le-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.le-panel-actions .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.le-switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  font-weight: 700;
}

/* Inline text editor (mobile + desktop) */
.le-inline-editor {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3500;
  width: min(92vw, 420px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  padding: 14px;
  font-family: "Cairo", sans-serif;
  border: 1px solid var(--border, #e5e5e5);
  box-sizing: border-box;
}
.le-inline-editor textarea,
.le-inline-editor input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid var(--border, #ddd);
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  box-sizing: border-box;
  resize: vertical;
}
.le-inline-editor textarea:focus,
.le-inline-editor input:focus {
  outline: none;
  border-color: var(--wareed-red, #d00018);
}
.le-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.le-inline-move,
.le-inline-hide {
  min-height: 48px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  background: #fff4f4;
  color: var(--wareed-dark, #4A0009);
}
.le-inline-actions button {
  flex: 1;
  min-height: 48px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.le-inline-ok {
  background: #28a745;
  color: #fff;
}
.le-inline-cancel {
  background: #f0f0f0;
  color: #333;
}

@media (max-width: 768px) {
  .le-edit-toggle {
    top: auto;
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    right: 12px;
  }
  body.wat-toolbar-visible .le-edit-toggle {
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  }
  /* On touch devices, require active selection (no hover-only) */
  body.le-edit-mode .le-editable:hover > .le-toolbar,
  body.le-edit-mode .le-img-host:hover > .le-toolbar {
    display: none;
  }
  body.le-edit-mode .le-editable.le-active > .le-toolbar,
  body.le-edit-mode .le-img-host.le-active > .le-toolbar {
    display: inline-flex;
  }
  body.le-edit-mode .le-editable:hover > .le-drag-handle,
  body.le-edit-mode .le-img-host:hover > .le-drag-handle {
    display: none;
  }
  body.le-edit-mode .le-editable.le-active > .le-drag-handle,
  body.le-edit-mode .le-img-host.le-active > .le-drag-handle {
    display: inline-flex;
  }
  .le-section-bar {
    inset-inline-end: 4px;
    top: 4px;
  }
  .le-sec-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

@media (min-width: 769px) {
  .le-tb-btn,
  .le-sec-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1rem;
  }
}
