/* ==========================================================================
   TDF Grievance Management System – theme
   Uses native CSS nesting (Chrome 120+, Safari 17.2+, Firefox 117+),
   the same baseline that :has() already requires.
   ========================================================================== */

:root {
    /* Brand tokens */
    --tdf-navy: #0b3556;
    --tdf-navy-dark: #082943;
    --tdf-navy-light: #0e4a73;
    --tdf-indigo: #232e7f;
    --tdf-orange: #f46831;
    --tdf-orange-dark: #d45520;
    --tdf-orange-light: #f7a778;
    --tdf-blue: #1e90ff;
    --tdf-blue-dark: #0268c0;
    --tdf-blue-light: #74c0fc;
    --tdf-green: #0e7c3f;
    --tdf-green-dark: #0a5c2e;
    --tdf-green-rgb: 14 124 63;
    --tdf-red: #c0392b;

    /* UI tokens (were repeated as literals) */
    --tdf-text: #1e293b;
    --tdf-muted: #475569;
    --tdf-line: #e2e8f0;
    --tdf-surface: #f8fafc;
    --tdf-focus-ring: 0 0 0 0.25rem rgb(var(--tdf-green-rgb) / 0.25);

    --tdf-font: 'Poppins', 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

/* ---- Base ---------------------------------------------------------------- */
/* Headings, .btn, .form-label etc. inherit this; no need to list them. */
body {
    font-family: var(--tdf-font);
    color: var(--tdf-text);
}

a {
    color: var(--tdf-indigo);

    &:hover {
        color: var(--tdf-green-dark);
    }
}

.lead {
    color: var(--tdf-indigo);
}

.hide {
    display: none;
}

.show {
    display: block;
}

/* ---- Hero ---------------------------------------------------------------- */
.hero-section {
    color: #fff;
    padding: 40px 0;
    border-block: 5px solid var(--tdf-indigo);

    img {
        padding: 5px;
        border-radius: 10px;
        background: #fff;
        box-shadow: 0 0 10px rgb(0 0 0 / 0.5);
    }
}

.site-title {
    color: var(--tdf-orange);
    text-transform: uppercase;
    text-wrap: balance;
}

.site-title-word {
    display: inline-block;
    margin-right: 0.25em;

    &::first-letter {
        color: var(--tdf-indigo);
        text-shadow: 1px 1px 2px rgb(241 241 241 / 0.5);
    }
}

/* ---- Language switcher --------------------------------------------------- */
.lang-switch {
    position: absolute;
    top: 16px;
    right: 16px;
    display: inline-flex;
    overflow: hidden;
    border: 1px solid rgb(255 255 255 / 0.5);
    border-radius: 999px;

    .lang-btn {
        padding: 4px 14px;
        border: none;
        background: #ddd;
        color: #fff;
        font-size: 0.85rem;
        font-weight: 600;
        cursor: pointer;
        transition: 0.2s;

        &.active {
            background: var(--tdf-indigo);
        }

        &:not(.active):hover {
            background: rgb(255 255 255 / 0.15);
        }
    }
}

/* ---- Cards / layout ------------------------------------------------------ */
.stats-card {
    margin-top: -30px;
    border-radius: 10px;
    transition: transform 0.2s;

    &:hover {
        transform: translateY(-5px);
    }
}

.shadow-sm {
    box-shadow: 0 0 12px rgb(171 181 255) !important;
}

.gunaso-card {
    overflow: hidden;
    border: 1px solid var(--tdf-line);
    border-radius: 16px;
    background: #fff;
}

.form-header-area {
    padding: 1.5rem;
    background: var(--tdf-surface);
    border-bottom: 1px solid var(--tdf-line);
}

.section-title {
    margin-bottom: 20px;
    padding-left: 10px;
    border-left: 4px solid var(--tdf-green);
    font-size: 1.1rem;
    color: var(--tdf-indigo);
}

.form-label {
    font-size: 0.9rem;
    color: var(--tdf-muted);
}

/* ---- Select2 (loaded before this file, so equal specificity wins by order) */
.select2-container {
    width: 100% !important;
    /* select2 writes an inline width */

    .select2-selection--single {
        height: 38px;
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
    }
}

.select2-container--default {
    .select2-selection--single .select2-selection__rendered {
        padding-left: 12px;
        line-height: 36px;
        color: #212529;
    }

    .select2-selection--single .select2-selection__arrow {
        height: 36px;
    }

    &.select2-container--focus .select2-selection--single {
        border-color: var(--tdf-green);
        outline: 0;
        box-shadow: var(--tdf-focus-ring);
    }
}

/* ---- Bootstrap overrides -> TDF theme ------------------------------------ */
.form-control:focus,
.form-select:focus {
    border-color: var(--tdf-green);
    box-shadow: var(--tdf-focus-ring);
}

/* .btn-primary and .btn-orange only differ by two colours */
.btn-primary {
    --btn-bg: var(--tdf-green);
    --btn-bg-hover: var(--tdf-green-dark);
}

.btn-orange {
    --btn-bg: var(--tdf-orange);
    --btn-bg-hover: var(--tdf-orange-dark);
}

.btn-primary,
.btn-orange {
    background-color: var(--btn-bg) !important;
    border-color: var(--btn-bg) !important;
    color: #fff !important;

    &:hover,
    &:focus {
        background-color: var(--btn-bg-hover) !important;
        border-color: var(--btn-bg-hover) !important;
    }
}

.text-primary {
    color: var(--tdf-indigo) !important;
}

.bg-primary {
    background-color: var(--tdf-indigo) !important;
}

.btn-light.text-primary:hover {
    background-color: #f7f7f7 !important;
    color: var(--tdf-orange) !important;
}

/* ==========================================================================
   Footer: "Alternative ways to make a complaint"
   ========================================================================== */
.card-footer {
    --gf-pad: 1.5rem;

    padding: 0;
    overflow: hidden;
    background: var(--tdf-surface);
    border-top: 1px solid var(--tdf-line);

    /* Every Font Awesome pseudo-element shares these four declarations */
    .form-header-area::before,
    .section-note::before,
    .row>.p-4 p::before,
    .row>.p-4::after {
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        line-height: 1;
    }

    /* Bootstrap .row (flex + negative gutters) becomes a 2-column grid */
    .row {
        --bs-gutter-x: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
        margin: 0;
        padding: 0 var(--gf-pad) var(--gf-pad);
    }

    /* Header bar */
    .form-header-area {
        grid-column: 1 / -1;
        width: auto;
        max-width: none;
        margin: 0 calc(-1 * var(--gf-pad));
        padding: 1.1rem var(--gf-pad);
        display: flex;
        align-items: center;
        gap: 0.85rem;
        background: #fff;

        &::before {
            content: "\f590";
            /* headset */
            flex: none;
            display: grid;
            place-items: center;
            width: 2.5rem;
            height: 2.5rem;
            border-radius: 50%;
            background: var(--tdf-navy);
            color: #fff;
            font-size: 1rem;
        }

        h5 {
            margin: 0;
            font-size: 1.05rem;
            font-weight: 600;
            line-height: 1.35;
        }
    }

    /* The two contact panels. Icons are supplied through custom properties:
       --icon (panel + title), --p1..--p3 (icon for each detail row). */
    .row>.p-4 {
        position: relative;
        display: flex;
        flex-direction: column;
        margin: 0;
        padding: 1.25rem 1.25rem 0.5rem !important;
        /* beats Bootstrap's !important .p-4 */
        overflow: hidden;
        background: #fff;
        border: 1px solid var(--tdf-line);
        border-top: 3px solid var(--accent);
        border-radius: 12px;

        /* Panel 1: officer (navy) */
        &:nth-child(2) {
            --accent: var(--tdf-navy);
            --icon: "\f2bb";
            /* address-card */
            --p1: "\f007";
            /* user */
            --p2: "\f095";
            /* phone */
            --p3: "\f0e0";
            /* envelope */
        }

        /* Panel 2: post / drop box (indigo) */
        &:nth-child(3) {
            --accent: var(--tdf-indigo);
            --icon: "\f658";
            /* envelope-open-text */
            --p1: "\f3c5";
            /* location-dot */
            --p2: "\f01c";
            /* inbox */
        }

        /* Faded corner icon */
        &::after {
            content: var(--icon);
            position: absolute;
            right: -0.4rem;
            bottom: -1.1rem;
            color: var(--accent);
            opacity: 0.06;
            pointer-events: none;
            font-size: 6rem;
        }

        /* Detail rows, ruled like a directory entry */
        p {
            position: relative;
            z-index: 1;
            /* above the faded corner icon */
            display: flex;
            align-items: center;
            gap: 0.8rem;
            margin: 0;
            padding: 0.7rem 0;
            border-top: 1px solid var(--tdf-line);
            font-size: 0.9rem;
            line-height: 1.4;
            overflow-wrap: anywhere;
            /* long emails / addresses never overflow */

            &::before {
                flex: none;
                width: 1.25rem;
                text-align: center;
                color: var(--accent);
                font-size: 0.95rem;
            }

            &:nth-of-type(1)::before {
                content: var(--p1);
            }

            &:nth-of-type(2)::before {
                content: var(--p2);
            }

            &:nth-of-type(3)::before {
                content: var(--p3);
            }

            /* First row is the headline (officer name / address) */
            &:first-of-type {
                font-size: 1.05rem;
                font-weight: 600;
                color: var(--tdf-indigo);
            }
        }
    }

    /* Panel titles */
    .section-note {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        margin: 0 0 0.5rem;
        font-size: 1rem;
        line-height: 1.35;
        color: var(--tdf-indigo);

        &::before {
            content: var(--icon);
            flex: none;
            display: grid;
            place-items: center;
            width: 2rem;
            height: 2rem;
            border-radius: 8px;
            background: #eef2f7;
            /* fallback */
            background: color-mix(in srgb, var(--accent) 12%, #fff);
            color: var(--accent);
            font-size: 0.9rem;
        }
    }

    /* Links (tel:, mailto:) */
    p a {
        color: inherit;
        text-decoration: underline;
        text-underline-offset: 0.2em;

        &:hover {
            color: var(--accent);
        }

        &:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: 2px;
            border-radius: 2px;
        }
    }

    /* Small screens: stack the panels */
    @media (max-width: 767.98px) {
        --gf-pad: 1rem;

        .row {
            grid-template-columns: 1fr;
            gap: 1rem;
        }

        .form-header-area h5 {
            font-size: 1rem;
        }
    }
}

/* ==========================================================================
   Radio groups rendered as segmented buttons
   Layout trick: [label row] then, per option, a text row (height --seg-h)
   and a gap row. The radio is pulled up over its text with a negative margin.
   ========================================================================== */
/* div:has(> input[type="radio"]) {
    --seg-h: 2.75rem;
    --seg-gap: 0.5rem;
    --seg-accent: var(--tdf-green);
    --seg-line: #cbd5e1;

    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;

    grid-auto-rows: var(--seg-h) var(--seg-gap);
    column-gap: 0.5rem;
    align-items: center;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.25;

    >.form-label {
        grid-column: 1 / -1;
        align-self: end;
        text-align: left;
    }

    >input[type="radio"] {
        appearance: none;
        position: relative;
        z-index: 1;
        box-sizing: border-box;
        align-self: start;
        justify-self: stretch;
        width: 100%;
        height: var(--seg-h);
        margin: calc(-1 * var(--seg-h)) 0 0;
        padding: 0;
        background: transparent;
        border: 1.5px solid var(--seg-line);
        border-radius: 10px;
        cursor: pointer;
        transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;

        &:nth-of-type(1) {
            grid-area: 3 / 1;
        }

        &:nth-of-type(2) {
            grid-area: 3 / 2;
        }

        &:hover {
            border-color: var(--seg-accent);
            background: rgb(var(--tdf-green-rgb) / 0.05);
        }

        &:checked {
            border-color: var(--seg-accent);
            background: rgb(var(--tdf-green-rgb) / 0.12);
            box-shadow: inset 0 0 0 1px var(--seg-accent);

            &::after {
                content: "\f00c";
                 position: absolute;
                top: -0.45rem;
                right: -0.35rem;
                display: grid;
                place-items: center;
                width: 1.15rem;
                height: 1.15rem;
                border-radius: 50%;
                background: var(--seg-accent);
                color: #fff;
                font: 900 0.6rem/1 "Font Awesome 6 Free";
            }
        }

        &:focus-visible {
            outline: 3px solid rgb(var(--tdf-green-rgb) / 0.35);
            outline-offset: 2px;
        }

        @media (prefers-reduced-motion: reduce) {
            transition: none;
        }
    }

    &:has(> input[type="radio"]:nth-of-type(5)) {
        grid-template-columns: repeat(3, minmax(0, 1fr));

        >input[type="radio"] {
            &:nth-of-type(3) {
                grid-area: 3 / 3;
            }

            &:nth-of-type(4) {
                grid-area: 5 / 1;
            }

            &:nth-of-type(5) {
                grid-area: 5 / 2;
            }
        }

        @media (max-width: 575.98px) {
            grid-template-columns: repeat(2, minmax(0, 1fr));

            >input[type="radio"] {
                &:nth-of-type(3) {
                    grid-area: 5 / 1;
                }

                &:nth-of-type(4) {
                    grid-area: 5 / 2;
                }

                &:nth-of-type(5) {
                    grid-area: 7 / 1;
                }
            }
        }
    }
} */

/* Radio button container */
div:has(> input[type="radio"]) {
    --seg-h: 2.75rem;
    --seg-gap: 0.5rem;
    --seg-accent: var(--tdf-green);
    --seg-line: #cbd5e1;

    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
    grid-auto-rows: var(--seg-h) var(--seg-gap);
    column-gap: 0.5rem;
    align-items: center;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.25;
}

/* Field label */
div:has(> input[type="radio"])>.form-label {
    grid-column: 1 / -1;
    align-self: end;
    text-align: left;
}

/* Radio inputs as clickable button shells */
div:has(> input[type="radio"])>input[type="radio"] {
    appearance: none;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    align-self: start;
    justify-self: stretch;
    width: 100%;
    height: var(--seg-h);
    margin: calc(-1 * var(--seg-h)) 0 0;
    padding: 0;
    background: transparent;
    border: 1.5px solid var(--seg-line);
    border-radius: 10px;
    cursor: pointer;
    transition:
        border-color 0.15s,
        background-color 0.15s,
        box-shadow 0.15s;
}

/* Radio button positions: two columns */
div:has(> input[type="radio"])>input[type="radio"]:nth-of-type(1) {
    grid-area: 3 / 1;
}

div:has(> input[type="radio"])>input[type="radio"]:nth-of-type(2) {
    grid-area: 3 / 2;
}

div:has(> input[type="radio"])>input[type="radio"]:nth-of-type(3) {
    grid-area: 5 / 1;
}

/* Hover state */
div:has(> input[type="radio"])>input[type="radio"]:hover {
    border-color: var(--seg-accent);
    background: rgb(var(--tdf-green-rgb) / 0.05);
}

/* Selected radio button */
div:has(> input[type="radio"])>input[type="radio"]:checked {
    border-color: var(--seg-accent);
    background: rgb(var(--tdf-green-rgb) / 0.12);
    box-shadow: inset 0 0 0 1px var(--seg-accent);
}

/* Checkmark badge on selected option */
div:has(> input[type="radio"])>input[type="radio"]:checked::after {
    content: "\f00c";
    position: absolute;
    top: -0.45rem;
    right: -0.35rem;
    display: grid;
    place-items: center;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    background: var(--seg-accent);
    color: #fff;
    font: 900 0.6rem/1 "Font Awesome 6 Free";
}

/* Keyboard accessibility */
div:has(> input[type="radio"])>input[type="radio"]:focus-visible {
    outline: 3px solid rgb(var(--tdf-green-rgb) / 0.35);
    outline-offset: 2px;
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    div:has(> input[type="radio"])>input[type="radio"] {
        transition: none;
    }
}

/* Five radio options: three columns */
div:has(> input[type="radio"]:nth-of-type(5)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Third option: first row, third column */
div:has(> input[type="radio"]:nth-of-type(5))>input[type="radio"]:nth-of-type(3) {
    grid-area: 3 / 3;
}

/* Fourth option: second row, first column */
div:has(> input[type="radio"]:nth-of-type(5))>input[type="radio"]:nth-of-type(4) {
    grid-area: 5 / 1;
}

/* Fifth option: second row, second column */
div:has(> input[type="radio"]:nth-of-type(5))>input[type="radio"]:nth-of-type(5) {
    grid-area: 5 / 2;
}

/* Mobile layout: five options in two columns */
@media (max-width: 575.98px) {
    div:has(> input[type="radio"]:nth-of-type(5)) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Third option */
    div:has(> input[type="radio"]:nth-of-type(5))>input[type="radio"]:nth-of-type(3) {
        grid-area: 5 / 1;
    }

    /* Fourth option */
    div:has(> input[type="radio"]:nth-of-type(5))>input[type="radio"]:nth-of-type(4) {
        grid-area: 5 / 2;
    }

    /* Fifth option */
    div:has(> input[type="radio"]:nth-of-type(5))>input[type="radio"]:nth-of-type(5) {
        grid-area: 7 / 1;
    }
}
