/* =========================================================
   Dùng chung cho mọi trang tuyển dụng (controller = recruitment).
   Tự nạp qua AppHelper::autoload() ở cấp controller.
   ========================================================= */

/* =========================================================
   Apply buttons + CV application modal (shared by index & detail).
   Moved here from detail.css so the modal also works on /tuyen-dung.
   ========================================================= */

.btn-apply {
    display: block; width: 100%; text-align: center;
    background: #2cae5f; color: #fff; font-size: 15px; font-weight: 700;
    padding: 13px 20px; border-radius: 30px;
    transition: background .2s, transform .2s;
    /* Reset native <button> chrome so the button matches the original anchor look */
    border: none; cursor: pointer; font-family: inherit; -webkit-appearance: none; appearance: none;
}
.btn-apply:hover { background: #229150; color: #fff; text-decoration: none; transform: translateY(-2px); }
/* Nut phu (Huy) di mau trung tinh chu khong phai xanh thuong hieu: dat canh
   .btn-apply thi hai nut cung xanh se tranh nhau, va #2cae5f tren nen trang
   chi dat 3:1 - duoi nguong AA cho chu 14px. */
.btn-apply-outline {
    display: block; width: 100%; text-align: center; margin-top: 10px;
    border: 1.5px solid #C9D6CF; color: #5B6B63; font-size: 14px; font-weight: 600;
    padding: 11px 20px; border-radius: 30px; transition: all .2s;
    background: none;
}
.btn-apply-outline:hover { background: #F2F6F3; color: #0B1F17; border-color: #8A9A92; text-decoration: none; }

/* Body scroll lock while any modal is open */
body.cv-modal-open { overflow: hidden; }

/* Backdrop + flex centering — hidden by default, shown via .is-open */
.cv-modal {
    display: none;
    /* Longhand offsets (not `inset`) so iOS Safari < 14.5 also full-screens it. */
    position: fixed; top: 0; right: 0; bottom: 0; left: 0;
    /* Tren header dinh (z-50) de lop phu mo ca header thay vi header cho len tren. */
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.cv-modal.is-open { display: flex; }

/* Semi-transparent overlay */
.cv-modal__overlay {
    position: fixed; top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0, 0, 0, .52);
    cursor: pointer;
}

/* Panel */
.cv-modal__panel {
    position: relative;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px -20px rgba(15,40,28,.38);
    padding: 36px 32px 28px;
    width: 100%;
    max-width: 680px; /* wider to fit the two-column form */
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* momentum scroll inside the panel on iOS */
    animation: cvPanelIn .22s ease;
}
.cv-modal__panel--sm {
    max-width: 400px; /* confirm dialog stays compact */
}

/* Two-column form grid; long fields span both columns */
.cv-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}
.cv-cell { display: flex; flex-direction: column; }
.cv-cell--full { grid-column: 1 / -1; }
@media (max-width: 560px) {
    .cv-grid { grid-template-columns: 1fr; }
}

@keyframes cvPanelIn {
    from { opacity: 0; transform: translateY(-18px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Close (×) button */
.cv-modal__x {
    position: absolute; top: 14px; right: 18px;
    background: none; border: none; cursor: pointer;
    font-size: 24px; line-height: 1; color: #8A9A92;
    padding: 4px 6px; border-radius: 6px;
    transition: color .15s, background .15s;
}
.cv-modal__x:hover { color: #0B1F17; background: #F2F6F3; }

/* Modal title */
.cv-modal__title {
    font-size: 20px; font-weight: 700;
    color: #0B1F17; margin: 0 0 20px;
    padding-right: 28px; /* avoid overlap with X */
}

/* Form field rows */
.cv-field {
    display: flex; flex-direction: column; gap: 5px;
    margin-bottom: 4px;
    font-size: 14px; font-weight: 600; color: #5B6B63;
    width: 100%;
}
.cv-field span { display: block; margin-bottom: 3px; }
.cv-field small { font-weight: 400; color: #8A9A92; font-size: 12px; }
.cv-field input,
.cv-field textarea,
.cv-field select {
    width: 100%; padding: 10px 12px;
    border: 1.5px solid #C9D6CF;
    border-radius: 8px; font-size: 14px;
    color: #0B1F17; background: #FBFCFB;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
    box-sizing: border-box;
}
/* Position dropdown — keep a native-ish caret but consistent box */
.cv-field select.cv-select {
    -webkit-appearance: none; appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%238A9A92'%3E%3Cpath d='M5 7l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
.cv-field input:focus,
.cv-field textarea:focus,
.cv-field select:focus {
    outline: none;
    border-color: #2cae5f;
    box-shadow: 0 0 0 3px rgba(44, 174, 95, .18);
    background: #fff;
}
/* ---- CV dropzone ----
   Input thật vẫn nằm đó, chỉ trong suốt và bé lại chứ không display:none —
   display:none là rơi khỏi luồng tab, bàn phím hết đường mở hộp chọn file.
   Mọi trạng thái nhìn thấy được vẽ trên .cv-drop qua :hover/:focus-within/
   .is-drag/.is-filled. */
.cv-drop-label {
    display: block; margin-bottom: 8px;
    font-size: 14px; font-weight: 600; color: #5B6B63;
}
.cv-drop-wrap { position: relative; margin-bottom: 4px; }

.cv-drop {
    position: relative; display: block;
    padding: 26px 18px;
    border: 1.5px dashed #C9D6CF;
    border-radius: 8px;
    background: #FBFCFB;
    text-align: center; cursor: pointer;
    transition: border-color .15s, background-color .15s, box-shadow .15s;
}
/* Input co lại còn 1px thay vì phủ kín ô: nếu nó phủ kín thì cú thả rơi trúng
   chính input, trình duyệt tự gán file theo đường mặc định — chạy song song với
   nhánh gán bằng JS thành hai đường xử lý cho cùng một thao tác. Để nó bé lại
   thì mọi cú thả đều rơi vào .cv-drop, chỉ còn một đường. Bấm vẫn mở hộp chọn
   file vì đó là <label> bọc ngoài, không cần input hứng chuột. */
.cv-drop__input {
    position: absolute; left: 0; top: 0;
    width: 1px; height: 1px;
    opacity: 0;
}
.cv-drop:hover,
.cv-drop:focus-within {
    border-color: #2cae5f;
    background: #F4FBF7;
}
.cv-drop:focus-within {
    box-shadow: 0 0 0 3px rgba(44, 174, 95, .18);
}
.cv-drop.is-drag {
    border-color: #2cae5f;
    border-style: solid;
    background: #e8f7ee;
    box-shadow: 0 0 0 3px rgba(44, 174, 95, .18);
}

.cv-drop__idle {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    pointer-events: none;
}
.cv-drop__icon {
    width: 26px; height: 26px; margin-bottom: 8px;
    color: #2cae5f;
}
.cv-drop__title { font-size: 14px; font-weight: 600; color: #0B1F17; }
.cv-drop__browse {
    font-size: 13px; font-weight: 600; color: #229150;
    text-decoration: underline; text-underline-offset: 2px;
}
.cv-drop__hint { margin-top: 6px; font-size: 12px; color: #8A9A92; }

/* Đã chọn file: khung đặc, xếp ngang icon | tên + dung lượng */
.cv-drop.is-filled {
    border-style: solid; border-color: #2cae5f;
    background: #e8f7ee;
    padding: 14px 44px 14px 16px;
    text-align: left;
}
.cv-drop.is-filled .cv-drop__idle { display: none; }
.cv-drop__file {
    display: flex; align-items: center; gap: 12px;
    pointer-events: none;
}
/* display trong CSS đè thuộc tính hidden của HTML, nên phải trả lại tường minh */
.cv-drop__file[hidden],
.cv-drop__clear[hidden] { display: none; }
.cv-drop__file-icon { width: 24px; height: 24px; flex: 0 0 auto; color: #229150; }
.cv-drop__meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cv-drop__name {
    font-size: 14px; font-weight: 600; color: #0B1F17;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cv-drop__size { font-size: 12px; color: #5B6B63; }

/* Nút xoá nằm ngoài <label> nên bấm nó không mở hộp chọn file */
.cv-drop__clear {
    position: absolute; top: 50%; right: 12px;
    transform: translateY(-50%);
    z-index: 2;
    display: grid; place-items: center;
    width: 26px; height: 26px; padding: 0;
    border: none; border-radius: 50%;
    background: rgba(11, 31, 23, .06); color: #5B6B63;
    cursor: pointer; transition: background-color .15s, color .15s;
}
.cv-drop__clear svg { width: 14px; height: 14px; }
.cv-drop__clear:hover { background: #B42318; color: #fff; }
.cv-drop__clear:focus-visible { outline: 2px solid #2cae5f; outline-offset: 2px; }

/* Ô sai: viền đỏ để lỗi ngay dưới không phải là tín hiệu duy nhất */
.cv-drop.is-error { border-color: #B42318; background: #FEF3F2; }

/* Inline error messages */
.cv-err {
    display: none;
    font-size: 12px; color: #B42318;
    margin-top: 2px; margin-bottom: 10px;
}

/* Honeypot — invisible to real users */
.cv-hp {
    position: absolute; left: -9999px;
    width: 1px; height: 1px; overflow: hidden;
}

/* Submit button inside form — matches global .btn-apply but full-width */
.cv-submit-btn {
    width: 100%; margin-top: 16px;
    border: none; cursor: pointer;
}
.cv-submit-btn:disabled { opacity: .6; cursor: not-allowed; transform: none !important; }

/* Confirm modal actions row */
.cv-modal__actions {
    display: flex; gap: 12px; justify-content: flex-end;
    margin-top: 20px; flex-wrap: wrap;
}
.cv-modal__actions .btn-apply,
.cv-modal__actions .btn-apply-outline {
    display: inline-block; width: auto;
    min-width: 120px; padding: 10px 24px;
    font-size: 14px;
}
.cv-modal__actions .btn-apply { border: none; cursor: pointer; }
.cv-modal__actions .btn-apply-outline { cursor: pointer; background: none; }
.cv-modal__actions .btn-apply:disabled,
.cv-modal__actions .btn-apply-outline:disabled { opacity: .6; cursor: not-allowed; }

/* Success modal (shown after a CV is submitted) — a bit larger than --sm */
.cv-success { text-align: center; max-width: 640px; padding: 48px 52px 40px; }
.cv-success__icon {
    width: 92px; height: 92px; margin: 4px auto 24px;
    border-radius: 50%; background: #e8f7ee;
    display: flex; align-items: center; justify-content: center;
}
.cv-success__icon svg { width: 52px; height: 52px; }
.cv-success__title { text-align: center; padding-right: 0; margin-bottom: 18px; font-size: 26px; }
.cv-success__body {
    font-size: 16px; color: #5B6B63; line-height: 1.8; margin-bottom: 30px;
}
.cv-success__body p { margin: 0 0 14px; }
.cv-success__body p:last-child { margin-bottom: 0; }
.cv-success__lead { font-weight: 600; color: #0B1F17; font-size: 18px; }
.cv-success__regards { font-weight: 700; color: #0B1F17; }
.cv-success__ok { width: auto; min-width: 200px; margin: 0 auto; padding: 14px 32px; font-size: 15px; }
@media (max-width: 640px) {
    .cv-success { padding: 28px 20px 24px; }
}

/* Spinner on the confirm button while submitting */
.cv-modal .btn-apply.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.cv-modal .btn-apply.is-loading::after {
    content: '';
    position: absolute; top: 0; right: 0; bottom: 0; left: 0;
    margin: auto;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cvSpin .65s linear infinite;
}
@keyframes cvSpin {
    to { transform: rotate(360deg); }
}

/* Mobile tweaks */
@media (max-width: 540px) {
    .cv-modal__panel { padding: 24px 16px 20px; }
    .cv-modal__actions { flex-direction: column-reverse; }
    .cv-modal__actions .btn-apply,
    .cv-modal__actions .btn-apply-outline { width: 100%; text-align: center; }
}

/* Toast notifications (success / error feedback after submit) */
.cv-toast-wrap {
    position: fixed; top: 24px; right: 24px;
    z-index: 10050; /* above modal + sticky navbar */
    display: flex; flex-direction: column; gap: 10px;
    max-width: calc(100vw - 48px);
}
.cv-toast {
    display: flex; align-items: flex-start; gap: 10px;
    min-width: 240px; max-width: 380px;
    padding: 13px 16px; border-radius: 12px;
    background: #fff; color: #0B1F17;
    font-size: 14px; font-weight: 600; line-height: 1.4;
    box-shadow: 0 12px 34px -14px rgba(15,40,28,.28);
    border-left: 4px solid #2cae5f;
    opacity: 0; transform: translateX(20px);
    transition: opacity .25s ease, transform .25s ease;
}
.cv-toast.is-show { opacity: 1; transform: translateX(0); }
.cv-toast--error { border-left-color: #B42318; }
.cv-toast__icon { flex-shrink: 0; font-size: 16px; line-height: 1.4; }
.cv-toast--success .cv-toast__icon { color: #2cae5f; }
.cv-toast--error .cv-toast__icon { color: #B42318; }
@media (max-width: 540px) {
    .cv-toast-wrap { top: 12px; right: 12px; left: 12px; }
    .cv-toast { min-width: 0; max-width: none; }
}
