/* ============================================
   QuickHealth — Visual Editor v2 CSS
   Sistema de Edición In-Situ GRANULAR
   Prefijo .qh-ve- evita colisiones.
   ============================================ */

/* ---------- Admin Toolbar ---------- */
.qh-ve-toolbar {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Inter', sans-serif;
  pointer-events: auto;
}

.qh-ve-toggle {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.qh-ve-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
  border-radius: inherit;
}

.qh-ve-toggle:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 40px rgba(99, 102, 241, 0.5);
}

.qh-ve-toggle.active {
  background: linear-gradient(135deg, #EF4444 0%, #F97316 100%);
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.4);
  animation: qh-ve-pulse 2s infinite;
}

@keyframes qh-ve-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(239, 68, 68, 0.4), 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 8px 32px rgba(239, 68, 68, 0.4), 0 0 0 8px rgba(239, 68, 68, 0); }
}

.qh-ve-toggle i {
  position: relative;
  z-index: 1;
  transition: transform 0.3s ease;
}

.qh-ve-toggle.active i {
  transform: rotate(45deg);
}

/* ---------- Actions Bar ---------- */
.qh-ve-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateX(-20px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.qh-ve-actions.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.qh-ve-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 99px;
  background: linear-gradient(135deg, #F59E0B, #EF4444);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  animation: qh-ve-badge-pop 0.3s ease;
}

@keyframes qh-ve-badge-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.qh-ve-btn {
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.qh-ve-btn-save {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.qh-ve-btn-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.qh-ve-btn-discard {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.qh-ve-btn-discard:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #EF4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.qh-ve-btn-revert {
  background: rgba(239, 68, 68, 0.15);
  color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.qh-ve-btn-revert:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

/* ---------- Hover Outline (sutil, coloreado por tipo) ---------- */
.qh-ve-hover-outline {
  position: fixed;
  pointer-events: none;
  z-index: 99990;
  border: 1.5px solid rgba(99, 102, 241, 0.6);
  border-radius: 4px;
  background: transparent;
  transition: all 0.1s ease-out;
  display: none;
}

.qh-ve-hover-outline.visible {
  display: block;
}

/* ---------- Tag Label (coloreado por tipo) ---------- */
.qh-ve-tag-label {
  position: fixed;
  z-index: 99991;
  padding: 2px 8px;
  border-radius: 4px;
  background: #6366F1;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  font-family: 'Inter', 'SF Mono', monospace;
  letter-spacing: 0.2px;
  pointer-events: none;
  display: none;
  white-space: nowrap;
  line-height: 1.5;
}

.qh-ve-tag-label.visible {
  display: inline-flex;
  align-items: center;
}

/* ---------- Breadcrumb Navigation ---------- */
.qh-ve-breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: auto;
  scrollbar-width: none;
}
.qh-ve-breadcrumb::-webkit-scrollbar { display: none; }

.qh-ve-crumb {
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.4);
  font-size: 10px;
  font-weight: 600;
  font-family: 'Inter', monospace;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.qh-ve-crumb:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}

.qh-ve-crumb.active {
  cursor: default;
  font-weight: 700;
}

.qh-ve-crumb-sep {
  color: rgba(255, 255, 255, 0.15);
  font-size: 8px;
  margin: 0 1px;
}

/* ---------- Context Menu ---------- */
.qh-ve-context-menu {
  position: fixed;
  z-index: 99995;
  min-width: 300px;
  max-width: 400px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.04);
  font-family: 'Inter', sans-serif;
  display: none;
  overflow: hidden;
  animation: qh-ve-menu-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.qh-ve-context-menu.visible {
  display: block;
}

@keyframes qh-ve-menu-in {
  0% { opacity: 0; transform: translateY(6px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.qh-ve-menu-header {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.qh-ve-menu-header h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #E2E8F0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.qh-ve-menu-header h4 i {
  font-size: 13px;
}

.qh-ve-menu-close {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.15s ease;
}
.qh-ve-menu-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #EF4444;
}

.qh-ve-menu-body {
  padding: 12px 16px 14px;
}

.qh-ve-menu-body label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

/* ---------- Format Toolbar ---------- */
.qh-ve-format-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.qh-ve-fmt {
  width: 30px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s ease;
}

.qh-ve-fmt:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #A5B4FC;
}

.qh-ve-fmt:active {
  background: rgba(99, 102, 241, 0.35);
  color: #fff;
}

.qh-ve-fmt-sep {
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 4px;
  flex-shrink: 0;
}

/* ---------- Rich Editable Area ---------- */
.qh-ve-editable-area {
  width: 100%;
  min-height: 60px;
  max-height: 200px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #E2E8F0;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  outline: none;
  overflow-y: auto;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
  margin-bottom: 10px;
  word-wrap: break-word;
}

.qh-ve-editable-area:focus {
  border-color: #6366F1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.qh-ve-editable-area::-webkit-scrollbar { width: 4px; }
.qh-ve-editable-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}

/* ---------- Inputs ---------- */
.qh-ve-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #E2E8F0;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
  margin-bottom: 8px;
}

.qh-ve-input:focus {
  border-color: #6366F1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.qh-ve-textarea {
  width: 100%;
  min-height: 70px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #E2E8F0;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  outline: none;
  resize: vertical;
  transition: all 0.2s ease;
  box-sizing: border-box;
  margin-bottom: 8px;
}

.qh-ve-textarea:focus {
  border-color: #6366F1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* ---------- Action Buttons ---------- */
.qh-ve-menu-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.qh-ve-menu-actions .qh-ve-btn {
  flex: 1;
  justify-content: center;
  padding: 9px 12px;
  font-size: 12px;
}

.qh-ve-btn-apply {
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.qh-ve-btn-apply:hover {
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}

.qh-ve-btn-cancel {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.qh-ve-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ---------- Divider ---------- */
.qh-ve-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 10px 0 8px;
}

/* ---------- Structure Buttons ---------- */
.qh-ve-struct-actions {
  display: flex;
  gap: 6px;
}

.qh-ve-btn-duplicate {
  background: rgba(16, 185, 129, 0.1);
  color: #6EE7B7;
  border: 1px solid rgba(16, 185, 129, 0.15);
}
.qh-ve-btn-duplicate:hover {
  background: rgba(16, 185, 129, 0.22);
  color: #fff;
}

.qh-ve-btn-delete {
  background: rgba(239, 68, 68, 0.1);
  color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, 0.15);
}
.qh-ve-btn-delete:hover {
  background: rgba(239, 68, 68, 0.22);
  color: #fff;
}

.qh-ve-btn-move {
  background: rgba(59, 130, 246, 0.1);
  color: #93C5FD;
  border: 1px solid rgba(59, 130, 246, 0.15);
}
.qh-ve-btn-move:hover {
  background: rgba(59, 130, 246, 0.22);
  color: #fff;
}

/* ---------- Container Info ---------- */
.qh-ve-container-info {
  padding: 8px 0;
}

.qh-ve-info-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 0;
}

.qh-ve-info-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 50px;
}

.qh-ve-info-value {
  font-size: 12px;
  color: #CBD5E1;
  font-family: 'SF Mono', 'Fira Code', monospace;
  word-break: break-all;
}

.qh-ve-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  font-style: italic;
  margin: 6px 0 0;
  line-height: 1.5;
}

/* ---------- Image Preview ---------- */
.qh-ve-img-preview {
  width: 100%;
  height: 90px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  object-fit: cover;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.02);
  transition: opacity 0.2s ease;
}

/* ---------- Confirmation Modal ---------- */
.qh-ve-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  animation: qh-ve-fade-in 0.2s ease;
}

.qh-ve-modal-overlay.visible {
  display: flex;
}

@keyframes qh-ve-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.qh-ve-modal {
  width: 90%;
  max-width: 650px;
  max-height: 80vh;
  background: rgba(15, 23, 42, 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
  animation: qh-ve-modal-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes qh-ve-modal-in {
  0% { opacity: 0; transform: translateY(24px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.qh-ve-modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.qh-ve-modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #F1F5F9;
  display: flex;
  align-items: center;
  gap: 10px;
}

.qh-ve-modal-header h3 i { color: #10B981; }

.qh-ve-modal-body {
  padding: 18px 22px;
  max-height: 45vh;
  overflow-y: auto;
}

.qh-ve-modal-body::-webkit-scrollbar { width: 5px; }
.qh-ve-modal-body::-webkit-scrollbar-track { background: transparent; }
.qh-ve-modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}

/* Changes table */
.qh-ve-changes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.qh-ve-changes-table th {
  text-align: left;
  padding: 7px 8px;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 9px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.qh-ve-changes-table td {
  padding: 8px 8px;
  color: #CBD5E1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: top;
  word-break: break-word;
}

.qh-ve-changes-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.qh-ve-selector-cell {
  color: #A5B4FC;
  font-size: 10px;
  font-family: 'SF Mono', monospace;
}

.qh-ve-prop-cell {
  color: #94A3B8;
  font-size: 10px;
}

.qh-ve-val-old {
  color: #FCA5A5;
  background: rgba(239, 68, 68, 0.08);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 10px;
  display: inline-block;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qh-ve-val-new {
  color: #6EE7B7;
  background: rgba(16, 185, 129, 0.08);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 10px;
  display: inline-block;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qh-ve-action-badge {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.qh-ve-action-edit { background: rgba(99, 102, 241, 0.12); color: #A5B4FC; }
.qh-ve-action-duplicate { background: rgba(16, 185, 129, 0.12); color: #6EE7B7; }
.qh-ve-action-delete { background: rgba(239, 68, 68, 0.12); color: #FCA5A5; }

.qh-ve-modal-footer {
  padding: 14px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.qh-ve-modal-footer .qh-ve-btn {
  padding: 11px 22px;
  font-size: 13px;
  border-radius: 10px;
}

/* ---------- Spinner ---------- */
.qh-ve-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: qh-ve-spin 0.6s linear infinite;
}

@keyframes qh-ve-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Mode Indicator ---------- */
.qh-ve-mode-indicator {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99998;
  padding: 8px 20px;
  border-radius: 99px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.92), rgba(139, 92, 246, 0.92));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  display: none;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.35);
  animation: qh-ve-slide-down 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.qh-ve-mode-indicator.visible {
  display: inline-flex;
}

@keyframes qh-ve-slide-down {
  from { opacity: 0; transform: translateX(-50%) translateY(-16px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.qh-ve-mode-indicator .qh-ve-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #EF4444;
  animation: qh-ve-dot-blink 1.2s infinite;
}

@keyframes qh-ve-dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---------- Editing Mode: prevent navigation but allow pointer ---------- */
.qh-ve-editing-active a,
.qh-ve-editing-active button:not([class*="qh-ve-"]) {
  pointer-events: none !important;
}

/* Re-enable editor elements */
.qh-ve-toolbar,
.qh-ve-toolbar *,
.qh-ve-context-menu,
.qh-ve-context-menu *,
.qh-ve-modal-overlay,
.qh-ve-modal-overlay * {
  pointer-events: auto !important;
}

.qh-ve-btn,
.qh-ve-toggle,
.qh-ve-menu-close,
.qh-ve-input,
.qh-ve-textarea,
.qh-ve-editable-area,
.qh-ve-fmt,
.qh-ve-crumb {
  cursor: pointer !important;
}

.qh-ve-editable-area {
  cursor: text !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .qh-ve-toolbar {
    bottom: 16px;
    left: 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .qh-ve-toggle {
    width: 48px;
    height: 48px;
    font-size: 18px;
    border-radius: 14px;
  }

  .qh-ve-actions {
    flex-direction: column;
    gap: 6px;
    padding: 10px 14px;
  }

  .qh-ve-context-menu {
    min-width: 270px;
    max-width: 340px;
  }

  .qh-ve-modal {
    width: 95%;
    max-height: 85vh;
  }

  .qh-ve-mode-indicator {
    font-size: 10px;
    padding: 7px 14px;
    top: 68px;
  }
}
