/* ==========================================================================
   CV BUILDER - TEMPLATE PRESTIGE (UY TÍN)
   Á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: Sidebar tối toàn chiều cao (Col-4) + Banner sage xuyên ngang 2 cột gần
   đỉnh trang (Họ tên/Chức danh trắng trái + Avatar tròn viền trắng tràn mép phải)
   + Main nền xám rất nhạt (Col-8) với heading in hoa kèm đường kẻ kéo dài.
   ========================================================================== */

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

/* 1.1. Theme Sage Slate (Đá phiến + Xanh xô thơm - Mặc định) */
.cv-template-prestige,
.cv-template-prestige[data-theme="sage_slate"],
[data-theme="sage_slate"] .cv-template-prestige,
[data-theme="sage_slate"]#cvPrestigeComponent,
#cvPrestigeComponent[data-theme="sage_slate"],
[data-theme="sage_slate"] {
    --cv-primary: #2c3a47;
    --cv-primary-subtle: #e6ece5;
    --cv-primary-dark: #1e2833;
    --cv-primary-rgb: 44, 58, 71;
    --cv-sidebar-bg: #2c3a47;
    --cv-accent: #c7d6c4;
    --cv-border: #b8c4b6;
    --cv-text-dark: #1f2937;
    --cv-mock-border: #b8c4b6;

    --cv-theme-primary: #2c3a47;
    --cv-theme-primary-subtle: #e6ece5;
    --cv-theme-primary-dark: #1e2833;
    --cv-theme-sidebar-bg: #2c3a47;
    --cv-theme-accent: #c7d6c4;
    --cv-theme-border: #b8c4b6;
    --cv-theme-text-dark: #1f2937;

    --cv-prestige-banner-bg: #7d977a;
    --cv-prestige-main-bg: #f1f1f1;
}

/* 1.2. Theme Taupe Ink (Taupe nâu xám + Mực đen) */
.cv-template-prestige[data-theme="taupe_ink"],
[data-theme="taupe_ink"] .cv-template-prestige,
[data-theme="taupe_ink"]#cvPrestigeComponent,
#cvPrestigeComponent[data-theme="taupe_ink"],
[data-theme="taupe_ink"] {
    --cv-primary: #2e2a3a;
    --cv-primary-subtle: #efe9e1;
    --cv-primary-dark: #1d1a26;
    --cv-primary-rgb: 46, 42, 58;
    --cv-sidebar-bg: #2e2a3a;
    --cv-accent: #e2d6c6;
    --cv-border: #cfc3b3;
    --cv-text-dark: #1f2937;
    --cv-mock-border: #cfc3b3;

    --cv-theme-primary: #2e2a3a;
    --cv-theme-primary-subtle: #efe9e1;
    --cv-theme-primary-dark: #1d1a26;
    --cv-theme-sidebar-bg: #2e2a3a;
    --cv-theme-accent: #e2d6c6;
    --cv-theme-border: #cfc3b3;
    --cv-theme-text-dark: #1f2937;

    --cv-prestige-banner-bg: #9c8a74;
    --cv-prestige-main-bg: #f4f2ef;
}

/* 1.3. Theme Mist Navy (Hải quân sương mù) */
.cv-template-prestige[data-theme="mist_navy"],
[data-theme="mist_navy"] .cv-template-prestige,
[data-theme="mist_navy"]#cvPrestigeComponent,
#cvPrestigeComponent[data-theme="mist_navy"],
[data-theme="mist_navy"] {
    --cv-primary: #1e2f4d;
    --cv-primary-subtle: #e3eaf1;
    --cv-primary-dark: #13203a;
    --cv-primary-rgb: 30, 47, 77;
    --cv-sidebar-bg: #1e2f4d;
    --cv-accent: #c3d3e2;
    --cv-border: #b6c6d6;
    --cv-text-dark: #1f2937;
    --cv-mock-border: #b6c6d6;

    --cv-theme-primary: #1e2f4d;
    --cv-theme-primary-subtle: #e3eaf1;
    --cv-theme-primary-dark: #13203a;
    --cv-theme-sidebar-bg: #1e2f4d;
    --cv-theme-accent: #c3d3e2;
    --cv-theme-border: #b6c6d6;
    --cv-theme-text-dark: #1f2937;

    --cv-prestige-banner-bg: #7b95ad;
    --cv-prestige-main-bg: #f0f3f7;
}

/* 2. COLOR SWATCHES CHO PALETTE BUTTONS */
.cv-swatch-sage_slate {
    background-color: #2c3a47;
}

.cv-swatch-taupe_ink {
    background-color: #2e2a3a;
}

.cv-swatch-mist_navy {
    background-color: #1e2f4d;
}

/* 3. CLASS ĐỊNH HÌNH CẤU TRÚC TEMPLATE PRESTIGE CHUẨN GỐC */
.cv-template-prestige {
    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, #1f2937);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* 3.1. Banner sage xuyên ngang 2 cột, cách đỉnh trang ~32px */
.cv-prestige-banner {
    position: absolute;
    top: 32px;
    left: 0;
    right: 0;
    height: 100px;
    background-color: var(--cv-prestige-banner-bg);
    padding: 0 28px;
    z-index: 2;
    transition: background-color 0.15s ease-in-out;
}

.cv-prestige-banner-info {
    color: #ffffff;
    min-width: 0;
    overflow: hidden;
}

.cv-prestige-fullname {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chữ trắng trên banner_bg chỉ đạt ~3.1-3.3:1 -> Chức danh BẮT BUỘC là "Large Text" theo WCAG AA
   (>= 18.66px đậm): 1.2rem (19.2px) + font-weight 700 + trắng đặc (không alpha) để đạt >= 3:1. */
.cv-prestige-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Placeholder do JS Form Mode chèn (<span class="opacity-50 text-secondary">) khi Họ tên/Chức danh
   trống -> .text-secondary xám chìm trên banner, ép về trắng (opacity-50 vẫn giữ sắc thái placeholder) */
.cv-template-prestige .cv-prestige-banner .text-secondary {
    color: #ffffff !important;
}

/* Avatar lớn hơn chiều cao banner -> tràn xuống dưới mép banner, viền trắng dày, z-index nổi trên Main */
.cv-prestige-avatar-wrap {
    position: relative;
    width: 112px;
    height: 112px;
    transform: translateY(32px);
    z-index: 3;
}

.cv-prestige-avatar {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.cv-prestige-avatar-placeholder {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    border: 4px solid #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 2.2rem;
}

/* 3.2. Sidebar tối toàn chiều cao, padding-top đủ chừa chỗ cho banner + avatar tràn mép */
.cv-prestige-sidebar {
    background-color: var(--cv-theme-sidebar-bg);
    color: #ffffff;
    padding-top: 160px;
    padding-bottom: 24px;
    transition: background-color 0.15s ease-in-out;
}

.cv-prestige-sidebar-heading {
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.cv-prestige-sidebar-heading::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: var(--cv-theme-accent);
    opacity: 0.45;
}

.cv-prestige-contact-block {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--cv-theme-border);
}

.cv-prestige-contact-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.92);
    word-break: break-word;
}

.cv-prestige-contact-item i {
    color: var(--cv-theme-accent);
    margin-top: 3px;
    flex-shrink: 0;
    font-size: 0.82rem;
}

.cv-prestige-skill-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
}

.cv-prestige-skill-bullet {
    font-size: 0.4rem;
    color: var(--cv-theme-accent);
    flex-shrink: 0;
}

/* Màu chữ phụ/nhấn trên nền sidebar tối */
.cv-prestige-text-faded {
    color: rgba(255, 255, 255, 0.68);
}

.cv-prestige-text-accent {
    color: var(--cv-theme-accent);
}

/* Khối Tham khảo: ẩn khi rỗng (spec.md Mục 5) bằng CSS thay vì d-none phía server */
.cv-template-prestige #livePreviewReferenceSection:has(.cv-live-ref-empty) {
    display: none;
}

/* Direct Mode: khối Học vấn/Tham khảo trên Sidebar tối (viền trái accent sáng, không dùng primary) */
.cv-prestige-direct-sidebar-item {
    border-left: 2px solid var(--cv-theme-accent);
    padding-left: 10px;
}

.cv-prestige-direct-skill-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* 3.3. Main nền xám rất nhạt, padding-top đủ chừa chỗ cho banner */
.cv-prestige-main {
    background-color: var(--cv-prestige-main-bg);
    padding-top: 160px;
    padding-bottom: 24px;
    min-height: 100%;
}

/* Heading Main: in hoa đậm màu primary + đường kẻ kéo dài hết phần còn lại của hàng */
.cv-prestige-section-heading {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--cv-theme-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    transition: color 0.15s ease-in-out;
}

.cv-prestige-section-heading::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: var(--cv-theme-border);
}

.cv-prestige-timeline-card {
    margin-bottom: 4px;
}

.cv-prestige-text-primary {
    color: var(--cv-theme-primary);
}

.cv-prestige-text-muted {
    color: #6b7280;
}

.cv-prestige-tag-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 9999px;
    border: 1px solid var(--cv-theme-border);
    background-color: var(--cv-theme-primary-subtle, #e6ece5);
    color: var(--cv-theme-primary);
    font-size: 0.75rem;
    font-weight: 500;
}

/* 3.4. Direct Mode (Soạn thảo trực tiếp): chữ/viền sáng trên nền sidebar tối + banner sage */
.cv-prestige-sidebar .form-control-plaintext,
.cv-prestige-banner-info .form-control-plaintext {
    color: #ffffff !important;
}

.cv-prestige-sidebar .form-control-plaintext::placeholder,
.cv-prestige-banner-info .form-control-plaintext::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

.cv-prestige-banner-info .hover-border:hover,
.cv-prestige-banner-info .hover-border:focus {
    border-color: rgba(255, 255, 255, 0.6) !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
}

.cv-prestige-sidebar select.form-control-plaintext option {
    color: #1f2937;
}

.cv-prestige-sidebar .hover-border:hover,
.cv-prestige-sidebar .hover-border:focus {
    border-color: rgba(255, 255, 255, 0.5) !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Viền trái mặc định của thẻ (--cv-theme-primary trùng gần hệt sidebar_bg) -> dùng accent sáng để không chìm mất */
.cv-prestige-sidebar .cv-direct-edu-card,
.cv-prestige-sidebar .cv-direct-ref-card {
    border-left-color: var(--cv-theme-accent) !important;
}

.cv-prestige-sidebar .cv-direct-add-btn {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.4);
}

.cv-prestige-sidebar .cv-direct-add-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--cv-theme-accent);
    color: var(--cv-theme-accent);
}

/* Direct Mode: nút "Thêm..." ở Main nền xám nhạt -> dùng primary */
.cv-prestige-main .cv-direct-add-btn {
    color: var(--cv-theme-primary);
}

.cv-prestige-main .cv-direct-add-btn:hover {
    background-color: var(--cv-primary-subtle, #e6ece5);
    border-color: var(--cv-theme-primary);
    color: var(--cv-primary-dark);
}

/* 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 sidebar tối + bullet phẳng + timeline phẳng của `prestige`. */

/* 4.1. Alias .cv-simple-title/.cv-simple-timeline-card -> dùng ở Main nền sáng (Kinh nghiệm, Giải thưởng) */
.cv-template-prestige .cv-simple-title {
    color: var(--cv-theme-primary) !important;
}

.cv-template-prestige .cv-simple-timeline-card {
    border-left: 0 !important;
    padding-left: 0 !important;
    margin-bottom: 4px;
}

/* 4.2. Trung hòa màu chữ tối Bootstrap (.text-dark/.text-muted/.text-secondary) do JS gán cứng
   bên trong Sidebar tối -> đổi thành chữ sáng để đọc được trên nền tối (Học vấn/Kỹ năng/Tham khảo) */
.cv-template-prestige .cv-prestige-sidebar .text-dark,
.cv-template-prestige .cv-prestige-sidebar .text-secondary {
    color: rgba(255, 255, 255, 0.92) !important;
}

.cv-template-prestige .cv-prestige-sidebar .text-muted {
    color: rgba(255, 255, 255, 0.68) !important;
}

/* Chức vụ người tham khảo do JS dựng (.cv-simple-title.cv-live-ref-pos) nằm trong Sidebar tối:
   rule 4.1 ép --cv-theme-primary (= sidebar_bg) làm chữ chìm mất -> dùng accent sáng, khớp bản server */
.cv-template-prestige .cv-prestige-sidebar .cv-simple-title {
    color: var(--cv-theme-accent) !important;
}

/* 4.3. Khối Học vấn (JS dựng .cv-simple-education-header/-body dạng hộp badge của `simple`)
   trong Sidebar tối -> bỏ hộp nền sáng, chuyển thành khối phẳng chữ sáng */
.cv-template-prestige .cv-prestige-sidebar .cv-simple-education-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    background-color: transparent !important;
    color: #ffffff !important;
    font-weight: 700;
    font-size: 0.75rem;
    border-radius: 0 !important;
    padding: 0 !important;
    margin-bottom: 2px;
}

.cv-template-prestige .cv-prestige-sidebar .cv-simple-education-body {
    background-color: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    font-size: 0.72rem;
}

/* 4.4. Khối Kỹ năng (JS dựng hộp "bg-light border rounded" + sao .cv-simple-star/.cv-simple-star-empty)
   trong Sidebar tối -> chuyển thành bullet phẳng, KHÔNG sao, full-width */
.cv-template-prestige .cv-prestige-sidebar .cv-live-skill-item.col-6 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
}

.cv-template-prestige .cv-prestige-sidebar .cv-live-skill-item .bg-light {
    background-color: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 8px;
}

.cv-template-prestige .cv-prestige-sidebar .cv-live-skill-item .bg-light .cv-live-skill-name {
    color: #ffffff !important;
    font-weight: 700;
}

.cv-template-prestige .cv-prestige-sidebar .cv-live-skill-item .bg-light::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--cv-theme-accent);
    flex-shrink: 0;
}

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

/* Pill tag Nơi làm việc/Ngành nghề/Lĩnh vực: syncVSelectTags() dựng .cv-simple-tag-pill */
.cv-template-prestige .cv-simple-tag-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 9999px;
    border: 1px solid var(--cv-theme-border);
    background-color: var(--cv-theme-primary-subtle, #e6ece5);
    color: var(--cv-theme-primary);
    font-size: 0.75rem;
    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, AVATAR KHÔNG BỊ CẮT MÉP */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    .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;
    }

    /* Khung A4 vốn có overflow: hidden -> avatar tràn mép banner vẫn nằm trọn trong biên của
       .cv-template-prestige (không vượt khỏi .cv-a4-sheet) nên không bị cắt mất khi in. */
    .cv-a4-sheet {
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        width: 100% !important;
    }

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

    .cv-template-prestige .cv-prestige-banner {
        background-color: var(--cv-prestige-banner-bg) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .cv-template-prestige .cv-prestige-sidebar {
        background-color: var(--cv-theme-sidebar-bg) !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .cv-template-prestige .cv-prestige-main {
        background-color: var(--cv-prestige-main-bg) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Ngăn ngắt trang xấu giữa chừng các khối thông tin */
    .cv-template-prestige .break-inside-avoid,
    .cv-prestige-contact-item,
    .cv-prestige-skill-item,
    .cv-prestige-timeline-card,
    .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;
    }
}
