/* Custom Styles for CV Maker App */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Inter:wght@300;400;500;600;700&family=Lora:ital,wght@0,400;0,600;1,400&family=Merriweather:ital,wght@0,300;0,400;0,700;1,400&family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=Poppins:wght@300;400;500;600;700&family=Raleway:wght@300;400;500;600;700&family=Roboto:wght@300;400;500;700&display=swap');

:root {
  --primary-purple: #7c3aed;
  --primary-purple-dark: #6d28d9;
  --primary-purple-light: #8b5cf6;
  --primary-purple-bg: #f5f3ff;
}

* {
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
  color-adjust: exact !important;
}

/* CV Typography Text Grouping System */
:root {
  --cv-fs-header: 26px;
  --cv-fs-subheader: 13.5px;
  --cv-fs-section: 14px;
  --cv-fs-body: 12px;
  --cv-fs-meta: 10.5px;
}

#cv-preview-sheet,
.cv-preview-container {
  --cv-fs-header: 26px;
  --cv-fs-subheader: 13.5px;
  --cv-fs-section: 14px;
  --cv-fs-body: 12px;
  --cv-fs-meta: 10.5px;
}

.cv-fs-header,
#cv-preview-sheet .cv-fs-header {
  font-size: var(--cv-fs-header, 26px) !important;
  line-height: 1.15 !important;
}
.cv-fs-subheader,
#cv-preview-sheet .cv-fs-subheader {
  font-size: var(--cv-fs-subheader, 13.5px) !important;
  line-height: 1.25 !important;
}
.cv-fs-section,
#cv-preview-sheet .cv-fs-section {
  font-size: var(--cv-fs-section, 14px) !important;
  line-height: 1.3 !important;
}
.cv-fs-body,
#cv-preview-sheet .cv-fs-body,
#cv-preview-sheet p.cv-fs-body,
#cv-preview-sheet li,
#cv-preview-sheet .preview-draggable-bullet span.flex-1 {
  font-size: var(--cv-fs-body, 12px) !important;
  line-height: 1.4 !important;
}
.cv-fs-meta,
#cv-preview-sheet .cv-fs-meta,
#cv-preview-sheet .cv-fs-meta span,
#cv-preview-sheet .cv-fs-meta div {
  font-size: var(--cv-fs-meta, 10.5px) !important;
  line-height: 1.35 !important;
}

body {
  font-family: 'Montserrat', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
  overflow-x: hidden;
}

/* Custom Scrollbar with Purple Theme */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* A4 Sheet Preview Canvas */
.cv-preview-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1.5rem;
  background: #334155;
  background-image: radial-gradient(#475569 1px, transparent 1px);
  background-size: 16px 16px;
  min-height: 100%;
}

.cv-sheet-wrapper {
  transform-origin: top center;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  justify-content: center;
}

.cv-sheet {
  width: 210mm;
  min-height: 297mm;
  padding: 16mm 18mm;
  margin: 0 auto;
  background: #ffffff;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
  position: relative;
  transition: box-shadow 0.2s ease-in-out;
}

/* Responsive scale for preview */
@media (max-width: 1280px) {
  .cv-sheet-wrapper {
    transform: scale(0.92);
    margin-bottom: -8%;
  }
}

@media (max-width: 1024px) {
  .cv-preview-container {
    padding: 1rem 0.5rem;
    overflow-x: auto;
  }
  .cv-sheet-wrapper {
    transform: scale(0.8);
    margin-bottom: -20%;
  }
}

@media (max-width: 768px) {
  .cv-preview-container {
    padding: 0.75rem 0.25rem;
    background: #1e293b;
  }
  .cv-sheet-wrapper {
    transform: scale(0.68);
    margin-bottom: -32%;
  }
}

@media (max-width: 480px) {
  .cv-sheet-wrapper {
    transform: scale(0.48);
    margin-bottom: -52%;
  }
}

/* SortableJS Drag & Drop Styles for Editor & Live Preview */
.sortable-ghost {
  opacity: 0.35 !important;
  background-color: #ede9fe !important;
  border: 2px dashed #8b5cf6 !important;
  border-radius: 0.5rem !important;
}

.sortable-chosen {
  background-color: #f5f3ff !important;
}

.sortable-drag {
  opacity: 0.95 !important;
  box-shadow: 0 20px 25px -5px rgba(124, 58, 237, 0.3) !important;
  cursor: grabbing !important;
}

.drag-handle {
  cursor: grab;
  touch-action: none;
}
.drag-handle:active {
  cursor: grabbing;
}

/* Live A4 Preview Interactive Hover Handles */
.preview-draggable-sec {
  position: relative;
  border-radius: 6px;
  transition: outline 0.15s ease, background-color 0.15s ease;
}
.preview-draggable-sec:hover {
  outline: 1.5px dashed rgba(124, 58, 237, 0.45);
  background-color: rgba(245, 243, 255, 0.4);
}
.preview-draggable-sec:hover .preview-sec-handle {
  opacity: 1;
  pointer-events: auto;
}

.preview-sec-handle {
  position: absolute;
  top: -12px;
  left: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 3px;
}

.preview-sec-drag-grip {
  cursor: grab;
  touch-action: none;
  pointer-events: auto;
}
.preview-sec-drag-grip:active {
  cursor: grabbing;
}

.preview-sec-handle button {
  cursor: pointer;
  pointer-events: auto;
}

.preview-draggable-item {
  position: relative;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}
.preview-draggable-item:hover {
  background-color: rgba(243, 232, 255, 0.35);
}
.preview-draggable-item:hover .preview-item-handle {
  opacity: 1;
  pointer-events: auto;
}

.preview-item-handle {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  cursor: grab;
}
.preview-item-handle:active {
  cursor: grabbing;
}

.preview-draggable-bullet {
  position: relative;
  border-radius: 3px;
  transition: background-color 0.12s ease;
}
.preview-draggable-bullet:hover {
  background-color: rgba(243, 232, 255, 0.5);
}
.preview-draggable-bullet:hover .preview-bullet-handle {
  opacity: 1;
  pointer-events: auto;
}

.preview-bullet-handle {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  cursor: grab;
}
.preview-bullet-handle:active {
  cursor: grabbing;
}

/* Print Optimization for Exact A4 Output */
@media print {
  @page {
    size: A4 portrait;
    margin: 0mm !important;
  }
  
  html, body {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #1e293b !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  
  .no-print,
  #editor-column,
  #style-panel,
  #app-header,
  #mobile-nav,
  #templates-modal,
  #theme-modal,
  #resumes-modal,
  #google-auth-modal,
  .toast-container,
  .preview-sec-handle,
  .preview-item-handle,
  .preview-bullet-handle,
  .preview-actions-overlay,
  button,
  .btn {
    display: none !important;
  }
  
  .cv-preview-container {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    width: 210mm !important;
    min-height: 297mm !important;
  }
  
  .cv-sheet-wrapper {
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    width: 210mm !important;
  }
  
  .cv-sheet {
    width: 210mm !important;
    min-height: 297mm !important;
    max-width: 210mm !important;
    padding: 16mm 18mm !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    transform: none !important;
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  .preview-draggable-sec {
    outline: none !important;
    background-color: transparent !important;
  }
  .preview-draggable-item {
    background-color: transparent !important;
  }
  .preview-draggable-bullet {
    background-color: transparent !important;
  }
}

/* Color Accent Badges & Helpers */
.color-picker-dot {
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #cbd5e1;
}
.color-picker-dot:hover {
  transform: scale(1.15);
}
.color-picker-dot.active {
  box-shadow: 0 0 0 3px #7c3aed;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Custom Tab styling */
.tab-active {
  color: #7c3aed;
  border-bottom: 2px solid #7c3aed;
  font-weight: 600;
}
