/* ==========================================================================
   CV BUILDER - TEMPLATE CREATIVE (SÁNG TẠO)
   Áp dụng kiến trúc CSS phân tầng độc lập & hỗ trợ đa bảng màu theo [data-theme]
   Bố cục: KHÔNG sidebar - toàn bộ nội dung là các card bo góc nền be ấm xếp dọc
   trên nền trắng: dải liên hệ ngang trên cùng, card Header (Họ tên/Chức danh/
   Thông tin cơ bản/Giới thiệu bên trái + Avatar vuông bên phải), card Kinh nghiệm
   full-width timeline chấm tròn 2 cột, hàng card ngang Học vấn/Giải thưởng/Kỹ
   năng, hàng card cuối Mong muốn công việc/Công việc mong muốn/Tham khảo.
   ========================================================================== */

/* 1. THEME VARIABLES CHO CÁC BẢNG MÀU CỦA TEMPLATE CREATIVE */

/* 1.1. Theme Terracotta (Đất nung cam ấm - Mặc định) */
.cv-template-creative,
.cv-template-creative[data-theme="terracotta"],
[data-theme="terracotta"] .cv-template-creative,
[data-theme="terracotta"]#cvCreativeComponent,
#cvCreativeComponent[data-theme="terracotta"],
[data-theme="terracotta"] {
    --cv-primary: #8c3b2a;
    --cv-primary-subtle: #faf3ef;
    --cv-primary-dark: #6b2a1d;
    --cv-primary-rgb: 140, 59, 42;
    --cv-card-bg: #ebe5e0;
    --cv-accent: #f07b5a;
    --cv-border: #f2b5a2;
    --cv-text-dark: #1f1f1f;
    --cv-mock-border: #f2b5a2;

    --cv-theme-primary: #8c3b2a;
    --cv-theme-primary-subtle: #faf3ef;
    --cv-theme-primary-dark: #6b2a1d;
    --cv-theme-card-bg: #ebe5e0;
    --cv-theme-accent: #f07b5a;
    --cv-theme-border: #f2b5a2;
    --cv-theme-text-dark: #1f1f1f;
}

/* 1.2. Theme Cocoa Latte (Nâu cà phê sữa) */
.cv-template-creative[data-theme="cocoa_latte"],
[data-theme="cocoa_latte"] .cv-template-creative,
[data-theme="cocoa_latte"]#cvCreativeComponent,
#cvCreativeComponent[data-theme="cocoa_latte"],
[data-theme="cocoa_latte"] {
    --cv-primary: #6f4e37;
    --cv-primary-subtle: #f8f4f0;
    --cv-primary-dark: #4a3424;
    --cv-primary-rgb: 111, 78, 55;
    --cv-card-bg: #ece6df;
    --cv-accent: #c08a5b;
    --cv-border: #dcc3ab;
    --cv-text-dark: #1f1f1f;
    --cv-mock-border: #dcc3ab;

    --cv-theme-primary: #6f4e37;
    --cv-theme-primary-subtle: #f8f4f0;
    --cv-theme-primary-dark: #4a3424;
    --cv-theme-card-bg: #ece6df;
    --cv-theme-accent: #c08a5b;
    --cv-theme-border: #dcc3ab;
    --cv-theme-text-dark: #1f1f1f;
}

/* 1.3. Theme Moss Studio (Xanh rêu studio) */
.cv-template-creative[data-theme="moss_studio"],
[data-theme="moss_studio"] .cv-template-creative,
[data-theme="moss_studio"]#cvCreativeComponent,
#cvCreativeComponent[data-theme="moss_studio"],
[data-theme="moss_studio"] {
    --cv-primary: #3f6212;
    --cv-primary-subtle: #f5f8ef;
    --cv-primary-dark: #2d4a0c;
    --cv-primary-rgb: 63, 98, 18;
    --cv-card-bg: #e7eadf;
    --cv-accent: #84a33a;
    --cv-border: #c5d6a0;
    --cv-text-dark: #1f1f1f;
    --cv-mock-border: #c5d6a0;

    --cv-theme-primary: #3f6212;
    --cv-theme-primary-subtle: #f5f8ef;
    --cv-theme-primary-dark: #2d4a0c;
    --cv-theme-card-bg: #e7eadf;
    --cv-theme-accent: #84a33a;
    --cv-theme-border: #c5d6a0;
    --cv-theme-text-dark: #1f1f1f;
}

/* 2. COLOR SWATCHES CHO PALETTE BUTTONS */
.cv-swatch-terracotta {
    background-color: #8c3b2a;
}

.cv-swatch-cocoa_latte {
    background-color: #6f4e37;
}

.cv-swatch-moss_studio {
    background-color: #3f6212;
}

/* 3. CLASS ĐỊNH HÌNH CẤU TRÚC TEMPLATE CREATIVE CHUẨN */
.cv-template-creative {
    background-color: #ffffff;
    width: 100%;
    min-height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--cv-theme-text-dark, #1f1f1f);
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 24px;
}

/* 3.1. Card bo góc dùng chung cho mọi khối nội dung */
.cv-creative-card {
    background-color: var(--cv-theme-card-bg, #ebe5e0);
    border-radius: 6px;
    padding: 16px;
    transition: background-color 0.15s ease-in-out;
}

.cv-creative-card-heading {
    color: var(--cv-theme-primary);
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--cv-theme-accent);
    transition: color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

/* 3.2. Dải liên hệ ngang trên cùng */
.cv-creative-contact-strip {
    padding: 10px 16px;
}

.cv-creative-contact-item {
    line-height: 1.4;
}

.cv-creative-icon {
    color: var(--cv-theme-accent);
}

/* 3.3. Card Header: Họ tên/Chức danh/Avatar */
.cv-creative-fullname {
    color: var(--cv-theme-primary);
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: 0.2px;
}

.cv-creative-role-title {
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--cv-theme-text-dark, #1f1f1f);
}

.cv-creative-role-title::after {
    content: "";
    display: inline-block;
    width: 36px;
    height: 2px;
    background-color: var(--cv-theme-accent);
    margin-left: 10px;
}

.cv-creative-avatar {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 6px;
}

.cv-creative-avatar-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    background-color: var(--cv-theme-primary-subtle, #faf3ef);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--cv-theme-primary);
    font-size: 2rem;
}

/* 3.4. Chữ nhấn trên card dùng primary (KHÔNG dùng accent cho chữ) */
.cv-creative-text-primary {
    color: var(--cv-theme-primary);
}

/* 3.5. Kinh nghiệm: Timeline chấm tròn accent + đường kẻ dọc */
.cv-creative-timeline-item {
    position: relative;
    padding-left: 20px;
    border-left: 2px solid var(--cv-theme-border);
    padding-bottom: 2px;
}

.cv-creative-timeline-dot {
    position: absolute;
    left: -7px;
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--cv-theme-accent);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px var(--cv-theme-border);
}

/* 3.6. Kỹ năng: bullet phẳng full-width, KHÔNG sao, KHÔNG hộp */
.cv-creative-skill-item {
    position: relative;
    padding-left: 14px;
}

.cv-creative-skill-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 7px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--cv-theme-accent);
}

/* 3.7. Tag pill Nơi làm việc/Ngành nghề/Lĩnh vực */
.cv-creative-tag-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--cv-theme-border);
    background-color: var(--cv-theme-primary-subtle, #faf3ef);
    color: var(--cv-theme-primary);
    font-size: 0.72rem;
    font-weight: 500;
}

/* 3.8. Khối Tham khảo: ẩn ở CẤP .col bọc ngoài khi rỗng (để 2 card còn lại tự giãn đều).
   Dùng :has() thay vì d-none server-side vì syncReferences() chỉ dựng lại container,
   không gỡ class trên .col -> nếu dùng d-none, tham khảo thêm ở Form Mode sẽ không bao giờ hiện. */
.cv-template-creative .cv-creative-ref-col:has(.cv-live-ref-empty) {
    display: none;
}

/* 4. TƯƠNG THÍCH ĐỒNG BỘ JS REPEATER LIVE PREVIEW (KHI CHÈN CLASS .cv-simple-*)
   JS dùng chung `syncAllRepeaters()` trong create_form.blade.php dựng markup cứng mang class gốc
   của template `simple` (hộp sáng, sao đánh giá, chữ tối) cho MỌI template Form Mode.
   Khối dưới đây ghi đè để khớp giao diện creative (timeline chấm tròn + bullet phẳng full-width). */

/* 4.1. Alias .cv-simple-title -> màu primary (chữ nhấn trên card dùng primary, không dùng accent) */
.cv-template-creative .cv-simple-title {
    color: var(--cv-theme-primary) !important;
}

/* 4.2. Khối Kinh nghiệm/Giải thưởng do JS dựng (.cv-simple-timeline-card) -> timeline chấm tròn accent
   + viền trái xám khớp timeline bản server (duy nhất khối Kinh nghiệm có timeline thật trong component). */
.cv-template-creative .cv-simple-timeline-card.cv-live-exp-item {
    position: relative;
    border-left: 2px solid var(--cv-theme-border) !important;
    padding-left: 20px !important;
    margin-bottom: 0 !important; /* container đã dùng flex gap-3, tránh khoảng cách gấp đôi */
    background-color: transparent !important;
}

.cv-template-creative .cv-simple-timeline-card.cv-live-exp-item::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--cv-theme-accent);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px var(--cv-theme-border);
}

/* Khối Giải thưởng (.cv-simple-timeline-card.cv-live-award-item) -> component thật (creative.blade.php)
   KHÔNG vẽ timeline cho Giải thưởng, ghi đè phẳng để Form Mode Live Preview khớp đúng bản render cuối. */
.cv-template-creative .cv-simple-timeline-card.cv-live-award-item {
    position: static;
    border-left: 0 !important;
    padding-left: 0 !important;
    margin-bottom: 0 !important; /* container đã dùng flex gap-2 */
    background-color: transparent !important;
}

.cv-template-creative .cv-simple-timeline-card.cv-live-award-item::before {
    content: none;
}

/* 4.3. Khối Học vấn do JS dựng (.cv-simple-education-header/-body) -> danh sách phẳng, không hộp */
.cv-template-creative #livePreviewEducationContainer > .cv-live-edu-item,
.cv-template-creative #livePreviewReferenceContainer > .cv-live-ref-item {
    margin-bottom: 0 !important; /* JS gắn mb-3/mb-2, container đã dùng flex gap-2 */
}

.cv-template-creative .cv-simple-education-header {
    background-color: transparent !important;
    color: var(--cv-theme-text-dark) !important;
    font-weight: 700;
    font-size: 0.78rem;
    border-radius: 0 !important;
    padding: 0 !important;
}

.cv-template-creative .cv-simple-education-header .cv-live-edu-school {
    color: var(--cv-theme-text-dark) !important;
    font-weight: 700;
}

.cv-template-creative .cv-simple-education-header .cv-live-edu-time {
    color: #6b7280 !important;
    font-size: 0.68rem !important;
}

.cv-template-creative .cv-simple-education-body {
    background-color: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin-left: 0;
    font-size: 0.68rem !important;
}

.cv-template-creative .cv-simple-education-body .cv-live-edu-major {
    color: var(--cv-theme-primary) !important;
    font-weight: 600;
}

/* 4.4. Khối Kỹ năng do JS dựng (hộp "col-6 bg-light border" + sao FontAwesome)
   -> bỏ hộp/sao, ép full-width bullet phẳng khớp component thật. */
.cv-template-creative .cv-live-skill-item.col-6 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
}

.cv-template-creative .cv-live-skill-item .bg-light {
    background-color: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 2px 0 2px 14px !important;
    display: block !important;
    position: relative;
}

.cv-template-creative .cv-live-skill-item .bg-light::before {
    content: "";
    position: absolute;
    left: 0;
    top: 9px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--cv-theme-accent);
}

.cv-template-creative .cv-live-skill-stars {
    display: none !important;
}

.cv-template-creative .cv-live-skill-name {
    color: var(--cv-theme-text-dark, #1f1f1f) !important;
    font-size: 0.72rem !important;
}

/* 4.5. Tag pill Nơi làm việc/Ngành nghề/Lĩnh vực từ syncVSelectTags() */
.cv-template-creative .cv-simple-tag-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--cv-theme-border);
    background-color: var(--cv-theme-primary-subtle, #faf3ef);
    color: var(--cv-theme-primary);
    font-size: 0.72rem;
    font-weight: 500;
}

/* 5. @MEDIA PRINT A4 CHUẨN: KHÔNG CẮT KHỐI, CHỐNG TRÀN LỀ, GIỮ MÀU SẮC */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    /* Ẩn toolbar, topbar, buttons khi in */
    .cv-show-topbar,
    .cv-public-topbar,
    .btn,
    .cv-preview-control,
    .cv-preview-actions,
    .no-print,
    header,
    footer,
    nav {
        display: none !important;
    }

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

    .cv-a4-sheet {
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        width: 100% !important;
    }

    .cv-template-creative {
        width: 100% !important;
        background-color: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .cv-template-creative .cv-creative-card {
        background-color: var(--cv-theme-card-bg, #ebe5e0) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Ngăn ngắt trang xấu: break-inside: avoid ở CẤP CARD (không phải cấp hàng) */
    .cv-template-creative .cv-creative-card,
    .cv-template-creative .cv-creative-timeline-item,
    .cv-template-creative .cv-creative-contact-item,
    .cv-template-creative .cv-creative-skill-item,
    .cv-live-exp-item,
    .cv-live-edu-item,
    .cv-live-skill-item,
    .cv-live-award-item,
    .cv-live-ref-item,
    .cv-simple-timeline-card {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }
}
