/* ==========================================================================
   Carers Support Referrals V2 – Stylesheet
   Scoped entirely under .csRefV2Container to avoid conflicts with v1 or theme.
   ========================================================================== */

/* ── Container ─────────────────────────────────────────────────────────── */

.csRefV2Container {
    margin: 0 auto;
    max-width: 900px;
    font-family: "Open Sans", sans-serif;
}

.csRefV2Title {
    font-family: "Mulish", sans-serif;
    font-weight: 700;
    color: #000;
    margin-bottom: 1.5rem;
}

/* ── Error banner ───────────────────────────────────────────────────────── */

.csRefV2Error {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 0.25rem;
    color: #721c24;
}

/* ── Nav pills (step tabs) ──────────────────────────────────────────────── */

.csRefV2Nav {
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #dee2e6;
}

.csRefV2Nav > li > a {
    color: #555;
    border-radius: 0;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s, background-color 0.2s;
}

.csRefV2Nav > li.active > a,
.csRefV2Nav > li.active > a:focus,
.csRefV2Nav > li.active > a:hover {
    color: #fff;
    background-color: #21aab1;
    border-color: #21aab1;
}

.csRefV2Nav > li > a:hover {
    background-color: #e9f7f8;
    color: #21aab1;
}

.csRefV2Nav > li.csRefV2TabLocked > a,
.csRefV2Nav > li.csRefV2TabLocked > a:focus,
.csRefV2Nav > li.csRefV2TabLocked > a:hover {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 600px) {
    .csRefV2Nav > li > a {
        font-size: 0.8rem;
        padding: 0.5rem 0.4rem;
    }
}

/* ── Tab panes ──────────────────────────────────────────────────────────── */

.csRefV2TabContent .tab-pane {
    padding: 1.5rem 0;
}

/* ── Intro and privacy details ──────────────────────────────────────────── */

.csRefV2Intro {
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background-color: #f0fafa;
    border-left: 4px solid #21aab1;
    border-radius: 0 0.25rem 0.25rem 0;
}

.csRefV2Intro p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: #333;
}

.csRefV2Intro p:last-child {
    margin-bottom: 0;
}

.csRefV2Note {
    color: #555;
    font-size: 0.9rem;
}

.csRefV2PrivacyDetails {
    margin-top: 1rem;
    border: 1px solid #c3e8ea;
    border-radius: 0.25rem;
    overflow: hidden;
}

.csRefV2PrivacyDetails summary {
    cursor: pointer;
    padding: 0.6rem 1rem;
    font-weight: 600;
    color: #21aab1;
    background-color: #e0f5f6;
    list-style: none;
    user-select: none;
}

.csRefV2PrivacyDetails summary::-webkit-details-marker {
    display: none;
}

.csRefV2PrivacyDetails summary::before {
    content: "▸ ";
}

.csRefV2PrivacyDetails[open] summary::before {
    content: "▾ ";
}

.csRefV2Privacy {
    padding: 1rem;
    font-size: 0.875rem;
    color: #444;
    line-height: 1.6;
}

.csRefV2Privacy p {
    margin-bottom: 0.5rem;
}

.csRefV2Declarations {
    margin-top: -1rem;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background-color: #fff;
    border: 1px solid #c3e8ea;
    border-radius: 0.25rem;
}

.csRefV2DeclarationBlock + .csRefV2DeclarationBlock {
    margin-top: 1.5rem;
}

.csRefV2DeclarationTitle {
    margin-bottom: 0;
    font-weight: 700;
    color: #21aab1;
}

.csRefV2Declarations p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: #333;
}

.csRefV2DeclarationField {
    margin-top: 0.5rem;
}

.csRefV2DeclarationField .csRefV2FieldWrap {
    margin-bottom: 0;
}

.csRefV2DeclarationClosing {
    margin-top: 1.5rem;
    margin-bottom: 0 !important;
    font-style: italic;
}

/* ── Section headings within tabs ───────────────────────────────────────── */

.csRefV2SectionHeader {
    margin-top: 1.5rem;
    margin-bottom: 0.25rem;
}

.csRefV2Heading {
    font-family: "Mulish", sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: #21aab1;
    border-bottom: 2px solid #e0f5f6;
    padding-bottom: 0.4rem;
}

.csRefV2SubHeader {
    margin-top: 1rem;
}

.csRefV2SubHeading {
    font-weight: 700;
    font-size: 1rem;
    color: #21aab1;
    margin-bottom: 1rem;
}

/* ── Form field layout ──────────────────────────────────────────────────── */

.csRefV2Fields.row,
.csRefV2CaredForInstance.row {
    display: flex;
    flex-wrap: wrap;
}

.csRefV2Fields .csRefV2FieldWrap {
    padding-right: 12px;
    padding-left: 12px;
}

.csRefV2Fields .csRefV2RowBreak {
    flex-basis: 100%;
    width: 100%;
    height: 0;
}

/* Override shared helper .csws-form-field styles for v2 consistency */

.csRefV2Container .csws-form-field label {
    color: #000;
    font-family: "Open Sans", sans-serif;
    font-weight: normal;
    font-size: 0.95rem;
    line-height: normal;
    margin-bottom: 0.5rem;
    display: block;
}

.csRefV2Container .csws-form-field .help-text small {
    font-size: 0.75rem;
}

.csRefV2Container .csws-form-field input:not([type="radio"]):not([type="checkbox"]),
.csRefV2Container .csws-form-field textarea,
.csRefV2Container .csws-form-field select,
.csRefV2Container .csws-form-field .select2-selection {
    border-radius: 20px;
    min-height: 48px;
    font-size: 0.95rem;
}

.csRefV2Container .select2-container .select2-selection--single {
    height: 48px !important;
    padding: 0 2.5rem 0 1rem !important;
    display: flex;
    align-items: center;
}

.csRefV2Container .select2-container .select2-selection--single.select2-selection--clearable {
    padding-right: 4rem !important;
}

.csRefV2Container .select2-container .select2-selection--single .select2-selection__rendered {
    padding: 0 !important;
    line-height: 1.4 !important;
}

.csRefV2Container .select2-container .select2-selection--single .select2-selection__clear {
    position: absolute !important;
    top: 50%;
    right: 2.2rem;
    transform: translateY(-50%);
    float: none !important;
    border: 0 !important;
    background: transparent !important;
    color: #666 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 1rem !important;
    height: 1rem !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    font-size: 1rem !important;
    line-height: 1 !important;
    cursor: pointer;
}

.csRefV2Container .select2-container .select2-selection--single .select2-selection__clear:hover,
.csRefV2Container .select2-container .select2-selection--single .select2-selection__clear:focus {
    color: #333 !important;
}

.csRefV2Container .select2-container .select2-selection--single .select2-selection__placeholder,
.csRefV2Container .select2-container .select2-selection--single .select2-selection__rendered {
    color: #777;
}

.csRefV2Container .select2-container .select2-selection--multiple {
    min-height: 48px !important;
    height: auto !important;
    padding: 0.45rem 2.4rem 0.45rem 0.75rem !important;
}

.csRefV2Container .select2-container .select2-selection--multiple::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 1rem;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #8c8c8c;
    transform: translateY(-35%);
    pointer-events: none;
}

.csRefV2Container .select2-container .select2-selection--multiple .select2-selection__rendered {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0 !important;
}

.csRefV2Container .select2-container .select2-selection--multiple .select2-selection__choice {
    margin: 0 !important;
    padding: 0.2rem 0.65rem !important;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.csRefV2Container .select2-container .select2-selection--multiple .select2-search--inline,
.csRefV2Container .select2-container .select2-selection--multiple .select2-search__field {
    margin: 0 !important;
}

.csRefV2Container .select2-container .select2-selection--multiple .select2-search__field {
    min-height: 0 !important;
    height: 1.4em !important;
    resize: none;
}

.csRefV2Container .select2-container .select2-selection--multiple .select2-selection__choice__remove {
    position: static !important;
    border: 0 !important;
    background: transparent !important;
    color: #666 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 1rem !important;
    line-height: 1 !important;
}

.csRefV2Container .select2-container .select2-selection--multiple .select2-selection__choice__remove:hover,
.csRefV2Container .select2-container .select2-selection--multiple .select2-selection__choice__remove:focus {
    color: #333 !important;
}

.select2-dropdown.select2-dropdown--below,
.select2-dropdown.select2-dropdown--above {
    margin-top: 0 !important;
}

.csRefV2Container .csws-form-field textarea {
    min-height: 120px;
    border-radius: 8px;
}

/* Radio / toggle styling */

.csRefV2Container .csws-form-field input[type="radio"] {
    position: relative;
    height: 20px;
    width: 20px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
    flex-shrink: 0;
}

.csRefV2Container .csws-form-field input[type="radio"]::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 9px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid #aaa;
}

.csRefV2Container .csws-form-field input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    top: 9px;
    left: 9px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #21aab1;
    transform: translate(-50%, -50%);
}

.csRefV2Container .csws-form-field .formRadio {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.csRefV2Container .csws-form-field .toggle-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: normal;
    cursor: pointer;
}

/* Checkbox styling */

.csRefV2Container .csws-form-field input[type="checkbox"] {
    position: relative;
    height: 18px;
    width: 18px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
    flex-shrink: 0;
}

.csRefV2Container .csws-form-field input[type="checkbox"]::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 9px;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
    border: 2px solid #aaa;
    border-radius: 3px;
}

.csRefV2Container .csws-form-field input[type="checkbox"]:checked::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #21aab1;
    font-size: 0.8rem;
    font-weight: bold;
}

.csRefV2Container .csws-form-field .formCheckboxes label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    font-weight: normal;
    cursor: pointer;
}

/* ── Validation error states ────────────────────────────────────────────── */

.csRefV2Container .csws-form-field input.highlightError,
.csRefV2Container .csws-form-field textarea.highlightError,
.csRefV2Container .csws-form-field select.highlightError {
    border: 2px solid #dc3545 !important;
}

.csRefV2Container .csws-form-field input[type="radio"].highlightError::before,
.csRefV2Container .csws-form-field input[type="checkbox"].highlightError::before {
    border-color: #dc3545;
}

.csRefV2Container .csws-form-field .select2-selection.highlightError {
    border: 2px solid #dc3545 !important;
}

.csRefV2TabError {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 0.25rem;
    color: #721c24;
    font-size: 0.9rem;
}

/* ── Address / postcode ─────────────────────────────────────────────────── */

.csRefV2PostcodeWrap {
    position: relative;
}

.csRefV2PostcodeLookupBtn {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    border-radius: 20px;
    padding: 0.3rem 1rem;
    background-color: #e0f5f6;
    border: 1px solid #21aab1;
    color: #21aab1;
    cursor: pointer;
    transition: background-color 0.2s;
}

.csRefV2PostcodeLookupBtn:hover {
    background-color: #21aab1;
    color: #fff;
}

/* Postcode lookup panel */
.csRefV2PcPanel {
    margin-top: 0.3rem;
}

.csRefV2PostcodeLookupBtn {
    margin-top: 0.4rem;
    font-size: 0.875rem;
    border-radius: 20px;
    padding: 0.35rem 1.1rem;
    background-color: #e0f5f6;
    border: 1px solid #21aab1;
    color: #21aab1;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    display: inline-block;
}

.csRefV2PostcodeLookupBtn:hover,
.csRefV2PostcodeLookupBtn:focus {
    background-color: #21aab1;
    color: #fff;
    outline: 2px solid #187a80;
    outline-offset: 2px;
}

.csRefV2PostcodeLookupBtn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.csRefV2PcStatus {
    margin-top: 0.35rem;
    min-height: 1.4rem;
}

.csRefV2PcMsg {
    font-size: 0.875rem;
    display: inline-block;
}

.csRefV2PcLoading {
    color: #6c757d;
    font-style: italic;
}

.csRefV2PcError {
    color: #c0392b;
}

.csRefV2PcSuccess {
    color: #1e7e34;
    font-weight: 600;
}

.csRefV2PcInfo {
    color: #4a4a4a;
}

.csRefV2PcResults {
    margin-top: 0.5rem;
}

.csRefV2PcLabel {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #333;
}

.csRefV2PcSelect {
    font-size: 0.95rem;
    border-radius: 6px !important;
    min-height: 40px !important;
}

.csRefV2ManualHint {
    margin-top: 0.5rem;
    margin-bottom: 0;
    font-size: 0.85rem;
    color: #555;
}

.csRefV2ManualBtn {
    background: none;
    border: none;
    padding: 0;
    color: #21aab1;
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    line-height: inherit;
}

.csRefV2ManualBtn:hover,
.csRefV2ManualBtn:focus {
    color: #187a80;
    outline: none;
}

.csRefV2WestSussexWarning {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 0.25rem;
    color: #856404;
    font-size: 0.875rem;
    display: none;
}

/* ── Repeatable cared-for section ───────────────────────────────────────── */

.csRefV2CaredForContainer {
    padding: 0;
}

.csRefV2CaredForInstance {
    border: 1px solid #c3e8ea;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
    background-color: #fafefe;
}

.csRefV2CaredForInstance .csRefV2CaredForInstanceLabel {
    font-weight: 700;
    font-size: 1rem;
    color: #21aab1;
    margin-bottom: 1rem;
    display: block;
}

.csRefV2BtnRemoveCaredFor {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: 1px solid #dc3545;
    color: #dc3545;
    border-radius: 20px;
    font-size: 0.8rem;
    padding: 0.2rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.csRefV2BtnRemoveCaredFor:hover {
    background-color: #dc3545;
    color: #fff;
}

/* ── Navigation buttons ─────────────────────────────────────────────────── */

.csRefV2Buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
    flex-wrap: wrap;
}

.csRefV2Container .btn {
    border-radius: 50px;
    font-family: "Open Sans", sans-serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 0.6rem 1.75rem;
    border: none;
    outline: none;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
}

.csRefV2Container .btn-primary {
    background-color: #21aab1;
    color: #fff;
}

.csRefV2Container .btn-primary:hover,
.csRefV2Container .btn-primary:focus {
    background-color: #1a8c93;
    color: #fff;
}

.csRefV2Container .btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.csRefV2Container .btn-secondary {
    background-color: #6c757d;
    color: #fff;
}

.csRefV2Container .btn-secondary:hover {
    background-color: #545b62;
}

/* ── Form result messages ───────────────────────────────────────────────── */

.csRefV2FormResult {
    padding: 1rem 1.25rem;
    margin-top: 1rem;
    border-radius: 0.25rem;
}

.csRefV2FormResult.is-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.csRefV2FormResult.is-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* ── Conditional fields – animated show/hide ────────────────────────────── */

.csRefV2Conditional {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
    .csRefV2Container .col-md-6,
    .csRefV2Container .col-md-4 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }

    .csRefV2Buttons {
        flex-direction: column;
    }

    .csRefV2Container .btn {
        width: 100%;
        text-align: center;
    }
}
