/* ==========================================================================
   CV BUILDER - TEMPLATE DYNAMIC (NĂNG ĐỘNG)
   Áp dụng kiến trúc CSS phân tầng độc lập & hỗ trợ 3 bảng màu theo [data-theme]
   Bố cục:
   - Header: Khối Avatar vuông 140px viền trắng nền tối (Col-3 / 25%) + Họ tên to & Thông tin cơ bản (Col-9 / 75%)
   - Dải liên hệ ngang toàn phần (Full-width Horizontal Contact Bar) mang màu nền chủ đạo theme
   - Thân CV 2 cột không đối xứng:
     * Cột trái - Sidebar tối màu (Col-3 / 25%): Giới thiệu bản thân & Mong muốn về công việc (chữ trắng)
     * Cột phải - Nội dung chính (Col-9 / 75%): Công việc mong muốn, Học vấn, Kinh nghiệm, Giải thưởng, Kỹ năng & Tham khảo (chia đôi Col-6/Col-6)
   ========================================================================== */

/* ==========================================================================
   1. THEME VARIABLES CHO 3 BẢNG MÀU CỦA TEMPLATE DYNAMIC
   ========================================================================== */

/* 1.1. Theme Emerald (Xanh năng động - Bản gốc & Mặc định) */
.cv-template-dynamic,
.cv-template-dynamic[data-theme="emerald"],
[data-theme="emerald"] .cv-template-dynamic,
[data-theme="emerald"]#cvDynamicComponent,
#cvDynamicComponent[data-theme="emerald"],
[data-theme="emerald"]#cvSimplePreview,
#cvSimplePreview[data-theme="emerald"],
[data-theme="emerald"]#cvSimpleLivePaper,
#cvSimpleLivePaper[data-theme="emerald"],
[data-theme="emerald"]#cvDirectSheet,
#cvDirectSheet[data-theme="emerald"],
[data-theme="emerald"] {
    --cv-primary: #059669;
    --cv-primary-subtle: #ecfdf5;
    --cv-primary-dark: #047857;
    --cv-primary-rgb: 5, 150, 105;
    --cv-sidebar-bg: #1e293b;
    --cv-accent: #047857;
    --cv-border: #a7f3d0;
    --cv-text-dark: #064e3b;
    --cv-mock-border: #a7f3d0;

    --cv-theme-primary: #059669;
    --cv-theme-sidebar-bg: #1e293b;
    --cv-theme-sidebar: #1e293b;
    --cv-theme-accent: #047857;
    --cv-theme-border: #a7f3d0;
    --cv-theme-text-dark: #064e3b;
    --cv-mock-primary: #059669;
    --cv-mock-sidebar-bg: #1e293b;
}

/* 1.2. Theme Crimson (Đỏ nhiệt huyết) */
.cv-template-dynamic[data-theme="crimson"],
[data-theme="crimson"] .cv-template-dynamic,
[data-theme="crimson"]#cvDynamicComponent,
#cvDynamicComponent[data-theme="crimson"],
[data-theme="crimson"]#cvSimplePreview,
#cvSimplePreview[data-theme="crimson"],
[data-theme="crimson"]#cvSimpleLivePaper,
#cvSimpleLivePaper[data-theme="crimson"],
[data-theme="crimson"]#cvDirectSheet,
#cvDirectSheet[data-theme="crimson"],
[data-theme="crimson"] {
    --cv-primary: #dc2626;
    --cv-primary-subtle: #fef2f2;
    --cv-primary-dark: #b91c1c;
    --cv-primary-rgb: 220, 38, 38;
    --cv-sidebar-bg: #1e293b;
    --cv-accent: #b91c1c;
    --cv-border: #fecaca;
    --cv-text-dark: #991b1b;
    --cv-mock-border: #fecaca;

    --cv-theme-primary: #dc2626;
    --cv-theme-sidebar-bg: #1e293b;
    --cv-theme-sidebar: #1e293b;
    --cv-theme-accent: #b91c1c;
    --cv-theme-border: #fecaca;
    --cv-theme-text-dark: #991b1b;
    --cv-mock-primary: #dc2626;
    --cv-mock-sidebar-bg: #1e293b;
}

/* 1.3. Theme Navy (Xanh hải quân) */
.cv-template-dynamic[data-theme="navy"],
[data-theme="navy"] .cv-template-dynamic,
[data-theme="navy"]#cvDynamicComponent,
#cvDynamicComponent[data-theme="navy"],
[data-theme="navy"]#cvSimplePreview,
#cvSimplePreview[data-theme="navy"],
[data-theme="navy"]#cvSimpleLivePaper,
#cvSimpleLivePaper[data-theme="navy"],
[data-theme="navy"]#cvDirectSheet,
#cvDirectSheet[data-theme="navy"],
[data-theme="navy"] {
    --cv-primary: #1e3a8a;
    --cv-primary-subtle: #eff6ff;
    --cv-primary-dark: #172554;
    --cv-primary-rgb: 30, 58, 138;
    --cv-sidebar-bg: #0f172a;
    --cv-accent: #172554;
    --cv-border: #bfdbfe;
    --cv-text-dark: #1e3a8a;
    --cv-mock-border: #bfdbfe;

    --cv-theme-primary: #1e3a8a;
    --cv-theme-sidebar-bg: #0f172a;
    --cv-theme-sidebar: #0f172a;
    --cv-theme-accent: #172554;
    --cv-theme-border: #bfdbfe;
    --cv-theme-text-dark: #1e3a8a;
    --cv-mock-primary: #1e3a8a;
    --cv-mock-sidebar-bg: #0f172a;
}

/* ==========================================================================
   2. COLOR SWATCHES CHO PALETTE BUTTONS
   ========================================================================== */
.cv-swatch-emerald {
    background-color: #059669;
}

.cv-swatch-crimson {
    background-color: #dc2626;
}

.cv-swatch-navy {
    background-color: #1e3a8a;
}

/* ==========================================================================
   3. CLASS ĐỊNH HÌNH CẤU TRÚC TEMPLATE DYNAMIC CHUẨN GỐC
   ========================================================================== */
.cv-template-dynamic {
    background-color: #ffffff;
    width: 100%;
    min-height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1e293b;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* 3.1. Header: Khối Avatar vuông nền tối & Khối thông tin bên phải */
.cv-dynamic-header-avatar {
    background-color: var(--cv-theme-sidebar-bg, #1e293b);
    padding: 20px 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.cv-dynamic-avatar-wrapper {
    width: 140px;
    height: 140px;
    position: relative;
    flex-shrink: 0;
}

.cv-dynamic-avatar {
    width: 140px;
    height: 140px;
    min-width: 140px;
    min-height: 140px;
    max-width: 140px;
    max-height: 140px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 12px !important;
    border: 3px solid #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: block;
}

.cv-dynamic-avatar-placeholder {
    width: 140px;
    height: 140px;
    border-radius: 12px;
    border: 3px solid #ffffff;
    background-color: #334155;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cv-dynamic-header-main {
    background-color: #ffffff;
    padding: 20px 24px;
}

.cv-dynamic-fullname {
    font-size: 1.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #0f172a;
    line-height: 1.2;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.cv-dynamic-title {
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.5px;
    margin-bottom: 0;
}

.cv-dynamic-basic-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #475569;
}

.cv-dynamic-basic-icon {
    width: 20px;
    text-align: center;
    color: var(--cv-theme-primary, #059669);
    font-size: 14px;
    flex-shrink: 0;
}

/* 3.2. Dải liên hệ ngang toàn phần (Full-width Horizontal Contact Bar) */
.cv-dynamic-contact-bar {
    background-color: var(--cv-theme-primary, #059669);
    color: #ffffff;
    padding: 10px 20px;
    margin: 0;
    width: 100%;
    transition: background-color 0.2s ease;
}

.cv-dynamic-contact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #ffffff;
    min-width: 0;
}

.cv-dynamic-contact-icon {
    width: 20px;
    text-align: center;
    color: #ffffff;
    font-size: 14px;
    opacity: 0.9;
    flex-shrink: 0;
}

.cv-dynamic-contact-text {
    color: #ffffff;
    min-width: 0;
}

.cv-dynamic-contact-item .form-control-plaintext {
    color: #ffffff;
    min-width: 0;
    width: 100%;
}

.cv-dynamic-contact-item .form-control-plaintext::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* 3.3. Thân CV: Cột trái Sidebar tối màu (Col-3 / 25%) */
.cv-dynamic-sidebar {
    background-color: var(--cv-theme-sidebar-bg, #1e293b);
    color: #ffffff;
    padding: 24px 16px;
    min-height: 100%;
    transition: background-color 0.2s ease;
}

.cv-dynamic-sidebar-title {
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--cv-theme-primary, #059669);
    padding-bottom: 6px;
    margin-bottom: 12px;
    transition: border-color 0.2s ease;
}

.cv-dynamic-sidebar-text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    line-height: 1.6;
}

/* 3.4. Thân CV: Cột phải Nội dung chính (Col-9 / 75%) */
.cv-dynamic-main {
    background-color: #ffffff;
    padding: 24px 24px;
}

.cv-dynamic-section-title {
    color: #1e293b;
    font-weight: 700;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--cv-theme-primary, #059669);
    padding-bottom: 6px;
    margin-bottom: 16px;
    transition: border-color 0.2s ease;
}

.cv-dynamic-tag {
    display: inline-block;
    background-color: var(--cv-primary-subtle, #ecfdf5);
    color: var(--cv-theme-text-dark, #064e3b);
    border: 1px solid var(--cv-theme-border, #a7f3d0);
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 6px;
    margin-bottom: 6px;
    transition: all 0.2s ease;
}

.cv-dynamic-timeline-item {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #e2e8f0;
}

.cv-dynamic-timeline-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* 3.5. Kỹ năng sao & Người tham khảo chia đôi */
.cv-dynamic-skill-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.cv-dynamic-star {
    color: #f59e0b;
    font-size: 12px;
}

.cv-dynamic-star-empty {
    color: #cbd5e1;
    font-size: 12px;
}

.cv-dynamic-ref-item {
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px dashed #f1f5f9;
}

.cv-dynamic-ref-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

/* ==========================================================================
   4. DIRECT EDITING MODE CLASSES (SOẠN THẢO TRỰC TIẾP)
   ========================================================================== */
.cv-dynamic-direct-fullname {
    font-size: 1.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #0f172a;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.cv-dynamic-direct-title {
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.5px;
}

/* Inputs trên dải liên hệ ngang (chữ trắng trên nền màu theme) */
.cv-dynamic-contact-bar .form-control-plaintext {
    color: #ffffff !important;
}

.cv-dynamic-contact-bar .form-control-plaintext::placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
}

.cv-dynamic-contact-bar .hover-border:hover,
.cv-dynamic-contact-bar .hover-border:focus {
    border-color: rgba(255, 255, 255, 0.5) !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Inputs & Textareas trên Sidebar tối màu (chữ trắng trên nền tối) */
.cv-dynamic-sidebar .form-control-plaintext {
    color: #ffffff !important;
}

.cv-dynamic-sidebar .form-control-plaintext::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

.cv-dynamic-sidebar .hover-border:hover,
.cv-dynamic-sidebar .hover-border:focus {
    border-color: rgba(255, 255, 255, 0.3) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Nút xóa item trực tiếp */
.cv-dynamic-remove-btn {
    border: none;
    background: transparent;
    padding: 0 4px;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    color: #ef4444;
    transition: transform 0.15s ease;
}

.cv-dynamic-remove-btn:hover {
    transform: scale(1.15);
}

.cv-dynamic-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--cv-theme-primary, #059669);
    background: transparent;
    border: 1px dashed var(--cv-theme-primary, #059669);
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.cv-dynamic-add-btn:hover {
    background-color: var(--cv-primary-subtle, #ecfdf5);
    color: var(--cv-theme-primary, #059669);
}

/* ==========================================================================
   5. TỐI ƯU HÓA IN ẤN & XUẤT PDF (@media print)
   ========================================================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    /* Ẩn hoàn toàn các thành phần điều khiển khi in */
    .cv-show-topbar,
    .cv-public-topbar,
    .btn,
    .cv-preview-control,
    .cv-preview-actions,
    .no-print,
    header,
    footer,
    nav,
    .cv-builder-header,
    .cv-form-toolbar,
    .cv-dynamic-add-btn,
    .cv-dynamic-remove-btn,
    .removeDiv {
        display: none !important;
    }

    /* Reset margin, padding, shadow cho stage, sheet & template */
    .cv-paper-stage,
    .cv-a4-sheet,
    .cv-template-dynamic {
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .cv-paper-stage {
        background: transparent !important;
    }

    .cv-template-dynamic,
    .cv-dynamic-header-avatar,
    .cv-dynamic-sidebar,
    .cv-dynamic-contact-bar,
    .cv-dynamic-main {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .cv-dynamic-header-avatar,
    .cv-dynamic-sidebar {
        background-color: #1e293b !important;
        color: #ffffff !important;
    }

    .cv-dynamic-contact-bar {
        background-color: var(--cv-theme-primary, #059669) !important;
        color: #ffffff !important;
    }

    .cv-dynamic-timeline-item,
    .cv-dynamic-skill-item,
    .cv-dynamic-ref-item,
    .cv-dynamic-header-avatar,
    .cv-dynamic-contact-bar,
    .cv-live-exp-item,
    .cv-live-edu-item,
    .cv-live-skill-item,
    .cv-live-award-item,
    .cv-live-ref-item {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }
}
