/* ==========================================================================
   Kids Paradise - Dual-Tab Rich Text & HTML Code Editor
   Light Modern Theme, Full WYSIWYG Toolbar, Floating Bubble, Code Editor
   ========================================================================== */

:root {
  --editor-primary: #ff3366;
  --editor-primary-hover: #e02456;
  --editor-bg: #ffffff;
  --editor-border: #e2e8f0;
  --editor-text: #0f172a;
  --editor-muted: #64748b;
  --editor-toolbar-bg: #f8fafc;
  --editor-code-bg: #0f172a;
  --editor-code-text: #38bdf8;
}

.rich-editor-wrapper {
  background: var(--editor-bg);
  border: 1px solid var(--editor-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}

.rich-editor-wrapper.is-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999999;
  border-radius: 0;
  border: none;
  height: 100vh;
}

/* --- Top Header & Mode Switcher --- */
.editor-top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--editor-border);
  flex-wrap: wrap;
  gap: 10px;
}

.editor-tabs-nav {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}

.editor-tab-btn {
  border: none;
  background: transparent;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--editor-muted);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.editor-tab-btn:hover {
  color: var(--editor-text);
}

.editor-tab-btn.active {
  background: #ffffff;
  color: var(--editor-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.editor-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-editor-action {
  background: #f8fafc;
  border: 1px solid var(--editor-border);
  color: #334155;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-editor-action:hover {
  background: #fff1f2;
  border-color: #ff3366;
  color: #ff3366;
}

.btn-editor-action.btn-danger-action:hover {
  background: #fef2f2;
  border-color: #ef4444;
  color: #ef4444;
}

/* --- Visual Editor Toolbar --- */
.rich-editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--editor-toolbar-bg);
  border-bottom: 1px solid var(--editor-border);
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: #cbd5e1;
  margin: 0 6px;
  flex-shrink: 0;
}

.toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #475569;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.toolbar-btn:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  color: var(--editor-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.toolbar-btn.active {
  background: #fff1f2;
  border-color: #ff3366;
  color: #ff3366;
}

.toolbar-select {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.toolbar-select:focus {
  border-color: var(--editor-primary);
}

/* Toolbar Color Swatch Picker */
.toolbar-color-wrap {
  position: relative;
  display: inline-flex;
}

.toolbar-color-popover {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  z-index: 200;
  width: 170px;
}

.toolbar-color-popover.show {
  display: grid;
}

.tb-swatch {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid #e2e8f0;
  transition: transform 0.15s;
}

.tb-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.tb-custom-color-row {
  grid-column: span 5;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #f1f5f9;
  font-size: 0.78rem;
  color: #64748b;
}

.tb-custom-color-row input[type="color"] {
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

/* --- Visual Canvas (WYSIWYG Writing Area) --- */
.rich-editor-canvas-container {
  flex: 1;
  position: relative;
  overflow-y: auto;
  min-height: 480px;
  max-height: 75vh;
  background: #ffffff;
}

.rich-editor-canvas {
  min-height: 480px;
  padding: 36px 48px;
  outline: none;
  color: #1e293b;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1.05rem;
  line-height: 1.8;
  word-break: break-word;
}

.rich-editor-canvas:empty:before {
  content: 'Start typing your page story, paragraphs, headings, or paste your text here...';
  color: #94a3b8;
  font-style: italic;
  pointer-events: none;
}

/* Canvas Typography & Elements Styling */
.rich-editor-canvas h1,
.rich-editor-canvas h2,
.rich-editor-canvas h3,
.rich-editor-canvas h4,
.rich-editor-canvas h5,
.rich-editor-canvas h6 {
  color: #0f172a;
  font-weight: 800;
  margin: 1.5em 0 0.5em;
  line-height: 1.3;
}

.rich-editor-canvas h1 { font-size: 2.2rem; }
.rich-editor-canvas h2 { font-size: 1.75rem; border-bottom: 1px solid #f1f5f9; padding-bottom: 8px; }
.rich-editor-canvas h3 { font-size: 1.4rem; }
.rich-editor-canvas h4 { font-size: 1.2rem; }
.rich-editor-canvas h5 { font-size: 1.05rem; }
.rich-editor-canvas h6 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.5px; }

.rich-editor-canvas p {
  margin: 0 0 1.2em;
  color: #334155;
}

.rich-editor-canvas a {
  color: #ff3366;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rich-editor-canvas a:hover {
  color: #e02456;
}

.rich-editor-canvas img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 16px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.rich-editor-canvas blockquote {
  border-left: 4px solid #ff3366;
  background: #fff1f2;
  color: #1e293b;
  padding: 16px 24px;
  border-radius: 0 10px 10px 0;
  margin: 20px 0;
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.7;
}

.rich-editor-canvas pre,
.rich-editor-canvas code {
  font-family: 'Fira Code', Consolas, Monaco, monospace;
}

.rich-editor-canvas pre {
  background: #0f172a;
  color: #38bdf8;
  padding: 16px 20px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 20px 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.rich-editor-canvas hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #cbd5e1, transparent);
  margin: 32px 0;
}

.rich-editor-canvas table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}

.rich-editor-canvas table th,
.rich-editor-canvas table td {
  border: 1px solid #e2e8f0;
  padding: 12px 16px;
  text-align: left;
}

.rich-editor-canvas table th {
  background: #f8fafc;
  font-weight: 800;
  color: #0f172a;
}

.rich-editor-canvas table tr:nth-child(even) {
  background: #fdfdfd;
}

.rich-editor-canvas ul,
.rich-editor-canvas ol {
  margin: 0 0 1.2em 24px;
  color: #334155;
}

.rich-editor-canvas li {
  margin-bottom: 6px;
}

/* Callout / Alert Box */
.rich-callout-box {
  padding: 16px 20px;
  border-radius: 10px;
  margin: 20px 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-left: 4px solid #3b82f6;
  background: #eff6ff;
  color: #1e40af;
}

.rich-callout-box.callout-success { border-left-color: #22c55e; background: #f0fdf4; color: #166534; }
.rich-callout-box.callout-warning { border-left-color: #f59e0b; background: #fffbeb; color: #92400e; }
.rich-callout-box.callout-danger { border-left-color: #ef4444; background: #fef2f2; color: #991b1b; }

/* Responsive Video Embed Container */
.rich-video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 12px;
  margin: 20px 0;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.rich-video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Contact Page Grid & Form in Editor Canvas & Live Preview */
.contact-page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin-top: 24px;
  align-items: stretch;
}

.contact-form-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.contact-info-column {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.contact-hours-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.03);
  flex-shrink: 0;
}

.contact-map-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  flex: 1;
  min-height: 280px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.03);
  display: flex;
}

.contact-map-card iframe {
  border: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  flex: 1;
  display: block;
}

.contact-form-group {
  margin-bottom: 18px;
}

.contact-form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 6px;
}

.contact-form-control {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  outline: none;
  box-sizing: border-box;
}

.elementor-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #ff3366 0%, #ff527b 100%);
  color: #ffffff !important;
  font-weight: 700;
  border-radius: 10px;
  padding: 12px 24px;
  border: none;
  text-decoration: none;
  cursor: pointer;
}

@media (max-width: 860px) {
  .contact-page-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .contact-map-card {
    min-height: 300px;
    height: 300px;
  }
}

/* --- HTML Source Code Pane --- */
.rich-code-pane {
  display: none;
  flex-direction: column;
  background: var(--editor-code-bg);
  min-height: 520px;
  position: relative;
}

.code-pane-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  color: #94a3b8;
  font-size: 0.8rem;
}

.html-code-textarea {
  width: 100%;
  min-height: 480px;
  padding: 20px;
  background: transparent;
  color: #f8fafc;
  font-family: 'Fira Code', 'Courier New', Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  border: none;
  outline: none;
  resize: vertical;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-all;
}

/* --- Bottom Status Bar --- */
.editor-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: #f8fafc;
  border-top: 1px solid var(--editor-border);
  font-size: 0.78rem;
  color: #64748b;
}

.editor-status-counts {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ==========================================================================
   FLOATING SELECTION POPUP TOOLBAR (MEDIUM / NOTION STYLE)
   ========================================================================== */
.floating-selection-toolbar {
  position: absolute;
  z-index: 99999;
  display: none;
  align-items: center;
  background: #0f172a;
  color: #f8fafc;
  padding: 5px 8px;
  border-radius: 10px;
  box-shadow: 0 12px 30px -4px rgba(15, 23, 42, 0.45), 0 6px 12px -4px rgba(15, 23, 42, 0.25);
  gap: 3px;
  transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(4px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.floating-selection-toolbar.active {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.floating-selection-toolbar::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: #0f172a transparent transparent transparent;
}

.floating-selection-toolbar.arrow-top::after {
  bottom: auto;
  top: -6px;
  border-width: 0 6px 6px 6px;
  border-color: transparent transparent #0f172a transparent;
}

.floating-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  position: relative;
}

.floating-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.floating-btn.active {
  background: #ff3366;
  color: #ffffff;
}

.floating-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 4px;
}

.floating-select {
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.floating-color-popover {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  z-index: 100000;
}

.floating-color-popover.show {
  display: grid;
}

.swatch-item {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}

.swatch-item:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.floating-custom-color-input {
  grid-column: span 4;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid #334155;
  font-size: 0.75rem;
  color: #94a3b8;
}

.floating-custom-color-input input[type="color"] {
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

/* ==========================================================================
   MODALS (IMAGE UPLOAD, VIDEO EMBED, TABLE GENERATOR, PREVIEW)
   ========================================================================== */
.editor-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000000;
  padding: 20px;
}

.editor-modal.show {
  display: flex;
}

.editor-modal-content {
  background: #ffffff;
  border-radius: 14px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.editor-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.editor-modal-header h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
}

.editor-modal-close {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  cursor: pointer;
  color: #64748b;
  line-height: 1;
}

.editor-modal-close:hover {
  color: #0f172a;
}

.editor-modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.editor-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.modal-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.2s;
}

.modal-dropzone:hover,
.modal-dropzone.drag-over {
  border-color: #ff3366;
  background: #fff1f2;
}

.modal-tabs-nav {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 18px;
}

.modal-tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748b;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.modal-tab-btn.active {
  color: #ff3366;
  border-bottom-color: #ff3366;
}

/* Device Preview Frame */
.preview-modal-content {
  max-width: 960px;
  height: 85vh;
  display: flex;
  flex-direction: column;
}

.preview-body-container {
  flex: 1;
  overflow-y: auto;
  background: #f1f5f9;
  padding: 20px;
  display: flex;
  justify-content: center;
}

.preview-frame-device {
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  border-radius: 12px;
  width: 100%;
  max-width: 100%;
  padding: 36px;
  transition: all 0.3s ease;
  min-height: 100%;
}
