/* ==============================================================================
   ON-PAGE VISUAL EDITOR STYLESHEET
   Pondok Pesantren Mamba'ul Hikmah
   Modern Islamic Emerald & Glassmorphism Aesthetics
   ============================================================================== */

:root {
  --ope-emerald-primary: #059669;
  --ope-emerald-hover: #047857;
  --ope-emerald-dark: #064e3b;
  --ope-gold-accent: #f59e0b;
  --ope-surface-dark: #0f172a;
  --ope-surface-glass: rgba(15, 23, 42, 0.92);
}

/* Studio Header / Floating Top Toolbar */
#ope-studio-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999999;
  background: var(--ope-surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.4);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: #f8fafc;
  padding: 0 16px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

#ope-studio-bar.ope-hidden {
  transform: translateY(-100%);
  pointer-events: none;
  opacity: 0;
}

/* Offset page content when studio bar is visible */
body.ope-active-mode {
  padding-top: 58px !important;
}

/* Brand & Status */
.ope-brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ope-brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(5, 150, 105, 0.25);
  border: 1px solid rgba(5, 150, 105, 0.5);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  color: #6ee7b7;
  letter-spacing: 0.02em;
}

.ope-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: ope-pulse 2s infinite;
}

@keyframes ope-pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.ope-brand-title {
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ope-page-badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: #cbd5e1;
  font-weight: 600;
}

/* Actions Toolbar */
.ope-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ope-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.18s ease;
  white-space: nowrap;
  text-decoration: none;
}

.ope-btn-primary {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.4);
}
.ope-btn-primary:hover {
  background: linear-gradient(135deg, #10b981, #059669);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(5, 150, 105, 0.6);
}

.ope-btn-save-dirty {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.45) !important;
  animation: ope-save-glow 1.8s infinite;
}

@keyframes ope-save-glow {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.ope-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.ope-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.ope-btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.ope-btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
}

/* Page Selector Dropdown */
.ope-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e2e8f0;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}
.ope-select option {
  background: #0f172a;
  color: #ffffff;
}

/* Admin Launcher Floating Pill (when toolbar is minimized) */
#ope-launcher-pill {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999990;
  background: linear-gradient(135deg, #059669, #064e3b);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 9999px;
  box-shadow: 0 10px 25px -3px rgba(5, 150, 105, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
#ope-launcher-pill:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 16px 32px -4px rgba(5, 150, 105, 0.7);
}

/* EDITABLE ELEMENTS HIGHLIGHTS (ACTIVE ONLY IN EDIT MODE) */
body.ope-edit-mode [data-edit-key] {
  position: relative !important;
  transition: outline 0.15s ease, background-color 0.15s ease;
  cursor: pointer !important;
}

body.ope-edit-mode [data-edit-key]:hover {
  outline: 2px dashed #059669 !important;
  outline-offset: 3px;
  background-color: rgba(5, 150, 105, 0.08) !important;
  border-radius: 4px;
}

body.ope-edit-mode [data-edit-key][contenteditable="true"]:focus {
  outline: 2px solid #10b981 !important;
  outline-offset: 3px;
  background-color: rgba(5, 150, 105, 0.12) !important;
  cursor: text !important;
}

body.ope-edit-mode [data-edit-key].ope-is-dirty {
  outline: 2px solid #f59e0b !important;
  outline-offset: 3px;
}

body.ope-edit-mode [data-edit-key].ope-is-dirty::after {
  content: "✎ Diedit";
  position: absolute;
  top: -20px;
  right: 0;
  background: #f59e0b;
  color: #0f172a;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  z-index: 10000;
  pointer-events: none;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Tooltip petunjuk saat hover di mode edit */
body.ope-edit-mode [data-edit-key]:hover::before {
  content: "✎ Edit Teks";
  position: absolute;
  top: -22px;
  left: 0;
  background: #064e3b;
  color: #a7f3d0;
  border: 1px solid #059669;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 10000;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

body.ope-edit-mode img[data-edit-key]:hover::before {
  content: "🖼️ Klik untuk Ganti Foto" !important;
  background: #0f766e !important;
  color: #ccfbf1 !important;
  border-color: #14b8a6 !important;
}

body.ope-edit-mode a[data-edit-key]:hover::before,
body.ope-edit-mode button[data-edit-key]:hover::before {
  content: "🔗 Edit Tombol (Double-click URL)" !important;
  background: #0369a1 !important;
  color: #e0f2fe !important;
  border-color: #38bdf8 !important;
}

/* Image Editable Indicator */
body.ope-edit-mode img[data-edit-key] {
  cursor: pointer !important;
  display: block;
}
body.ope-edit-mode img[data-edit-key]:hover {
  filter: brightness(0.92);
}

/* Floating Inline Rich-Text Toolbar */
#ope-inline-bubble {
  position: absolute;
  z-index: 9999999;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  font-family: system-ui, sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
#ope-inline-bubble.ope-bubble-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.ope-bubble-btn {
  background: transparent;
  color: #e2e8f0;
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  transition: background 0.15s ease;
}
.ope-bubble-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Visual Media / Image Modal */
.ope-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999999;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.ope-modal-overlay.ope-modal-active {
  opacity: 1;
  pointer-events: auto;
}

.ope-modal-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  max-width: 540px;
  width: 100%;
  padding: 24px;
  color: #f8fafc;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.ope-modal-overlay.ope-modal-active .ope-modal-card {
  transform: scale(1);
}

.ope-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.ope-modal-title {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
}
.ope-modal-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ope-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.ope-dropzone {
  border: 2px dashed rgba(5, 150, 105, 0.5);
  background: rgba(5, 150, 105, 0.05);
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 16px;
}
.ope-dropzone:hover {
  background: rgba(5, 150, 105, 0.12);
  border-color: #059669;
}

.ope-input-field {
  width: 100%;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 10px 14px;
  color: #ffffff;
  font-size: 13px;
  margin-top: 6px;
  outline: none;
  font-family: inherit;
}
.ope-input-field:focus {
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.25);
}

.ope-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Toast Notification */
#ope-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 999999999;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 12px 22px;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
#ope-toast.ope-toast-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
#ope-toast.ope-toast-success {
  border-color: #059669;
  background: #064e3b;
  color: #a7f3d0;
}
#ope-toast.ope-toast-error {
  border-color: #ef4444;
  background: #7f1d1d;
  color: #fca5a5;
}

/* Media Gallery Quick Picker in Modal */
.ope-gallery-presets {
  display: grid;
  grid-cols: 4;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.ope-preset-thumb {
  width: 100%;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
}
.ope-preset-thumb:hover {
  transform: scale(1.05);
  border-color: #059669;
}
