/* CV Export Styles - Base styles for all CV themes */

/* Layout Structure */
.cv-container {
    display: flex;
    min-height: 100vh;
    background: #ffffff;
    font-family: 'Almarai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.cv-sidebar {
    width: 300px;
    min-width: 300px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    padding: 20px;
    overflow-y: auto;
}

.cv-main {
    flex: 1;
    padding: 20px;
    background: #ffffff;
    overflow-y: auto;
}

.cv-sidebar-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Profile Section */
.cv-profile {
    text-align: center;
    margin-bottom: 20px;
}

.cv-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2d3748;
    margin: 10px 0 5px 0;
}

.cv-headline {
    font-size: 1rem;
    color: #4a5568;
    margin-bottom: 15px;
}

.cv-bio {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #4a5568;
    margin-bottom: 20px;
}

/* Section Styling */
.cv-section {
    margin-bottom: 25px;
}

.cv-section h1,
.cv-section h2 {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 2px solid #e2e8f0;
}

/* Block Items */
.cv-block-item {
    margin-bottom: 15px;
    padding: 10px;
    background: #ffffff;
    border-radius: 5px;
    border-left: 3px solid #4299e1;
}

.cv-block-title {
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 5px;
}

.cv-block-subtitle {
    color: #4a5568;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.cv-block-details {
    color: #4a5568;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-line;
}

/* Contact Info */
.cv-contact-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
    gap: 8px;
}

.cv-contact-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.cv-contact-text {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    line-height: 1.4;
    word-break: break-word;
}

.cv-contact-item svg {
    width: 18px;
    height: 18px;
    color: #4a5568;
    flex-shrink: 0;
}

.cv-contact-item a {
    color: #4299e1;
    text-decoration: none;
}

.cv-contact-item a:hover {
    text-decoration: underline;
}

/* Skills */
.cv-skills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.cv-skill-item {
    background: #e2e8f0;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    color: #2d3748;
}

.cv-skill-level {
    background: #4299e1;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    margin-left: 5px;
}

/* Experience & Education */
.cv-experience-item,
.cv-education-item {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
}

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

.cv-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.cv-item-title {
    font-weight: bold;
    color: #2d3748;
    font-size: 1rem;
}

.cv-item-company {
    color: #4a5568;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.cv-item-dates {
    color: #718096;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cv-container {
        flex-direction: column;
    }

    .cv-sidebar {
        width: 100%;
        order: 2;
    }

    .cv-main {
        order: 1;
    }

    .cv-item-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .cv-item-dates {
        margin-top: 5px;
    }
}

/* Print Styles */
@media print {
    /* Ensure colors and backgrounds print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* EXPORT FIX: Reduce spacing to focus on CV content */
    @page {
        margin: 0.5cm;
    }

    body {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* MULTI-PAGE PDF FIX: Maintain flex layout for proper sidebar rendering */
    /* Note: flex-direction is set by inline styles in template based on language (RTL/LTR) */
    .cv-container {
        display: flex !important;
        min-height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* MULTI-PAGE PDF FIX: Keep sidebar fixed width instead of full width */
    .cv-sidebar {
        width: 300px !important;
        min-width: 300px !important;
        max-width: 300px !important;
        flex-shrink: 0 !important;
        background: #f8f9fa !important;
        border-right: 1px solid #e9ecef !important;
        border-bottom: none !important;
        margin-bottom: 0 !important;
        padding: 15px !important;
        /* Allow sidebar content to flow to next pages */
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* RTL: Sidebar on right side */
    [dir="rtl"] .cv-sidebar {
        border-right: none !important;
        border-left: 1px solid #e9ecef !important;
    }

    .cv-main {
        flex: 1 !important;
        padding: 15px !important;
        /* Allow main content to flow to next pages */
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Prevent page breaks inside sections */
    .cv-section {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .cv-experience-item,
    .cv-education-item,
    .cv-block-item {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* Keep section title with content */
    .cv-section h1,
    .cv-section h2,
    .cv-section h3 {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    /* Ensure borders and backgrounds are visible */
    .border,
    .border-b,
    .border-t,
    .border-l,
    .border-r {
        border-color: inherit !important;
    }

    /* Ensure bullet points are visible */
    ul, ol {
        list-style-position: inside !important;
    }

    /* EXPORT FIX: Ensure contact items align properly in print */
    .cv-contact-item {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        margin-bottom: 10px !important;
    }

    .cv-contact-icon {
        flex-shrink: 0 !important;
        width: 20px !important;
        height: 20px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .cv-contact-text {
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        line-height: 1.4 !important;
    }

    .cv-contact-item svg {
        width: 18px !important;
        height: 18px !important;
        flex-shrink: 0 !important;
    }

    /* EXPORT FIX: Prevent text clipping - ensure all text has proper line height */
    *:not(img) {
        line-height: 1.6 !important;
        overflow: visible !important;
    }

    h1, h2, h3, h4, h5, h6, p, span, div, small, a, li {
        line-height: 1.6 !important;
        overflow: visible !important;
        padding-bottom: 2px !important;
    }

    /* EXPORT FIX: Ensure profile images maintain aspect ratio and clipping */
    img {
        overflow: hidden !important;
    }

    /* EXPORT FIX: Block items must show text completely */
    .border-b, [class*="border"] {
        overflow: visible !important;
    }

    /* EXPORT FIX: Preserve padding for interest tags */
    .cv-interest-tag {
        padding: 6px 8px !important;
        line-height: normal !important;
    }
    .cv-interest-tag span {
        padding-bottom: 0 !important;
        line-height: normal !important;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-bold { font-weight: bold; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }

/* RTL Support */
/* Note: dir="rtl" already reverses flex row direction, no need for row-reverse */

[dir="rtl"] .cv-item-dates {
    text-align: left;
}

[dir="rtl"] .cv-sidebar {
    border-right: none;
    border-left: 1px solid #e9ecef;
}

/* LTR specific fixes for badges */
[dir="ltr"] .cv-sidebar {
    border-right: 1px solid #e9ecef;
    border-left: none;
}

/* Theme Color Variations */
.cv-theme-blue .cv-block-item {
    border-left-color: #4299e1;
}

.cv-theme-green .cv-block-item {
    border-left-color: #48bb78;
}

.cv-theme-purple .cv-block-item {
    border-left-color: #9f7aea;
}

.cv-theme-red .cv-block-item {
    border-left-color: #f56565;
}

/* EXPORT FIX: Optimized spacing for PDF/Screenshot exports */
/* Applied when body has specific classes or inline styles */
/* Note: flex-direction is set by inline styles in template based on language (RTL/LTR) */
body[style*="margin: 0"] .cv-container,
body[style*="padding: 0"] .cv-container {
    display: flex !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: auto !important;
}

body[style*="margin: 0"] .cv-sidebar {
    width: 300px !important;
    min-width: 300px !important;
    max-width: 300px !important;
    flex-shrink: 0 !important;
    padding: 15px !important;
    margin-bottom: 0 !important;
}

body[style*="margin: 0"] .cv-main {
    flex: 1 !important;
    padding: 15px !important;
}

/* Remove excessive section spacing in exports */
body[style*="margin: 0"] .cv-section {
    margin-bottom: 15px !important;
}

body[style*="margin: 0"] .cv-experience-item,
body[style*="margin: 0"] .cv-education-item {
    margin-bottom: 15px !important;
    padding-bottom: 10px !important;
}

/* ==============================================
   MULTI-PAGE PDF EXPORT STYLES
   For Cloudflare Browser Rendering and similar services
   ============================================== */

/* Force flex layout for multi-page PDF exports */
.md\:flex {
    display: flex !important;
}

@media print {
    /* Ensure Tailwind flex classes work in print */
    /* Note: flex-direction is set by inline styles in template based on language (RTL/LTR) */
    .md\:flex {
        display: flex !important;
    }

    /* Fix for themes using md:flex with overflow-hidden */
    .md\:flex.overflow-hidden {
        overflow: visible !important;
    }

    /* Ensure flex children maintain their layout */
    .md\:flex > .w-full:first-child,
    .md\:flex > div:first-child {
        flex-shrink: 0 !important;
    }

    /* Background colors must be preserved in PDF */
    .bg-white { background-color: #ffffff !important; }
    .bg-gray-50 { background-color: #f9fafb !important; }
    .bg-gray-100 { background-color: #f3f4f6 !important; }
    .bg-blue-50 { background-color: #eff6ff !important; }
    .bg-blue-100 { background-color: #dbeafe !important; }
    .bg-blue-500 { background-color: #3b82f6 !important; }
    .bg-blue-600 { background-color: #2563eb !important; }
    .bg-blue-800 { background-color: #1e40af !important; }
    .bg-blue-900 { background-color: #1e3a8a !important; }

    /* Gradient backgrounds for PDF */
    .bg-gradient-to-l { background-image: linear-gradient(to left, var(--tw-gradient-stops)) !important; }
    .bg-gradient-to-r { background-image: linear-gradient(to right, var(--tw-gradient-stops)) !important; }
    .from-blue-800 { --tw-gradient-from: #1e40af !important; }
    .to-blue-400 { --tw-gradient-to: #60a5fa !important; }
    .to-blue-500 { --tw-gradient-to: #3b82f6 !important; }

    /* ==============================================
       TAILWIND THEME FIXES FOR MULTI-PAGE PDF
       For themes using Tailwind classes like indigo, etc.
       ============================================== */

    /* Force md: breakpoint to apply in print (Chrome uses ~800px for print) */
    .md\:flex {
        display: flex !important;
    }

    .md\:flex-no-wrap {
        flex-wrap: nowrap !important;
    }

    /* Fix sidebar width for Tailwind themes */
    .md\:max-w-xs {
        max-width: 20rem !important;
        min-width: 20rem !important;
        width: 20rem !important;
    }

    .lg\:w-96 {
        width: 24rem !important;
    }

    /* Ensure flex-shrink-0 works */
    .flex-shrink-0 {
        flex-shrink: 0 !important;
    }

    /* Fix full width sections */
    .w-full {
        width: 100% !important;
    }

    /* But not for sidebar that has max-w constraints */
    .md\:max-w-xs.w-full,
    .lg\:w-96.w-full {
        width: auto !important;
    }

    /* Sidebar background colors must be preserved */
    .md\:bg-blue-50 {
        background-color: #eff6ff !important;
    }

    .md\:bg-gray-50 {
        background-color: #f9fafb !important;
    }

    .md\:bg-gray-100 {
        background-color: #f3f4f6 !important;
    }

    /* Ensure rounded corners work */
    .md\:rounded-s {
        border-start-start-radius: 0.25rem !important;
        border-end-start-radius: 0.25rem !important;
    }

    /* RTL rounded corners */
    [dir="rtl"] .md\:rounded-s {
        border-start-start-radius: 0 !important;
        border-end-start-radius: 0 !important;
        border-start-end-radius: 0.25rem !important;
        border-end-end-radius: 0.25rem !important;
    }
}

