/* Live Preview Editing Styles */

/* Editable Fields */
[contenteditable="true"] {
  outline: 1px dashed transparent;
  transition: outline-color 0.2s;
  cursor: text;
}

[contenteditable="true"]:hover {
  outline: 1px dashed #3b82f6;
  /* Blue outline on hover */
}

[contenteditable="true"]:focus {
  outline: 2px solid #3b82f6;
  /* Stronger blue on focus */
  background-color: rgba(59, 130, 246, 0.05);
  border-radius: 2px;
}

/* Draggable Sections */
.resume-section {
  position: relative;
  transition: margin-bottom 0.1s;
  /* Smooth spacing adjustment */
}

.resume-section:hover::after {
  content: "⋮⋮";
  /* Drag handle icon */
  position: absolute;
  top: 50%;
  left: -20px;
  /* Position to the left of the section */
  transform: translateY(-50%);
  font-size: 16px;
  color: #94a3b8;
  cursor: grab;
  opacity: 0.5;
}

.resume-section:hover::after:hover {
  color: #3b82f6;
  opacity: 1;
}

/* Gap Resize Handle */
.gap-handle {
  position: absolute;
  bottom: -15px;
  /* Position in the gap */
  left: 0;
  right: 0;
  height: 10px;
  background: transparent;
  cursor: ns-resize;
  /* North-South resize cursor */
  z-index: 10;
  display: none;
  /* Hidden by default */
}

.resume-section:hover .gap-handle {
  display: block;
  /* Show on hover */
}

.gap-handle::before {
  content: "";
  display: block;
  width: 100%;
  height: 1px;
  background: #e2e8f0;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.gap-handle:hover::before {
  opacity: 1;
  background: #3b82f6;
}

/* Sortable Ghost Class */
.sortable-ghost {
  opacity: 0.4;
  background-color: #f1f5f9;
}

/* Restore default browser styles inside the resume preview to override Tailwind's global reset */
#resume-preview p {
  margin-top: 1em;
  margin-bottom: 1em;
}

#resume-preview ul {
  list-style-type: disc;
  padding-left: 40px;
  margin-top: 1em;
  margin-bottom: 1em;
}

#resume-preview ol {
  list-style-type: decimal;
  padding-left: 40px;
  margin-top: 1em;
  margin-bottom: 1em;
}

#resume-preview li {
  display: list-item;
}

#resume-preview h1 {
  font-size: 2em;
  margin-top: 0.67em;
  margin-bottom: 0.67em;
  font-weight: bold;
}

#resume-preview h2 {
  font-size: 1.5em;
  margin-top: 0.83em;
  margin-bottom: 0.83em;
  font-weight: bold;
}

#resume-preview h3 {
  font-size: 1.17em;
  margin-top: 1em;
  margin-bottom: 1em;
  font-weight: bold;
}

#resume-preview h4 {
  font-size: 1em;
  margin-top: 1.33em;
  margin-bottom: 1.33em;
  font-weight: bold;
}

#resume-preview h5 {
  font-size: 0.83em;
  margin-top: 1.67em;
  margin-bottom: 1.67em;
  font-weight: bold;
}

#resume-preview h6 {
  font-size: 0.67em;
  margin-top: 2.33em;
  margin-bottom: 2.33em;
  font-weight: bold;
}

#resume-preview b,
#resume-preview strong {
  font-weight: bolder;
}

#resume-preview i,
#resume-preview em {
  font-style: italic;
}

/* Upgraded Edit Toolbar UI */
.edit-toolbar:not(.hidden) {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 12px 16px !important;
  background: rgba(15, 23, 42, 0.85) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 16px !important;
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.1) !important;
  width: auto !important;
  max-width: 95vw !important;
  bottom: 24px !important;
  transition: all 0.3s ease !important;
  z-index: 10000 !important;
}

/* Make groups look like cohesive segments */
.edit-toolbar .toolbar-group {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 8px !important;
  padding: 4px !important;
  gap: 4px !important;
  display: flex !important;
  align-items: center !important;
}

/* Hide labels in some groups to save space */
.edit-toolbar .toolbar-group label {
  display: none !important;
}

/* Show specific labels */
.edit-toolbar .toolbar-group:nth-child(4) label,
/* Font Family */
.edit-toolbar .toolbar-group:nth-child(5) label,
/* Size */
.edit-toolbar .toolbar-group:nth-child(9) label

/* Line Spacing */
  {
  display: block !important;
  margin-left: 6px !important;
  margin-right: 2px !important;
  color: #94a3b8 !important;
  font-size: 0.65rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  font-weight: 600 !important;
}

/* Make buttons look softer */
.edit-toolbar .toolbar-btn {
  border: none !important;
  background: transparent !important;
  border-radius: 6px !important;
  color: #cbd5e1 !important;
  transition: all 0.2s ease !important;
  min-width: 28px !important;
  height: 28px !important;
  font-size: 14px !important;
}

.edit-toolbar .toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  color: white !important;
  transform: translateY(-1px) !important;
}

.edit-toolbar .toolbar-btn:active {
  transform: translateY(1px) !important;
}

/* Fix Inputs */
.edit-toolbar .toolbar-group select,
.edit-toolbar .toolbar-group input[type="number"] {
  background: rgba(0, 0, 0, 0.3) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: white !important;
  border-radius: 4px !important;
  padding: 2px 6px !important;
  font-size: 0.75rem !important;
  height: 26px !important;
}

.edit-toolbar .toolbar-group input[type="color"] {
  border: 2px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  cursor: pointer !important;
  width: 24px !important;
  height: 24px !important;
  padding: 0 !important;
  background: transparent !important;
}

.edit-toolbar .toolbar-group input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.edit-toolbar .toolbar-group input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

/* Close button and Drag handle */
.edit-toolbar .toolbar-close-btn {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
  border-radius: 50% !important;
  width: 28px !important;
  height: 28px !important;
  padding: 4px !important;
  margin-right: 4px !important;
}

.edit-toolbar .toolbar-close-btn:hover {
  background: #ef4444 !important;
  color: white !important;
}

.edit-toolbar .toolbar-drag-handle {
  border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
  padding-right: 8px !important;
  margin-right: 4px !important;
}

@media (max-width: 768px) {
  .edit-toolbar {
    top: 85px !important;
    /* Just below the header */
    bottom: auto !important;
    padding: 8px 12px !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: calc(100% - 24px) !important;
    left: 12px !important;
    transform: none !important;
    border-radius: 12px !important;
    background: rgba(15, 23, 42, 0.95) !important;
    /* more solid */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
  }

  /* Hide scrollbar for clean app look */
  .edit-toolbar::-webkit-scrollbar {
    display: none !important;
  }

  .edit-toolbar {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
  }

  .edit-toolbar .toolbar-group {
    padding: 2px !important;
    flex-shrink: 0 !important;
  }

  .edit-toolbar .toolbar-btn {
    min-width: 28px !important;
    height: 28px !important;
    font-size: 14px !important;
    flex-shrink: 0 !important;
  }

  .edit-toolbar .toolbar-drag-handle {
    display: none !important;
    /* Hide drag handle on mobile */
  }

  .edit-toolbar .toolbar-close-btn {
    flex-shrink: 0 !important;
  }
}

/* =========================================
   Mobile App Layout Overrides (Web-to-App)
   ========================================= */
@media (max-width: 1024px) {

  /* Hide unnecessary globals in app view */
  body:has(.builder-layout) footer {
    display: none !important;
  }

  /* Header adjustments for app view */
  body:has(.builder-layout) .header {
    position: relative !important;
    z-index: 1000 !important;
  }

  /* The form panel takes full width but grows natively */
  .form-panel {
    border-radius: 0 !important;
    box-shadow: none !important;
    padding-bottom: 120px !important;
    /* Space for FAB */
    margin-bottom: 40px !important;
  }

  .form-content {
    padding: 16px !important;
  }

  /* The preview panel becomes a full screen modal */
  .preview-panel {
    position: fixed !important;
    top: 73px !important;
    /* Below header */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: calc(100dvh - 73px) !important;
    max-height: none !important;
    border-radius: 0 !important;
    transform: translateX(100%) !important;
    /* Slide in from right like native app */
    z-index: 999 !important;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    background: #f1f5f9 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* When expanded, it slides in to cover the screen */
  .preview-panel.expanded {
    transform: translateX(0) !important;
  }

  /* Simplify preview header */
  .preview-header {
    flex-shrink: 0;
    min-height: auto !important;
    padding: 12px 16px !important;
    border-radius: 0 !important;
  }

  .preview-header::before {
    display: none !important;
    /* Remove bottom sheet drag handle */
  }

  .preview-panel:not(.expanded) .preview-header h2 {
    position: static !important;
    transform: none !important;
  }

  /* Make the preview container fill the screen */
  .preview-container {
    flex: 1 !important;
    height: auto !important;
    max-height: none !important;
    padding: 16px !important;
    overflow-y: auto !important;
    display: block !important;
  }

  .preview-panel:not(.expanded) .preview-container {
    display: block !important;
    /* Override legacy display:none */
  }

  /* Touch target improvements */
  input,
  select,
  textarea,
  button {
    touch-action: manipulation;
  }

  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="date"],
  textarea,
  select {
    font-size: 16px !important;
    /* Prevents iOS auto-zoom */
  }

  /* Reposition FAB */
  .mobile-preview-toggle {
    bottom: 24px !important;
    right: 24px !important;
    z-index: 10001 !important;
    /* Above everything */
  }

  .mobile-preview-toggle.active {
    background: #ef4444 !important;
    /* Red for close */
    bottom: 24px !important;
    /* Don't move it */
  }
}

/* Premium Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(14, 165, 233, 0.3);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(14, 165, 233, 0.6);
}.ats-result-content { color: #0f172a !important; font-weight: 500 !important; } .ai-result-panel { color: #0f172a !important; }
.font-select:focus { background-color: rgba(255, 255, 255, 0.13) !important; color: white !important; }
