/* ==========================================================================
   CV BUILDER - TEMPLATE TIMELINE (DÒNG THỜI GIAN)
   Á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 banner gradient full-width (Avatar + Họ tên + Liên hệ) + Thân 1 cột duy nhất
   với Kinh nghiệm/Học vấn trình bày kiểu Timeline (chấm tròn + đường nối dọc)
   ========================================================================== */

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

/* 1.1. Theme Azure (Xanh dương năng động - Mặc định) */
.cv-template-timeline,
.cv-template-timeline[data-theme="azure"],
[data-theme="azure"] .cv-template-timeline,
[data-theme="azure"]#cvTimelineComponent,
#cvTimelineComponent[data-theme="azure"],
[data-theme="azure"] {
    --cv-primary: #2563eb;
    --cv-primary-subtle: #eff6ff;
    --cv-primary-dark: #1e3a8a;
    --cv-primary-rgb: 37, 99, 235;
    --cv-sidebar-bg: #2563eb;
    --cv-accent: #93c5fd;
    --cv-border: #bfdbfe;
    --cv-text-dark: #1e293b;
    --cv-mock-border: #bfdbfe;

    --cv-theme-primary: #2563eb;
    --cv-theme-sidebar-bg: #2563eb;
    --cv-theme-accent: #93c5fd;
    --cv-theme-border: #bfdbfe;
    --cv-theme-text-dark: #1e293b;
}

/* 1.2. Theme Emerald (Xanh ngọc lục bảo) */
.cv-template-timeline[data-theme="emerald"],
[data-theme="emerald"] .cv-template-timeline,
[data-theme="emerald"]#cvTimelineComponent,
#cvTimelineComponent[data-theme="emerald"],
[data-theme="emerald"] {
    --cv-primary: #059669;
    --cv-primary-subtle: #ecfdf5;
    --cv-primary-dark: #065f46;
    --cv-primary-rgb: 5, 150, 105;
    --cv-sidebar-bg: #059669;
    --cv-accent: #6ee7b7;
    --cv-border: #a7f3d0;
    --cv-text-dark: #1e293b;
    --cv-mock-border: #a7f3d0;

    --cv-theme-primary: #059669;
    --cv-theme-sidebar-bg: #059669;
    --cv-theme-accent: #6ee7b7;
    --cv-theme-border: #a7f3d0;
    --cv-theme-text-dark: #1e293b;
}

/* 1.3. Theme Violet (Tím violet) */
.cv-template-timeline[data-theme="violet"],
[data-theme="violet"] .cv-template-timeline,
[data-theme="violet"]#cvTimelineComponent,
#cvTimelineComponent[data-theme="violet"],
[data-theme="violet"] {
    --cv-primary: #7c3aed;
    --cv-primary-subtle: #f5f3ff;
    --cv-primary-dark: #5b21b6;
    --cv-primary-rgb: 124, 58, 237;
    --cv-sidebar-bg: #7c3aed;
    --cv-accent: #c4b5fd;
    --cv-border: #ddd6fe;
    --cv-text-dark: #1e293b;
    --cv-mock-border: #ddd6fe;

    --cv-theme-primary: #7c3aed;
    --cv-theme-sidebar-bg: #7c3aed;
    --cv-theme-accent: #c4b5fd;
    --cv-theme-border: #ddd6fe;
    --cv-theme-text-dark: #1e293b;
}

/* 2. Color Swatches cho Palette Buttons */
.cv-swatch-azure {
    background-color: #2563eb;
}

.cv-swatch-emerald {
    background-color: #059669;
}

.cv-swatch-violet {
    background-color: #7c3aed;
}

/* 3. Class định hình cấu trúc Template Timeline chuẩn gốc */
.cv-template-timeline {
    background-color: #ffffff;
    width: 100%;
    min-height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #334155;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* 3.1. Header Banner gradient full-width */
.cv-timeline-banner {
    background-image: linear-gradient(135deg, var(--cv-theme-primary), var(--cv-primary-dark));
    color: #ffffff;
    transition: background-image 0.15s ease-in-out;
}

.cv-timeline-avatar-wrap {
    width: 96px;
    height: 96px;
}

.cv-timeline-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

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

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

.cv-timeline-role {
    color: var(--cv-theme-accent);
}

.cv-timeline-contact-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.9);
    word-break: break-word;
}

.cv-timeline-contact-item i {
    color: var(--cv-theme-accent);
    flex-shrink: 0;
}

.cv-timeline-basic-row {
    color: rgba(255, 255, 255, 0.75);
}

.cv-timeline-text-faded {
    color: rgba(255, 255, 255, 0.65);
}

/* 3.2. Thân CV 1 cột (nền trắng) */
.cv-timeline-body {
    background-color: #ffffff;
}

.cv-timeline-section-heading {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--cv-theme-primary);
    border-bottom: 2px solid var(--cv-theme-border);
    padding-bottom: 6px;
    margin-bottom: 14px;
    transition: color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

/* Dùng cho chữ nhấn trên nền trắng của Thân CV (công ty, trường học, vị trí tham khảo) */
.cv-timeline-title {
    color: var(--cv-theme-primary);
    transition: color 0.15s ease-in-out;
}

/* 3.3. Timeline chấm tròn + đường nối dọc (Kinh nghiệm & Học vấn) */
.cv-timeline-track {
    position: relative;
}

.cv-timeline-item {
    position: relative;
    padding-left: 20px;
    padding-bottom: 16px;
    margin-bottom: 4px;
    border-left: 2px solid var(--cv-theme-border);
}

.cv-timeline-item:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.cv-timeline-item::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--cv-theme-primary);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px var(--cv-theme-border);
}

.cv-timeline-item:first-child {
    padding-left: 20px;
}

.cv-timeline-education-header {
    font-weight: 700;
    color: var(--cv-theme-text-dark);
}

.cv-timeline-education-body {
    margin-top: 2px;
}

.cv-timeline-skill-pill {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 9999px;
    border: 1px solid var(--cv-theme-border);
    background-color: var(--cv-primary-subtle, #eff6ff);
    color: var(--cv-theme-primary);
    font-size: 0.78rem;
    font-weight: 500;
}

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

/* 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-timeline #livePreviewReferenceSection:has(.cv-live-ref-empty) {
    display: none;
}

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

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

.cv-timeline-banner select.form-control-plaintext option {
    color: #1e293b;
}

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

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

.cv-timeline-banner .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..." nằm ở Thân CV nền TRẮNG -> dùng primary (không dùng accent sáng của cv-builder.css,
   và hover không dùng nền --cv-theme-sidebar-bg vì trùng màu chữ primary làm chữ biến mất) */
.cv-timeline-body .cv-direct-add-btn {
    color: var(--cv-theme-primary);
}

.cv-timeline-body .cv-direct-add-btn:hover {
    background-color: var(--cv-primary-subtle, #eff6ff);
    border-color: var(--cv-theme-primary);
    color: var(--cv-primary-dark);
}

/* Direct Mode: mẫu clone Học vấn dùng chung (create_direct.blade.php #resumeEducation) mang .cv-simple-education-header
   + input .text-white / nút .text-white-50 (thiết kế cho header nền primary của `simple`). Ở `timeline` header trong suốt
   trên nền trắng -> ép chữ tối để không bị "vô hình" khi người dùng bấm "Thêm trình độ học vấn". */
.cv-template-timeline .cv-simple-education-header .form-control-plaintext {
    color: var(--cv-theme-text-dark) !important;
}

.cv-template-timeline .cv-simple-education-header .cv-direct-remove-btn {
    color: #ef4444 !important;
}

/* Direct Mode: ô nhập Kỹ năng dạng pill - kế thừa màu primary từ .cv-timeline-skill-pill cha */
.cv-timeline-skill-pill.cv-direct-skill-row {
    border-bottom: 0 !important;
}

.cv-timeline-skill-input {
    color: inherit !important;
    width: auto;
    min-width: 60px;
}

/* 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 .text-dark/.text-muted/.text-secondary)
   cho MỌI template Form Mode. Khối dưới đây ghi đè để khớp giao diện timeline (chấm tròn + đường nối)
   của `timeline` (theo đúng precedent đã áp dụng ở default.css/it.css/fresher.css/unique.css/sales.css). */

/* 4.1. Alias .cv-simple-timeline-card/.cv-simple-title -> tương đương .cv-timeline-item/.cv-timeline-title
   (áp dụng cho Kinh nghiệm & Giải thưởng & Tham khảo ở Thân CV nền trắng) */
.cv-template-timeline .cv-simple-timeline-card {
    position: relative;
    padding-left: 20px;
    padding-bottom: 16px;
    margin-bottom: 4px !important;
    border-left: 2px solid var(--cv-theme-border) !important;
}

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

.cv-template-timeline .cv-simple-title {
    color: var(--cv-theme-primary) !important;
}

/* Mốc cuối của timeline: ẩn đường nối dọc (đồng bộ .cv-timeline-item:last-child cho markup JS + rule ID Học vấn bên dưới) */
.cv-template-timeline #livePreviewExperienceContainer .cv-simple-timeline-card:last-child,
.cv-template-timeline #livePreviewEducationContainer .cv-live-edu-item:last-child {
    border-left-color: transparent !important;
    padding-bottom: 0;
}

/* Giải thưởng là "danh sách phẳng, năm căn phải" (plan.md Mục 4.1) - KHÔNG phải timeline:
   gỡ chấm tròn/đường nối mà alias .cv-simple-timeline-card ở trên áp lên thẻ giải thưởng do JS dựng */
.cv-template-timeline #livePreviewAwardContainer .cv-simple-timeline-card {
    border-left: 0 !important;
    padding-left: 0;
    padding-bottom: 0;
    margin-bottom: 0 !important;
}

.cv-template-timeline #livePreviewAwardContainer .cv-simple-timeline-card::before {
    content: none;
}

/* Pill tag Nơi làm việc/Ngành nghề/Lĩnh vực: syncVSelectTags() trong create_form.blade.php dựng .cv-simple-tag-pill
   (chỉ định nghĩa trong simple.css, không được nạp ở `timeline`) -> alias về .cv-timeline-tag-pill */
.cv-template-timeline .cv-simple-tag-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 9999px;
    border: 1px solid var(--cv-theme-border);
    background-color: var(--cv-primary-subtle, #eff6ff);
    color: var(--cv-theme-primary);
    font-size: 0.75rem;
    font-weight: 500;
}

/* 4.2. Khối Học vấn (JS dựng .cv-simple-education-header/-body dạng hộp badge của `simple`)
   -> chuyển thành khối phẳng chữ tối đồng bộ .cv-timeline-education-header/-body */
.cv-template-timeline .cv-simple-education-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: transparent !important;
    color: var(--cv-theme-text-dark) !important;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: 0 !important;
    padding: 0 !important;
    margin-bottom: 2px;
}

.cv-template-timeline .cv-simple-education-body {
    background-color: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

.cv-template-timeline #livePreviewEducationContainer .cv-live-edu-item {
    position: relative;
    padding-left: 20px;
    padding-bottom: 16px;
    margin-bottom: 4px !important;
    border-left: 2px solid var(--cv-theme-border) !important;
}

.cv-template-timeline #livePreviewEducationContainer .cv-live-edu-item::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--cv-theme-primary);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px var(--cv-theme-border);
}

/* 4.3. Khối Kỹ năng (JS dựng hộp "col-6 bg-light border rounded" + sao .cv-simple-star/.cv-simple-star-empty)
   -> chuyển thành pill badge đồng bộ .cv-timeline-skill-pill, ẩn sao đánh giá
   (thiết kế `timeline` không hiển thị thang điểm sao) */
.cv-template-timeline .cv-live-skill-item.col-6 {
    width: auto !important;
    max-width: 100% !important;
    flex: 0 0 auto !important;
}

.cv-template-timeline .cv-live-skill-item .bg-light {
    background-color: var(--cv-primary-subtle, #eff6ff) !important;
    border: 1px solid var(--cv-theme-border) !important;
    border-radius: 9999px !important;
    padding: 4px 14px !important;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
}

.cv-template-timeline .cv-live-skill-item .cv-live-skill-name {
    color: var(--cv-theme-primary) !important;
}

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

/* 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-timeline {
        width: 100% !important;
        background-color: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .cv-template-timeline .cv-timeline-banner {
        background-image: linear-gradient(135deg, var(--cv-theme-primary), var(--cv-primary-dark)) !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .cv-template-timeline .cv-timeline-body {
        background-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-timeline .break-inside-avoid,
    .cv-timeline-contact-item,
    .cv-timeline-item,
    .cv-timeline-skill-pill,
    .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;
    }
}
