/**
 * KBMC public frontend — mobile / tablet responsive helpers
 */

html {
    -webkit-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

img,
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* Sticky header: prevent content hiding under navbar on small screens */
.kbmc-header-sticky + * .container-fluid.py-4,
.kbmc-header-sticky ~ .container-fluid.py-4 {
    scroll-margin-top: 72px;
}

/* Page hero bands */
.container-fluid.py-4.bg-primary .container h1,
.container-fluid.py-4.bg-primary .container .h3 {
    font-size: clamp(1.15rem, 4vw, 1.75rem);
    line-height: 1.25;
}

.container-fluid.py-4.bg-primary .container p {
    font-size: clamp(0.8rem, 2.5vw, 0.95rem);
}

@media (max-width: 575.98px) {
    .container-fluid.py-4.bg-primary {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .container.py-5,
    .container.py-4 {
        padding-top: 1.25rem !important;
        padding-bottom: 1.25rem !important;
    }

    .container-fluid.py-5 {
        padding-top: 1.25rem !important;
        padding-bottom: 1.25rem !important;
    }
}

/* Home slider */
.mh-slide[style*="min-height: 580px"] {
    min-height: min(580px, 85vh) !important;
}

@media (max-width: 991.98px) {
    .mh-slide {
        min-height: 420px !important;
    }
}

@media (max-width: 575.98px) {
    .mh-slide {
        min-height: 360px !important;
    }

    .mh-iconbar .row {
        row-gap: 0;
    }

    .mh-iconitem {
        border-right: 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    }

    .mh-iconitem:nth-child(odd) {
        border-right: 1px solid rgba(255, 255, 255, 0.12);
    }

    .mh-ticker .d-flex {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    .mh-tickerlabel {
        text-align: center;
    }
}

/* Key persons — council block: 4 per row (two rows of 4) */
.mh-keypersons.council .mh-keypersons-row {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

@media (max-width: 991.98px) {
    .mh-keypersons {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .mh-keypersons.council .mh-keypersons-row {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 575.98px) {
    .mh-keypersons {
        grid-template-columns: 1fr !important;
    }

    .mh-keypersons.council .mh-keypersons-row {
        grid-template-columns: 1fr !important;
    }

    .mh-keypersons.council .mh-person {
        max-width: none !important;
    }
}

/* Logged-in user area */
.kbmc-user-shell > aside {
    margin-bottom: 0;
}

@media (max-width: 991.98px) {
    .kbmc-user-sidebar {
        margin-bottom: 0.5rem;
    }

    .kbmc-user-sidebar .card-body > .p-4.bg-primary {
        padding: 1rem !important;
    }

    .kbmc-user-sidebar .nav.flex-column {
        flex-direction: row !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        border-bottom: 1px solid #e9ecef;
    }

    .kbmc-user-sidebar .nav.flex-column .nav-link,
    .kbmc-user-sidebar .nav.flex-column form button.nav-link {
        white-space: nowrap;
        border-bottom: none !important;
        border-right: 1px solid #e9ecef;
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem;
    }

    .kbmc-user-sidebar .nav.flex-column .nav-link:last-child,
    .kbmc-user-sidebar .nav.flex-column form:last-child .nav-link {
        border-right: 0;
    }

    .kbmc-user-sidebar .nav.flex-column .nav-link i {
        display: none;
    }
}

.kbmc-user-main .card-header .d-flex {
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Tables */
.kbmc-user-main .table-responsive,
.kbmc-page-content .table-responsive {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    .kbmc-user-main table.table th,
    .kbmc-user-main table.table td,
    .kbmc-page-content table.table th,
    .kbmc-page-content table.table td {
        font-size: 0.8125rem;
        padding: 0.5rem 0.4rem;
    }
}

/* Survey application form (partials/survey-form-body) */
.kbmc-survey-tabs,
#surveyForm .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.kbmc-survey-tabs .nav-link,
#surveyForm .nav-tabs .nav-link {
    font-size: clamp(0.7rem, 2.5vw, 0.875rem);
    padding: 0.5rem 0.65rem;
    white-space: nowrap;
}

.kbmc-survey-form .row > [class*="col-"],
#surveyForm .row > [class*="col-"] {
    min-width: 0;
}

.kbmc-survey-form .table-responsive,
#surveyForm .table-responsive {
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}

/* Stack label/value pairs on phones (not the wide family-members grid) */
@media (max-width: 767.98px) {
    .kbmc-survey-form .table-responsive > table.table-bordered:not(.small) tbody tr {
        display: grid;
        grid-template-columns: 1fr;
    }

    .kbmc-survey-form .table-responsive > table.table-bordered:not(.small) th,
    .kbmc-survey-form .table-responsive > table.table-bordered:not(.small) td {
        display: block;
        width: 100% !important;
        max-width: 100%;
        white-space: normal;
        word-break: break-word;
    }

    .kbmc-survey-form .table-responsive > table.table-bordered:not(.small) th {
        background: #f8f9fa;
        font-size: 0.8125rem;
        border-bottom: 0;
        padding-bottom: 0.25rem;
    }

    .kbmc-survey-form .table-responsive > table.table-bordered:not(.small) td {
        padding-top: 0.35rem;
        border-top: 0;
        margin-bottom: 0.5rem;
    }

    .kbmc-survey-form .table-responsive > table.table-bordered:not(.small) td[colspan] {
        grid-column: 1;
    }
}

@media (max-width: 575.98px) {
    .kbmc-user-main .card-body.p-4,
    #surveyForm .card-body {
        padding: 1rem !important;
    }

    .kbmc-survey-form-actions {
        flex-direction: column;
        align-items: stretch !important;
    }

    .kbmc-survey-form-actions .btn {
        width: 100%;
    }

    #getBankDetailsBtn,
    #resetBankBtn {
        width: 100%;
    }

    .kbmc-survey-form .d-flex.align-items-center.gap-3 {
        flex-direction: column;
        align-items: flex-start !important;
    }
}

/* Scheme cards */
.scheme-card-img {
    height: clamp(150px, 28vw, 200px);
}

/* Contact & content pages */
@media (max-width: 767.98px) {
    .container .d-flex.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        text-align: left;
    }

    .container .d-flex.align-items-center.mb-4 i.fa-2x {
        margin-bottom: 0.5rem !important;
        margin-right: 0 !important;
    }
}

/* Government GR rows */
.kbmc-gr-row {
    flex-direction: column;
    align-items: flex-start !important;
}

@media (min-width: 576px) {
    .kbmc-gr-row {
        flex-direction: row;
        align-items: center !important;
    }
}

/* Modals */
@media (max-width: 575.98px) {
    .modal-dialog.modal-xl,
    .modal-dialog.modal-lg {
        max-width: calc(100% - 1rem);
        margin: 0.5rem auto;
    }

    #feedbackModal .modal-body .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .cidco-right-inner {
        padding: 1.25rem 1rem !important;
    }
}

/* Auth modal split layout */
@media (max-width: 991.98px) {
    .cidco-modal .modal-body {
        flex-direction: column !important;
    }

    .cidco-left {
        flex: 0 0 auto !important;
        min-height: 120px;
    }
}

/* Lottery / scheme pages */
.lottery-schedule-table {
    font-size: clamp(0.75rem, 2.5vw, 0.875rem);
}

/* Back to top — avoid overlap with mobile browser chrome */
@media (max-width: 575.98px) {
    .back-to-top {
        right: 12px;
        bottom: 12px;
        width: 44px;
        height: 44px;
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Pagination (Tailwind fallback in Bootstrap theme) */
body .pagination svg {
    width: 1rem !important;
    height: 1rem !important;
}

/* Document uploads */
.docs-table .doc-upload-input {
    max-width: 100% !important;
    min-width: 0 !important;
    width: 100%;
}

@media (max-width: 767.98px) {
    .docs-table td,
    .docs-table th {
        white-space: normal;
    }
}

/* Eligibility check modal (dashboard / verify-identity) */
body.elig-modal-open {
    overflow: hidden;
}

.elig-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0.75rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    background: rgba(0, 0, 0, 0.55);
}

@media (min-width: 576px) {
    .elig-overlay {
        align-items: center;
        padding: 1rem;
    }
}

.elig-modal {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 42rem;
    max-height: min(92dvh, 92vh);
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.elig-head {
    flex-shrink: 0;
    padding: 0.875rem 1rem;
    background: #f4fbfe;
    border-bottom: 1px solid #e5edf3;
}

.elig-head h5 {
    margin: 0;
    font-weight: 800;
    font-size: 1rem;
}

.elig-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    overscroll-behavior: contain;
}

.elig-foot {
    flex-shrink: 0;
    padding: 0.875rem 1rem;
    padding-bottom: max(0.875rem, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e5edf3;
    background: #fff;
    box-shadow: 0 -6px 16px rgba(15, 23, 42, 0.08);
}

.elig-continue-btn {
    width: 100%;
    font-weight: 700;
    padding: 0.65rem 1.25rem;
}

@media (min-width: 576px) {
    .elig-continue-btn {
        width: auto;
        min-width: 10rem;
    }

    .elig-foot {
        display: flex;
        justify-content: flex-end;
    }
}

.elig-q {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eef2f6;
}

.elig-q-last {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.elig-q-text {
    display: block;
    font-weight: 700;
    font-size: clamp(0.8125rem, 3.2vw, 0.9375rem);
    line-height: 1.45;
    margin-bottom: 0.5rem;
    word-break: break-word;
    hyphens: auto;
}

.elig-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
}

.elig-option {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-weight: 600;
    font-size: 0.9375rem;
    min-height: 2.75rem;
    cursor: pointer;
}

.elig-error {
    color: #b02a37;
    font-size: 0.8125rem;
    margin-top: 0.75rem;
    display: none;
}

.text-white-color {
    color: #fff !important;
}

/* My room scheme filter */
#schemeFilter {
    max-width: 100%;
    min-width: 0 !important;
    width: 100%;
}

@media (min-width: 576px) {
    #schemeFilter {
        width: auto;
        min-width: 14rem !important;
    }
}
