/* ==========================================================================
   CV BUILDER - TEMPLATE ANALYTIC (PHÂN TÍCH)
   Á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: Header full-width căn phải (họ tên/chức danh trắng) + Main ivory bên
   TRÁI (col-8, Mục tiêu/Học vấn/Kinh nghiệm/Mong muốn/Công việc mong muốn/Tham khảo)
   + Sidebar tối bên PHẢI (col-4, Avatar/Liên hệ & Thông tin cơ bản/Kỹ năng thanh
   tiến trình/Danh hiệu & Giải thưởng)
   ========================================================================== */

/* 1. Theme Variables cho các gam màu của template Analytic */

/* 1.1. Theme Amber Charcoal (Hổ phách & Than chì - Mặc định) */
.cv-template-analytic,
.cv-template-analytic[data-theme="amber_charcoal"],
[data-theme="amber_charcoal"] .cv-template-analytic,
[data-theme="amber_charcoal"]#cvAnalyticComponent,
#cvAnalyticComponent[data-theme="amber_charcoal"],
[data-theme="amber_charcoal"] {
    --cv-primary: #c86b05;
    --cv-primary-subtle: #fff8e1;
    --cv-primary-dark: #9a5204;
    --cv-primary-rgb: 200, 107, 5;
    --cv-accent: #f59e0b;
    --cv-border: #f2c66d;
    --cv-text-dark: #1f2937;
    --cv-mock-border: #f2c66d;

    --cv-theme-primary: #c86b05;
    --cv-theme-primary-subtle: #fff8e1;
    --cv-theme-primary-dark: #9a5204;
    --cv-theme-accent: #f59e0b;
    --cv-theme-border: #f2c66d;
    --cv-theme-text-dark: #1f2937;

    --cv-analytic-header-bg: #7a7978;
    --cv-analytic-main-bg: #fdf6dc;
    --cv-analytic-sidebar-bg: #363b3e;
    --cv-analytic-skill-track: #c9c9c9;
}

/* 1.2. Theme Teal Graphite (Xanh ngọc & Than xám) */
.cv-template-analytic[data-theme="teal_graphite"],
[data-theme="teal_graphite"] .cv-template-analytic,
[data-theme="teal_graphite"]#cvAnalyticComponent,
#cvAnalyticComponent[data-theme="teal_graphite"],
[data-theme="teal_graphite"] {
    --cv-primary: #0f766e;
    --cv-primary-subtle: #effaf8;
    --cv-primary-dark: #115e59;
    --cv-primary-rgb: 15, 118, 110;
    --cv-accent: #2dd4bf;
    --cv-border: #99e2d6;
    --cv-text-dark: #1f2937;
    --cv-mock-border: #99e2d6;

    --cv-theme-primary: #0f766e;
    --cv-theme-primary-subtle: #effaf8;
    --cv-theme-primary-dark: #115e59;
    --cv-theme-accent: #2dd4bf;
    --cv-theme-border: #99e2d6;
    --cv-theme-text-dark: #1f2937;

    --cv-analytic-header-bg: #6b7a78;
    --cv-analytic-main-bg: #f2faf8;
    --cv-analytic-sidebar-bg: #2f3a3a;
    --cv-analytic-skill-track: #c9d2d1;
}

/* 1.3. Theme Coral Slate (San hô & Đá phiến) */
.cv-template-analytic[data-theme="coral_slate"],
[data-theme="coral_slate"] .cv-template-analytic,
[data-theme="coral_slate"]#cvAnalyticComponent,
#cvAnalyticComponent[data-theme="coral_slate"],
[data-theme="coral_slate"] {
    --cv-primary: #c2410c;
    --cv-primary-subtle: #fff4ef;
    --cv-primary-dark: #9a3412;
    --cv-primary-rgb: 194, 65, 12;
    --cv-accent: #fb7a59;
    --cv-border: #f6b8a2;
    --cv-text-dark: #1f2937;
    --cv-mock-border: #f6b8a2;

    --cv-theme-primary: #c2410c;
    --cv-theme-primary-subtle: #fff4ef;
    --cv-theme-primary-dark: #9a3412;
    --cv-theme-accent: #fb7a59;
    --cv-theme-border: #f6b8a2;
    --cv-theme-text-dark: #1f2937;

    --cv-analytic-header-bg: #78716c;
    --cv-analytic-main-bg: #fdf3ee;
    --cv-analytic-sidebar-bg: #3a3533;
    --cv-analytic-skill-track: #cfc8c5;
}

/* 2. Color Swatches cho Palette Buttons */
.cv-swatch-amber_charcoal {
    background-color: #c86b05;
}

.cv-swatch-teal_graphite {
    background-color: #0f766e;
}

.cv-swatch-coral_slate {
    background-color: #c2410c;
}

/* 3. Class định hình cấu trúc Template Analytic chuẩn */
.cv-template-analytic {
    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.0. Phủ kín 2 cột Main ivory / Sidebar tối tới đáy khung giấy (Mục 18.1 plan.md - không hở trắng ở đáy).
   - Form Mode / Preview: .cv-a4-paper (display:flex, min-height 934px) kéo giãn component theo chiều cao.
   - Show / Public Show / Direct Mode: .cv-a4-sheet (min-height 1200px) mang luôn class .cv-template-analytic
     -> chuyển thành flex cột để component (Show) hoặc .row (Direct) lấp đầy phần còn lại.
   - .row g-0 align-items-stretch bên trong kéo 2 cột cao bằng nhau; nền vẫn đặt trên cột. */
.cv-a4-sheet.cv-template-analytic,
#cvAnalyticComponent.cv-template-analytic {
    display: flex;
    flex-direction: column;
}

.cv-a4-sheet.cv-template-analytic > #cvAnalyticComponent,
.cv-a4-sheet.cv-template-analytic > .row,
#cvAnalyticComponent.cv-template-analytic > .row {
    flex: 1 0 auto;
}

/* 3.1. Header full-width căn phải */
.cv-analytic-header {
    background-color: var(--cv-analytic-header-bg);
    transition: background-color 0.15s ease-in-out;
}

.cv-analytic-fullname {
    color: #ffffff;
}

.cv-analytic-role {
    color: #ffffff;
    font-size: 0.95rem;
}

/* Placeholder do JS Form Mode chèn (<span class="opacity-75">) khi Họ tên/Chức danh trống ->
   đã là màu trắng (opacity-75) nên không cần ghi đè thêm. */

/* 3.2. Main ivory (cột trái 8/12) */
.cv-analytic-main {
    background-color: var(--cv-analytic-main-bg);
}

.cv-analytic-section-heading {
    color: var(--cv-theme-primary);
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.15s ease-in-out;
}

.cv-analytic-section-heading::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: var(--cv-theme-primary);
    opacity: 0.35;
}

/* Mục tiêu nghề nghiệp: KHÔNG icon, không đường kẻ (đúng ảnh) */
.cv-analytic-section-heading-plain::after {
    content: none;
}

.cv-analytic-heading-icon {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 50%;
    background-color: var(--cv-theme-primary);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
}

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

.cv-analytic-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, #fff8e1);
    color: var(--cv-theme-primary);
    font-size: 0.75rem;
    font-weight: 500;
}

/* Khối Tham khảo: ẩn khi rỗng cũng đồng bộ qua CSS cho an toàn khi JS dựng lại */
.cv-template-analytic #livePreviewReferenceSection:has(.cv-live-ref-empty) {
    display: none;
}

/* 3.3. Sidebar tối (cột phải 4/12) */
.cv-analytic-sidebar {
    background-color: var(--cv-analytic-sidebar-bg);
    color: #ffffff;
    transition: background-color 0.15s ease-in-out;
}

.cv-analytic-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.cv-analytic-avatar-placeholder {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.85);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 2rem;
    margin: 0 auto;
}

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

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

.cv-analytic-heading-icon-dark {
    color: var(--cv-theme-accent);
    font-size: 0.78rem;
}

.cv-analytic-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-analytic-contact-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 50%;
    background-color: var(--cv-theme-accent);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.cv-analytic-text-faded {
    color: rgba(255, 255, 255, 0.68);
}

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

/* 3.4. Kỹ năng: thanh tiến trình ngang (Mục 18.3) */
.cv-analytic-skill-bar-track {
    width: 100%;
    height: 8px;
    background-color: var(--cv-analytic-skill-track);
    overflow: hidden;
}

.cv-analytic-skill-bar-fill {
    height: 100%;
    background-color: var(--cv-theme-accent);
    transition: background-color 0.15s ease-in-out, width 0.15s ease-in-out;
}

/* Mức độ kỹ năng rời rạc 1-5, tránh inline style width động (Zero Inline Styles Invariant) */
.cv-analytic-skill-level-1 { width: 20%; }
.cv-analytic-skill-level-2 { width: 40%; }
.cv-analytic-skill-level-3 { width: 60%; }
.cv-analytic-skill-level-4 { width: 80%; }
.cv-analytic-skill-level-5 { width: 100%; }

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

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

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

.cv-analytic-sidebar .form-control-plaintext {
    color: #ffffff !important;
}

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

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

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

/* Ghi đè viền trái mặc định của .cv-direct-award-card (--cv-theme-primary chỉ đạt ~2.2:1 trên nền
   sidebar tối ở teal_graphite/coral_slate) bằng màu accent sáng để không bị chìm (tiền lệ sales.css) */
.cv-analytic-sidebar .cv-direct-award-card {
    border-left-color: var(--cv-theme-accent) !important;
}

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

.cv-analytic-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);
}

.cv-analytic-main .cv-direct-add-btn:hover {
    background-color: var(--cv-theme-primary-subtle, #fff8e1);
    border-color: var(--cv-theme-primary);
    color: var(--cv-theme-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 analytic (Main ivory chữ tối + Sidebar tối chữ sáng
   + thanh tiến trình kỹ năng thay cho hộp sao). */

/* 4.1. Alias .cv-simple-title -> màu primary (dùng ở Main ivory: Kinh nghiệm) */
.cv-template-analytic .cv-simple-title {
    color: var(--cv-theme-primary) !important;
}

.cv-template-analytic .cv-simple-timeline-card {
    border-left: 0 !important;
    padding-left: 0 !important;
}

/* 4.2. Khối Học vấn trong Main (JS dựng .cv-simple-education-header/-body dạng hộp badge nền
   primary chữ trắng của `simple`) -> chuyển thành khối phẳng chữ tối trên nền ivory */
.cv-template-analytic .cv-analytic-main .cv-simple-education-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    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;
    margin-bottom: 2px;
}

.cv-template-analytic .cv-analytic-main .cv-simple-education-header .cv-live-edu-time {
    font-weight: 400;
    font-size: 0.7rem;
    color: #6b7280 !important;
}

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

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

/* 4.3. Khối Kinh nghiệm trong Main (JS chèn .cv-simple-timeline-card.cv-live-exp-item): Công ty
   IN HOA đậm trái + thời gian phải, bỏ border-left mặc định (xem 4.1) */
.cv-template-analytic .cv-analytic-main .cv-simple-timeline-card.cv-live-exp-item .cv-live-exp-company {
    text-transform: uppercase;
}

/* 4.4. Khối Giải thưởng trong Sidebar -> chữ sáng, bỏ border-left mặc định.
   Vô hiệu hóa nền sáng global của .cv-live-award-item (cv-builder.css: background #f8fafc +
   border #e2e8f0) khi nằm trên sidebar tối - tránh chữ trắng trên nền trắng (tiền lệ sales.css).
   Áp dụng cho CẢ 2 biến thể: bản server-rendered (templates/analytic.blade.php, chỉ có
   .cv-live-award-item) và bản JS Form Mode (.cv-simple-timeline-card.cv-live-award-item). */
.cv-template-analytic .cv-analytic-sidebar .cv-live-award-item {
    background-color: transparent !important;
    border: 0 !important;
    border-left: 2px solid var(--cv-theme-accent) !important;
    border-radius: 0 !important;
    padding: 0 0 0 10px !important;
}

.cv-template-analytic .cv-analytic-sidebar .cv-simple-timeline-card.cv-live-award-item {
    border-left: 2px solid var(--cv-theme-accent) !important;
    padding-left: 10px !important;
    color: #ffffff;
}

.cv-template-analytic .cv-analytic-sidebar .cv-simple-timeline-card.cv-live-award-item .text-dark {
    color: #ffffff !important;
}

.cv-template-analytic .cv-analytic-sidebar .cv-simple-timeline-card.cv-live-award-item .text-secondary,
.cv-template-analytic .cv-analytic-sidebar .cv-simple-timeline-card.cv-live-award-item .text-muted {
    color: rgba(255, 255, 255, 0.68) !important;
}

/* 4.5. Trung hòa màu chữ tối Bootstrap (.text-dark/.text-secondary/.text-muted) 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 */
.cv-template-analytic .cv-analytic-sidebar .text-dark,
.cv-template-analytic .cv-analytic-sidebar .text-secondary {
    color: rgba(255, 255, 255, 0.92) !important;
}

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

/* 4.6. Khối Kỹ năng trong Sidebar: JS dựng 5 sao FontAwesome (.cv-live-skill-stars > i) do
   `syncSkills()` trong create_form.blade.php — biến dãy 5 sao thành thanh 5 đoạn liền mạch,
   hiển thị tương đương bản server ở cùng bậc N (Mục 18.3 plan.md, scope đúng selector). */
.cv-template-analytic .cv-analytic-sidebar #livePreviewSkillContainer .cv-live-skill-item {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
}

.cv-template-analytic .cv-analytic-sidebar #livePreviewSkillContainer .cv-live-skill-item .d-flex.p-2.rounded.bg-light.border {
    display: block !important;
    background-color: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

.cv-template-analytic .cv-analytic-sidebar #livePreviewSkillContainer .cv-live-skill-name {
    color: #ffffff !important;
    white-space: normal !important;
    text-overflow: unset !important;
    overflow: visible !important;
    display: block;
    margin-bottom: 4px;
}

.cv-template-analytic .cv-analytic-sidebar #livePreviewSkillContainer .cv-live-skill-stars {
    display: flex !important;
    gap: 0 !important;
    width: 100% !important;
    height: 8px !important;
    margin-top: 4px;
    background-color: var(--cv-analytic-skill-track);
}

.cv-template-analytic .cv-analytic-sidebar #livePreviewSkillContainer .cv-live-skill-stars i {
    flex: 1 1 0;
    height: 100%;
    font-size: 0;
}

.cv-template-analytic .cv-analytic-sidebar #livePreviewSkillContainer .cv-live-skill-stars i::before {
    content: none;
}

.cv-template-analytic .cv-analytic-sidebar #livePreviewSkillContainer .cv-live-skill-stars i.fa-solid {
    background-color: var(--cv-theme-accent);
}

.cv-template-analytic .cv-analytic-sidebar #livePreviewSkillContainer .cv-live-skill-stars i.fa-regular {
    background-color: var(--cv-analytic-skill-track);
}

/* 4.7. Pill tag Nơi làm việc/Ngành nghề/Lĩnh vực từ syncVSelectTags() (Main ivory) */
.cv-template-analytic .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, #fff8e1);
    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, 2 CỘT PHỦ KÍN TỚI ĐÁY */
@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;
    }

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

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

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

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

    .cv-template-analytic .cv-analytic-sidebar {
        background-color: var(--cv-analytic-sidebar-bg) !important;
        color: #ffffff !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-analytic .break-inside-avoid,
    .cv-analytic-contact-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;
    }
}
