/* Resume Builder Styles */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: --gray-700;
    --border-color: #e5e7eb;
    --bg-light: #f9fafb;
    --text-dark: #111827;
    --text-muted: #6b7280;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f3f4f6;
    margin: 0;
    padding: 0;
}

.resume-builder-container {
    display: flex;
    min-height: 100vh;
    background: #fff;
}

/* Left Panel - Form Section */
.resume-form-panel {
    flex: 1;
    max-width: 600px;
    padding: 2rem;
    overflow-y: auto;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
}

.resume-form-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.resume-form-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 0.5rem 0;
}

.resume-form-header p {
    color: var(--text-muted);
    margin: 0;
    font-size: 7pt;
}

/* Form Sections */
.form-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-light);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.form-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-color);
}

.form-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.form-group label .required {
    color: #ef4444;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Photo Upload */
.photo-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

.photo-upload-area:hover {
    border-color: var(--primary-color);
    background: #fafafa;
}

.photo-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 1rem;
    display: none;
}

.photo-preview.show {
    display: block;
}

.upload-icon {
    width: 64px;
    height: 64px;
    background: var(--bg-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
}

.upload-text strong {
    color: var(--primary-color);
    cursor: pointer;
}

.btn-remove-photo {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-remove-photo:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.photo-upload-area {
    position: relative;
}

/* Dynamic Lists (Experience, Education, etc.) */
.dynamic-list {
    margin-top: 1rem;
}

.dynamic-item {
    background: white;
    padding: 1.25rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    position: relative;
}

.dynamic-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.dynamic-item-title {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 8pt;
}

.btn-remove-item {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-remove-item:hover {
    background: #dc2626;
}

.btn-add-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-item:hover {
    background: var(--primary-color);
    color: white;
}

/* Skills Tags */
.skills-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    min-height: 42px;
}

#skillsWrapper .skill-tag {
    font-size: 8pt;
}

.skill-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--primary-color);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8125rem;
}

.skill-tag button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    margin: 0;
    font-size: 1rem;
    line-height: 1;
}

.skills-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    min-width: 120px;
    font-size: 0.9375rem;
}

/* Right Panel - Preview Section */
.resume-preview-panel {
    flex: 1;
    background: #e5e7eb;
    padding: 2rem;
    overflow-y: auto;
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid #17b890;
}

.mobile-preview-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(---text-muted);
    color: #17b890;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    border: none;
    width: 100%;
    z-index: 1001;
}

.mobile-preview-toggle i {
    transition: transform 0.3s ease;
}

.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-template-select {
    padding: 0.625rem 1.25rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-template-select:hover {
    background: var(--primary-hover);
}

.btn-save {
    padding: 0.625rem 1.25rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-save:hover {
    background: #2563eb;
}

.btn-download {
    padding: 0.625rem 1.5rem;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-download:hover {
    background: #059669;
}

.btn-save-permanent {
    width: 100%;
    padding: 1rem 2rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-save-permanent:hover {
    background: #2563eb;
}

.resume-preview-container {
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    min-height: 600px;
    margin: 0 auto;
    overflow-x: auto;
    /* Allow scrolling if scaling is disabled or content is long */
    overflow-y: auto;
}

#resumePreview {
    transform-origin: top left;
    transition: transform 0.2s ease;
}

/* Template Selection Modal */
.template-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 4000;
    align-items: center;
    justify-content: center;
}

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

.template-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
}

.template-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.template-modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 32px;
    height: 32px;
}

.template-colors {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
    align-items: center;
}

.template-colors label {
    font-weight: 500;
    margin-right: 0.5rem;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--text-dark);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text-dark);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 350px);
    gap: 2rem;
    justify-content: center;
}

.template-card {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
    width: 350px;
    height: 500px;
    display: flex;
    flex-direction: column;
}

.template-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
    transform: translateY(-2px);
}

.template-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.template-preview-img {
    width: 100%;
    flex: 1;
    background: var(--bg-light);
    display: block;
    overflow: auto;
    position: relative;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.template-card-footer {
    padding: 1rem;
    text-align: center;
}

.template-name {
    font-weight: 600;
    margin: 0;
}

.btn-save-template {
    margin-top: 2rem;
    padding: 0.75rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

.btn-save-template:hover {
    background: var(--primary-hover);
}


.preview-controls #deleteCounterContainer {
    font-size: 8pt;
}

/* Responsive */
@media (max-width: 1024px) {

    /* Hand-tune preview aesthetics for mobile specifically */
    #resumePreview {
        /* Encourage a slightly larger base font if scaled deeply */
        --t1-text-size: 8.5pt !important;
        --t1-title-size: 11pt !important;
        --t1-name-size: 22pt !important;

        /* Reduce extreme white space on mobile previews */
        --t1-page-padding-left: 15px !important;
        --t1-page-padding-right: 15px !important;
        --t1-section-gap: 8px !important;

        /* Ensure the container doesn't force a minimum scale-breaking width */
        min-width: 0 !important;
        margin: 0 auto;
    }

    .resume-builder-container {
        flex-direction: column;
        padding-bottom: 60px;
        /* Space for collapsed preview */
    }

    .resume-form-panel {
        max-width: 100%;
        border-right: none;
        padding: 1.5rem;
    }

    .resume-preview-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        /* Use dynamic viewport height for mobile browsers */
        transform: translateY(calc(100% - 60px));
        /* Only show the toggle button */
        padding: 0;
        z-index: 2000;
        background: #fff;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.15);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.4s ease;
    }

    .resume-preview-panel.expanded {
        transform: translateY(0);
        overflow-y: auto;
        background: #f3f4f6;
        display: flex;
        flex-direction: column;
    }

    /* Target the container for horizontal scroll */
    .resume-preview-container {
        flex: 1;
        display: block;
        /* Use block for proper scroll triggering */
        overflow-x: auto !important;
        overflow-y: auto;
        width: 100%;
        margin-bottom: 20px;
        border: none;
        box-shadow: none;
        -webkit-overflow-scrolling: touch;
        padding: 20px 0;
        background: transparent;
        text-align: center;
        /* Center the resume */

        /* Custom Scrollbar Styles */
        scrollbar-width: thin;
        scrollbar-color: #17b890 transparent;
    }

    .resume-preview-container::-webkit-scrollbar {
        height: 6px;
    }

    .resume-preview-container::-webkit-scrollbar-track {
        background: transparent;
    }

    .resume-preview-container::-webkit-scrollbar-thumb {
        background-color: #17b890;
        border-radius: 10px;
    }

    #resumePreview {
        display: inline-block;
        min-width: 100%;
        text-align: left;
        vertical-align: top;
        transform: scale(1) !important;
        /* Prevent distortion on small screens */
        transform-origin: top center;
        width: 794px;
        /* Force A4 width to trigger scroll */
        margin: 0 auto;
        background: white;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    .mobile-preview-toggle {
        display: flex;
        flex-shrink: 0;
        height: 60px;
        position: sticky;
        top: 0;
        z-index: 2001;
        background: #fff;
    }

    .resume-preview-panel.expanded .mobile-preview-toggle {
        background: #374151;
        /* Darker color for expanded state */
    }

    .preview-controls {
        flex-direction: column;
        gap: 0.75rem;
        margin: 0.75rem;
        padding: 0.75rem;
    }

    .btn-template-select,
    .btn-save,
    .btn-download {
        width: 100%;
        justify-content: center;
        padding: 0.5rem 1rem;
        font-size: 5pt;
    }

    .btn-delete {
        font-size: 5pt;
    }

    .preview-controls #deleteCounterContainer {
        font-size: 7pt;
    }

    .template-modal-content {
        width: 95%;
        padding: 1rem;
    }

    .templates-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .template-card {
        width: 100%;
        max-width: 350px;
        margin: 0 auto;
        height: auto;
        aspect-ratio: 7/10;
    }
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}



/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Save Indicator */
.save-indicator {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #10b981;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    align-items: center;
    gap: 0.5rem;
    z-index: 999;
}

.save-indicator.show {
    display: flex;
}

/* Rich Text Editor */
.rich-text-editor {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    overflow: hidden;
}

.rich-text-toolbar {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    background: #f9fafb;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.rich-text-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    color: #374151;
}

.rich-text-toolbar button:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.rich-text-toolbar button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.rich-text-toolbar .separator {
    width: 1px;
    height: 32px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

.rich-text-content {
    min-height: 80px;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    line-height: 1.6;
    outline: none;
    overflow-y: auto;
    max-height: 300px;
}

.rich-text-content:empty:before {
    content: attr(data-placeholder);
    color: #9ca3af;
}

.rich-text-content ul,
.rich-text-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.rich-text-content li {
    margin: 0.25rem 0;
}

.enhance-ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s;
}

.enhance-ai-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.enhance-ai-btn i {
    font-size: 1rem;
}