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

/* Active menu bền vững trên trang con.
   sticky.navbar.js chỉ thêm/xoá class "active" trên các thẻ <a> (menuItems),
   KHÔNG đụng tới <li>. Vì vậy trang con đánh dấu active ở <li class="active">
   (server-side, không bị JS xoá khi cuộn) và style <span> tương đương a.active
   của trang chủ (xem frontend.css). Icon đã đổi màu sẵn nhờ "nav .active svg". */
nav .navbar-right > li.active > a > span {
    position: relative;
    text-transform: uppercase;
    color: #39B683 !important;
    font-weight: 600;
}
nav .navbar-right > li.active > a > span::after {
    content: " ";
    position: absolute;
    width: 25px;
    height: 1px;
    bottom: 0px;
    left: 0px;
    background-color: #39B683;
}

/* =========================================================
   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: #39B683; 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: #2d9e70; color: #fff; text-decoration: none; transform: translateY(-2px); }
.btn-apply-outline {
    display: block; width: 100%; text-align: center; margin-top: 10px;
    border: 1.5px solid #39B683; color: #39B683; font-size: 14px; font-weight: 600;
    padding: 11px 20px; border-radius: 30px; transition: all .2s;
}
.btn-apply-outline:hover { background: #e8faf3; color: #2d9e70; text-decoration: none; }

/* CTA "Gửi CV ngay" button rendered as a <button> — strip native chrome. */
button.btn-white {
    border: none; cursor: pointer; font-family: inherit;
    -webkit-appearance: none; appearance: 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;
    /* Above the sticky navbar (sticky.navbar.js applies z-index:9999) so the
       overlay dims the navbar too instead of it poking through on top. */
    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 8px 48px rgba(0, 0, 0, .18);
    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: #9EA8B5;
    padding: 4px 6px; border-radius: 6px;
    transition: color .15s, background .15s;
}
.cv-modal__x:hover { color: #1F2937; background: #F3F4F6; }

/* Modal title */
.cv-modal__title {
    font-size: 20px; font-weight: 700;
    color: #1F2937; 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: #47535D;
    width: 100%;
}
.cv-field span { display: block; margin-bottom: 3px; }
.cv-field small { font-weight: 400; color: #9EA8B5; font-size: 12px; }
.cv-field input,
.cv-field textarea,
.cv-field select {
    width: 100%; padding: 10px 12px;
    border: 1.5px solid #D1D5DB;
    border-radius: 8px; font-size: 14px;
    color: #1F2937; background: #FAFAFA;
    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='%239EA8B5'%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: #39B683;
    box-shadow: 0 0 0 3px rgba(57, 182, 131, .15);
    background: #fff;
}
.cv-field input[type="file"] {
    padding: 8px 10px;
    background: #F8FFFE;
    border-color: #39B683;
    cursor: pointer;
}

/* Inline error messages */
.cv-err {
    display: none;
    font-size: 12px; color: #E53E3E;
    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: #e8faf3;
    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: #4B5563; 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: #1F2937; font-size: 18px; }
.cv-success__regards { font-weight: 700; color: #1F2937; }
.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: #1F2937;
    font-size: 14px; font-weight: 600; line-height: 1.4;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .16);
    border-left: 4px solid #39B683;
    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: #E53E3E; }
.cv-toast__icon { flex-shrink: 0; font-size: 16px; line-height: 1.4; }
.cv-toast--success .cv-toast__icon { color: #39B683; }
.cv-toast--error .cv-toast__icon { color: #E53E3E; }
@media (max-width: 540px) {
    .cv-toast-wrap { top: 12px; right: 12px; left: 12px; }
    .cv-toast { min-width: 0; max-width: none; }
}
