/* Builder Layout Styles */
.cv-builder {
    background: #f5f5f5;
    min-height: 100vh;
    padding: 1rem; /* Reduced from 2rem */
}

/* CSS Reset for forms to prevent browser defaults */
.cv-builder form,
.cv-builder fieldset,
.cv-builder input,
.cv-builder textarea,
.cv-builder select,
.cv-builder label {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    font-size: 100%;
    vertical-align: baseline;
    background: transparent;
}

/* Restore necessary input styling after reset */
.cv-builder input,
.cv-builder textarea,
.cv-builder select {
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: #fafafa;
    font-family: inherit;
    font-size: 0.95rem;
    margin: 0 !important; /* Force zero margin */
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Ultra-aggressive input spacing reset */
.cv-builder .form-section-block input[type="text"],
.cv-builder .form-section-block input[type="email"],
.cv-builder .form-section-block input[type="tel"],
.cv-builder .form-section-block input[type="file"],
.cv-builder .form-section-block textarea,
.cv-builder .form-section-block select {
    margin: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
}

.builder-container {
    display: flex;
    gap: 2rem;
    max-width: 1800px;
    margin: 0 auto;
    align-items: flex-start;
    padding: 1rem;
    min-height: 100vh;
}

.profile-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.form-section {
    flex: 0 0 45%;
    max-width: 600px;
    min-width: 400px;
    background: white;
    padding: 0; /* Let inner areas manage spacing */
    border-radius: 8px;
    border: 1px solid #e5e7eb; /* match preview container border */
    box-shadow: none; /* align with clean look */
    margin-right: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 0; /* allow inner scroller */
}

.preview-section {
    flex: 1 1 55%;
    position: static; /* avoid sticky clipping */
    top: auto;
    height: auto; /* let it grow naturally */
    max-height: none; /* no cap */
    overflow: visible; /* Allow child to render fully; child will handle scrolling */
    background: white;
    padding: 0.5rem; /* Minimal padding */
    border-radius: 0; /* Remove border radius */
    box-shadow: none; /* Remove shadow */
    min-width: 500px;
    display: flex;
    flex-direction: column;
    min-height: 0; /* allow inner scroller */
}

/* Preview container adjustments - clean and simple */
.preview-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto !important; /* Vertical scrollbar for the content */
    overflow-x: auto !important; /* Allow horizontal scroll if needed */
    padding: 10px; /* Adequate padding */
    width: 100%;
    /* Let it fill the remaining height in the sticky container */
    flex: 1 1 auto;
    height: auto;
    max-height: none;
    min-height: 0; /* Important for flex children to allow scrolling */
    background: #f8fafc; /* Light background for better contrast */
    border-radius: 8px; /* Add slight radius */
    border: 1px solid #e5e7eb; /* Add subtle border */
}

/* Left form: header + scroller body to match preview structure */
.form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: white;
    position: sticky;
    top: 0;
    z-index: 3;
}

.cv-form {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto; /* internal scroll like preview */
    padding: 16px; /* comfortable spacing */
    background: #fbfdff; /* subtle contrast, matches preview */
}

/* Tweak quick start to sit nicely above scroll */
.quick-start-section {
    margin: 12px 16px 0 16px;
}

/* Ensure sticky action buttons behave within the form scroller */
.cv-form .action-buttons {
    position: sticky;
    bottom: 0;
}

/* Ensure bottom content is never hidden behind scrollbars */
.preview-container .cv-preview {
    padding-bottom: 40px !important;
    overflow: visible !important;
}

/* Loading state for preview */
.preview-container.loading {
    position: relative;
}

.preview-container.loading::before {
    content: "Loading CV Preview...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    font-weight: 500;
    color: #1e40af;
}

.preview-container .cv-template {
    width: 100%;
    max-width: 100%;
    min-width: unset; /* Remove minimum width constraint */
    margin: 0 auto; /* Removed large bottom margin */
    transform-origin: top left;
    background: white; /* Ensure CV has white background */
    box-shadow: none; /* Remove extra shadow */
    border-radius: 0; /* Remove rounded corners */
}

/* Ensure cv-preview fits container properly */
.preview-container .cv-preview {
    max-width: none !important; /* Allow full width */
    margin: 0 !important;
}

/* Responsive adjustments for all templates in preview */
@media screen and (max-width: 1400px) {
    .cv-template.template-creative .cv-sidebar {
        min-width: 160px;
        padding: 20px 15px;
    }
    
    .cv-template.template-creative .cv-main {
        padding: 20px;
    }
    
    .cv-template.template-creative .cv-name {
        font-size: 1.5rem;
    }
}

@media screen and (max-width: 1200px) {
    .cv-template.template-creative .cv-sidebar {
        width: 40%;
        min-width: 140px;
    }
    
    .cv-template.template-creative .cv-main {
        width: 60%;
    }
}

/* Responsive Layout */
@media screen and (max-width: 1400px) {
    .form-section {
        flex: 0 0 40%;
        min-width: 350px;
    }
    
    .preview-section {
        flex: 1 1 60%;
        min-width: 450px;
    }
}

@media screen and (max-width: 1200px) {
    .builder-container {
        flex-direction: column;
        align-items: stretch;
    }

    .form-section,
    .preview-section {
        flex: none;
        max-width: 100%;
        width: 100%;
        min-width: unset;
        margin-right: 0;
    }

    .preview-section {
        position: relative;
        top: 0;
        height: auto;
        margin-top: 2rem;
        overflow: visible;
    }

    .preview-header {
        position: relative;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .template-selector {
        width: 100%;
        justify-content: space-between;
    }

    .preview-tip {
        width: 100%;
        margin: 0;
        padding: 8px 12px;
        background: #eef2ff;
        color: #1e3a8a;
        border: 1px solid #c7d2fe;
        border-radius: 8px;
        font-size: 0.9rem;
    }
    
    .preview-container {
    /* Allow full content; only ensure a reasonable minimum */
    min-height: 50vh;
    height: auto;
    max-height: none;
    flex: 1 1 auto;
        padding: 5px;
    }
    
    .cv-preview {
        transform: scale(0.7);
        transform-origin: top center;
    }
}

@media screen and (max-width: 768px) {
    .cv-builder {
        padding: 1rem;
    }

    .form-section,
    .preview-section {
        padding: 1rem;
    }
}

/* Form Section Styles */
.form-section-block {
    margin-bottom: 1rem; /* Reduced from 1.5rem */
    padding: 0.8rem; /* Reduced from 1rem */
    background: #f8fafc;
    border-radius: 8px;
}

/* Preview Section Styles */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.preview-container {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    min-height: 500px;
    overflow: auto;
    /* Override earlier fixed height constraints to avoid clipping bottom content */
    flex: 1 1 auto;
    height: auto;
    max-height: none;
    min-height: 0;
}

.cv-template {
    max-width: 100%;
    transform-origin: top left;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    color: #1a1a1a;
}

/* Enhanced Template-specific styles for preview */
.cv-template.template-modern {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.cv-template.template-modern .cv-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.cv-template.template-modern .cv-name {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.cv-template.template-modern .cv-title {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

.cv-template.template-modern .cv-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.cv-template.template-modern .cv-contact span {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.cv-template.template-classic {
    background: #fafafa;
    padding: 40px;
    border: 2px solid #333;
}

.cv-template.template-classic .cv-header {
    text-align: center;
    padding: 30px;
    background: white;
    margin-bottom: 30px;
    border: 1px solid #ddd;
}

.cv-template.template-classic .cv-name {
    font-size: 2.2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.cv-template.template-classic .cv-title {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 15px;
}

.cv-template.template-creative {
    display: flex;
    min-height: 700px; /* Increased height */
    background: white;
    border-radius: 8px;
    overflow: visible; /* Allow full content to show */
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 100%;
}

.cv-template.template-creative .cv-sidebar {
    width: 35%;
    min-width: 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 25px 60px 25px; /* Increased bottom padding */
    flex-shrink: 0;
}

.cv-template.template-creative .cv-main {
    width: 65%;
    padding: 30px 30px 60px 30px; /* Increased bottom padding */
    background: white;
    flex: 1;
    overflow: visible; /* Don't clip inner content */
}

/* Creative template profile image styling */
.cv-template.template-creative .cv-profile-image.creative {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 20px;
    border: 3px solid rgba(255,255,255,0.3);
}

.cv-template.template-creative .cv-profile-image.creative img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cv-template.template-creative .cv-name {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    word-wrap: break-word;
}

.cv-template.template-creative .cv-title {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 25px;
}

.cv-template.template-ats {
    background: white;
    padding: 30px;
    font-family: Arial, sans-serif;
    line-height: 1.4;
}

.cv-template.template-ats .cv-name {
    font-size: 1.8rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 5px;
    text-align: center;
}

.cv-template.template-ats .cv-title {
    font-size: 1.2rem;
    margin-bottom: 15px;
    text-align: center;
}

.cv-template.template-ats .cv-contact {
    text-align: center;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* Ensure all templates have proper padding and spacing */
.cv-template {
    padding: 30px 30px 50px 30px; /* Increased bottom padding */
    min-height: 600px; /* Minimum height to prevent cutoff */
    box-sizing: border-box;
}

.cv-template.template-modern {
    padding: 0 0 40px 0; /* Modern template has its own padding structure */
    overflow: visible; /* Ensure bottom content isn't clipped */
}

.cv-template.template-classic {
    padding: 40px 40px 60px 40px; /* Extra bottom padding */
}

.cv-template.template-creative {
    padding: 0; /* Creative template has sidebar/main structure */
    min-height: 700px; /* Taller for two-column layout */
}

.cv-template.template-ats {
    padding: 40px 40px 60px 40px; /* Extra bottom padding */
    line-height: 1.6; /* Better readability */
}
.cv-section {
    margin-bottom: 30px; /* Increased spacing between sections */
}

.cv-section:last-child {
    margin-bottom: 0; /* Remove margin from last section */
}

.cv-section-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #667eea;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Preview toolbar */
.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    gap: 12px;
    border-bottom: 1px solid #eef2f7;
    background: #fbfdff;
}
.preview-toolbar .left-controls,
.preview-toolbar .right-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.zoom-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
}
.zoom-label {
    font-size: 0.85rem;
    color: #334155;
    min-width: 44px;
    text-align: center;
}
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    min-width: 34px;
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 8px;
    color: #1e293b;
    cursor: pointer;
}
.toolbar-btn:hover {
    background: #f8fafc;
}
.btn-preview.small {
    padding: 8px 12px;
}

/* Zoom effect on preview */
:root {
    --preview-scale: 1;
}
.preview-container.paper-bg {
    background:
      radial-gradient(ellipse at top left, rgba(0,0,0,0.06), transparent 50%),
      radial-gradient(ellipse at bottom right, rgba(0,0,0,0.06), transparent 50%),
      #f1f5f9;
}
.cv-preview {
    transform-origin: top center;
    transform: scale(var(--preview-scale));
    transition: transform 0.15s ease-out;
}

/* Keep scroll usability when scaled */
.preview-container {
    overflow: auto;
}

/* Sticky bottom action bar on the left form when near completion */
.action-buttons {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.85), #ffffff);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    padding: 12px 0 0 0;
    margin-top: 16px;
    border-top: 1px solid #eef2f7;
    display: flex;
    gap: 10px;
    z-index: 2;
}

.template-classic .cv-section-title {
    border-bottom: 2px solid #333;
    color: #333;
}

.template-creative .cv-section-title {
    border-bottom: 2px solid #667eea;
    color: #667eea;
}

.template-ats .cv-section-title {
    border-bottom: 1px solid #000;
    color: #000;
    text-transform: uppercase;
    font-size: 1.1rem;
}

/* Profile image styles */
.cv-profile-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 20px;
    border: 4px solid rgba(255,255,255,0.3);
}

.cv-profile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-classic .cv-profile-image {
    border: 4px solid #333;
    margin: 0 auto 20px;
}

.template-creative .cv-profile-image {
    width: 100px;
    height: 100px;
    margin-bottom: 15px;
}

/* Experience and Education items */
.experience-entry, .education-entry {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.experience-entry:last-child, .education-entry:last-child {
    border-bottom: none;
}

.experience-entry h4, .education-entry h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.experience-entry .company, .education-entry .school {
    font-weight: 500;
    color: #667eea;
    margin-bottom: 5px;
}

.experience-entry .date, .education-entry .date {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

.experience-entry p, .education-entry p {
    margin: 0;
    white-space: pre-line;
}

/* Profile Image Upload Styles */
.profile-image-section {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 2px dashed #e2e8f0;
    transition: all 0.3s ease;
}

.profile-image-section:hover {
    border-color: #667eea;
    background: #f1f5f9;
}

.image-upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.image-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    position: relative;
    overflow: hidden;
}

.image-preview:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.image-preview.has-image {
    border-color: #10b981;
}

.image-preview i {
    font-size: 40px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.image-preview span {
    font-size: 12px;
    color: #64748b;
    text-align: center;
    padding: 0 10px;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.hidden-input {
    display: none;
}

.image-upload-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-outline.small {
    padding: 8px 16px;
    font-size: 0.875rem;
    border-radius: 6px;
}

.hidden {
    display: none !important;
}

/* Template Switcher Styles */
.template-switcher {
    display: flex;
    gap: 5px;
    align-items: center;
}

.template-switch-btn {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.template-switch-btn:hover {
    background: #f1f5f9;
    border-color: #667eea;
}

.template-switch-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.template-indicator {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: normal;
    margin-left: 10px;
    padding: 4px 8px;
    background: #f1f5f9;
    border-radius: 4px;
}

/* Enhanced preview container - clean design */
.preview-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: transparent;
    padding: 10px; /* Adequate padding */
    border-radius: 0;
    min-height: 400px;
    overflow-y: auto; /* Vertical scrollbar */
    overflow-x: auto; /* Allow horizontal scroll if needed */
    border: none;
    /* Fill available space without hard clipping */
    height: auto;
    max-height: none;
    flex: 1 1 auto;
    width: 100%;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #64748b;
    text-align: center;
}

.preview-placeholder i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.preview-placeholder h3 {
    margin-bottom: 0.5rem;
    color: #374151;
}

/* Loading spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Demo data notice */
.demo-notice {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    color: #1e40af;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.demo-notice i {
    color: #3b82f6;
}

.preview-header {
    position: sticky;
    top: 0;
    background: white;
    z-index: 100;
    padding: 0.5rem 1rem; /* Reduced padding */
    border-bottom: 1px solid #e5e7eb;
    margin: -0.5rem -0.5rem 0.5rem -0.5rem; /* Adjusted margins */
    border-radius: 0; /* Remove border radius */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Template selector styles */
.template-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
}

.template-dropdown {
    padding: 0.4rem 0.8rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.2s ease;
    min-width: 120px;
}

.template-dropdown:hover {
    border-color: #2563eb;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

.template-dropdown:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Loading and switching indicators */
.loading-indicator,
.template-switching {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #6b7280;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator p,
.template-switching p {
    margin: 0;
    font-size: 0.9rem;
    color: #6b7280;
}

.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #dc2626;
    text-align: center;
}

.error-message i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.7;
}

.error-message p {
    margin: 0 0 16px 0;
    font-size: 0.9rem;
}

.retry-btn {
    padding: 8px 16px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.retry-btn:hover {
    background: #1d4ed8;
}

/* Scroll indicator for better UX */
.scroll-indicator {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    opacity: 0.8;
    pointer-events: none;
}

.cv-creative-sidebar-section {
    margin-top: 30px;
}

.cv-creative-sidebar-heading {
    margin-bottom: 10px;
    font-size: 1rem;
    color: white;
}

.cv-creative-sidebar-item {
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.cv-creative-main-section {
    margin-top: 0;
}

/* CV Template Display Fixes */
.cv-preview .cv-template {
    width: 210mm;
    min-height: 297mm;
    background: white;
    margin: 0 auto;
    padding: 15mm 12mm;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #2d3748;
    line-height: 1.6;
    transform-origin: top center;
    border-radius: 4px;
}

/* Ensure all templates are properly sized */
.cv-preview .template-modern,
.cv-preview .template-classic,
.cv-preview .template-creative,
.cv-preview .template-ats {
    max-width: 100%;
    overflow: visible; /* Let preview container handle scrolling */
}

/* Template-specific fixes */
/* Restrict negative header margins to modern template only to avoid overflow */
.cv-preview .template-modern .cv-header {
    margin-left: -12mm;
    margin-right: -12mm;
    margin-top: -15mm;
}

/* Text overflow handling */
.cv-preview h1,
.cv-preview h2,
.cv-preview h3,
.cv-preview p,
.cv-preview li {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Additional Form Spacing Fixes */
.form-section-block .form-row {
    margin-bottom: 1px; /* Ultra-tight spacing for form rows */
}

.form-section-block .form-group {
    margin-bottom: 0; /* Remove any default margins */
}

.form-section-block .form-group label {
    margin-bottom: 2px; /* Minimal label spacing */
}

.form-section-block h3 {
    margin-bottom: 0.8rem; /* Reduce heading spacing */
    margin-top: 0;
}

/* Specific override for personal info form rows */
.form-section-block .form-row + .form-row {
    margin-top: 0; /* Remove any top margin between consecutive rows */
}

/* Force minimal spacing on builder page */
.cv-builder .form-row {
    margin-bottom: 0px !important; /* Force zero spacing between form rows */
    padding-bottom: 5px; /* Add minimal padding instead of margin */
    margin-top: 0px !important; /* Force zero top margin */
}

.cv-builder .form-group {
    margin: 0 !important; /* Force zero margins on form groups */
    padding: 0; /* Remove padding too */
}

.cv-builder .form-group label {
    margin-bottom: 1px !important; /* Ultra-minimal label spacing */
    margin-top: 0 !important;
}

.cv-builder .form-group input,
.cv-builder .form-group select,
.cv-builder .form-group textarea {
    margin: 0 !important; /* Ensure no margins on inputs */
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

/* Ultra-specific targeting for personal info section */
.cv-builder .form-section-block .form-row {
    margin: 0 !important;
    padding: 0 !important;
    padding-bottom: 3px !important; /* Minimal visual separation */
}

/* Remove any browser default spacing */
.cv-builder .form-section-block * {
    box-sizing: border-box;
}

.cv-builder .form-section-block .form-row:not(:last-child) {
    border-bottom: none;
    margin-bottom: 0 !important;
}

/* EMERGENCY FIX - Target specific form row spacing issue */
.cv-builder .form-section-block div.form-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
    margin: 0 !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    line-height: 1 !important;
}

.cv-builder .form-section-block div.form-row + div.form-row {
    margin-top: 2px !important; /* Tiny gap between rows */
}

/* Reset any inherited spacing on form elements */
.cv-builder input[type="text"],
.cv-builder input[type="email"], 
.cv-builder input[type="tel"] {
    margin: 0 !important;
    margin-bottom: 0 !important;
    display: block !important;
    width: 100% !important;
}

/* CRITICAL FIX - Target the specific personal info section */
.cv-builder section[role="group"] .form-row {
    margin: 0 !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

.cv-builder section[role="group"] .form-row:nth-child(2) {
    margin-top: 0 !important; /* First form row (Name/Title) */
}

.cv-builder section[role="group"] .form-row:nth-child(3) {
    margin-top: 0 !important; /* Second form row (Email/Phone) */
}

/* Override ANY possible CSS that might add spacing */
.cv-builder #personal-info-heading ~ div.form-row {
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 1px !important;
}

/* MAXIMUM SPECIFICITY OVERRIDE - Last resort */
body main.cv-builder div.builder-container div.form-section section.form-section-block div.form-row {
    margin: 0 !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    padding-bottom: 1px !important;
    padding-top: 0 !important;
}

body main.cv-builder div.builder-container div.form-section section.form-section-block div.form-group {
    margin: 0 !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

/* Inline style backup */
div.form-row[style] {
    margin: 0 !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

/* FINAL EMERGENCY FIX - Target the exact HTML structure */
.cv-builder .form-section-block > .form-row:nth-of-type(2) {
    margin-top: 8px !important; /* Small top space for first form row */
    margin-bottom: 0 !important;
    padding-top: 0 !important;
}

.cv-builder .form-section-block > .form-row:nth-of-type(3) {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
}

/* Remove any potential line-height spacing */
.cv-builder .form-section-block {
    line-height: 1 !important;
}

.cv-builder .form-section-block * {
    line-height: inherit !important;
}

/* Zero out any browser default spacing for form elements */
.cv-builder .form-section-block input,
.cv-builder .form-section-block label,
.cv-builder .form-section-block div {
    vertical-align: top !important;
    line-height: 1.2 !important;
}
