/* ============================================================
   CB Responsive Data Table  —  global / reusable
   - Desktop: clean table with expandable detail row (arrow toggle)
   - Mobile (<=991px): each row becomes a stacked card,
     detail stays hidden until the arrow is tapped
   - Theme-color agnostic: avatars/role text use existing
     bg-* / text-* classes, so it fits any project palette
   ============================================================ */

.cb-rt-wrap {
    width: 100%;
    /* overflow-x: auto; */
    -webkit-overflow-scrolling: touch;
}

.cb-rt {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 6px;
    font-size: .85rem;
    margin-bottom: 0;
}

/* ---- head ---- */
.cb-rt thead th {
    background: #f4f5f9;
    color: #6c7282;
    font-weight: 700;
    text-transform: uppercase;
    font-size: .68rem;
    letter-spacing: .4px;
    padding: .7rem .9rem;
    white-space: nowrap;
    border: 0;
}

.cb-rt thead th:first-child {
    border-radius: 8px 0 0 8px;
}

.cb-rt thead th:last-child {
    border-radius: 0 8px 8px 0;
}

/* ---- main rows ---- */
.cb-rt tbody tr.cb-rt-main {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
    transition: box-shadow .15s ease;
}

.cb-rt tbody tr.cb-rt-main:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, .10);
    /* background: rgba(149, 150, 159, 0.23); */
}

.cb-rt tbody td {
    padding: .6rem .9rem;
    vertical-align: middle;
    border: 0;
    border-top: 1px solid #eceef3;
    border-bottom: 1px solid #eceef3;
}

.cb-rt-main td:first-child {
    border-left: 1px solid #eceef3;
    border-radius: 8px 0 0 8px;
}

.cb-rt-main td:last-child {
    border-right: 1px solid #eceef3;
    border-radius: 0 8px 8px 0;
}

/* ---- expand toggle ---- */
.cb-rt-expand {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 7px;
    background: #eef0f6;
    color: #5a6072;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease;
}

.cb-rt-expand:hover {
    background: #e2e5ef;
}

.cb-rt-expand i {
    font-size: 1.15rem;
    transition: transform .2s ease;
}

.cb-rt-expand.open {
    background: #d9e2ff;
    color: #2f55d4;
}

.cb-rt-expand.open i {
    transform: rotate(180deg);
}

/* ---- user cell ---- */
.cb-rt-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
}

.cb-rt-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
}

.cb-rt-name {
    font-weight: 600;
    color: #2d3748;
}

.cb-rt-user:hover .cb-rt-name {
    text-decoration: underline;
}

.cb-rt-inactive {
    display: inline-block;
    margin-top: 2px;
    font-size: .64rem;
    font-weight: 600;
    color: #c53030;
    background: #fde8e8;
    padding: 1px 8px;
    border-radius: 50px;
}

.cb-rt-email {
    max-width: 240px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.cb-rt-pill {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    padding: .22rem .6rem;
    border-radius: 50px;
    background: #f1f2f6;
}

.cb-rt-muted {
    color: #aab0bd;
}

/* ---- detail (expanded) row ---- */
.cb-rt-detail {
    display: none;
}

.cb-rt-detail.show {
    display: table-row;
}

.cb-rt-detail>td {
    border: 0 !important;
    padding: 0 !important;
    background: transparent;
}

.cb-rt-detail-card {
    background: #f8f9fc;
    border: 1px solid #e6e8ef;
    border-radius: 10px;
    padding: 1rem 1.2rem;
    margin: -2px .2rem 4px .2rem;
}

.cb-rt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .9rem 1.5rem;
}

.cb-rt-dl {
    display: block;
    font-size: .66rem;
    font-weight: 700;
    color: #8a93a8;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 2px;
}

.cb-rt-dv {
    font-size: .85rem;
    color: #2d3748;
    word-break: break-word;
}

.cb-rtswitch {
    margin-right: 0.75rem;
    position: relative;
    vertical-align: middle;
    margin-bottom: 0;
    display: inline-block;
    border-radius: 30rem;
    cursor: pointer;
    min-height: 1.35rem;
    font-size: 0.9375rem;
    line-height: 1.4;
}

/* ============================================================
   MOBILE  (<= 991px): rows become cards
   ============================================================ */
@media (max-width: 991px) {

    .cb-rt-wrap {
        overflow-x: visible;
    }

    .cb-rt {
        border-spacing: 0;
    }

    .cb-rt thead {
        display: none;
    }

    .cb-rt tbody {
        display: block;
        width: 100%;
    }

    .cb-rt tr.cb-rt-main {
        display: block;
        width: 100%;
        position: relative;
        border: 1px solid #e6e8ef;
        border-radius: 12px 12px 0 0;
        margin: 0 0 -1px 0;
        box-shadow: 0 3px 12px rgba(0, 0, 0, .06);
    }

    /* each body cell -> label (left) + value (right) */
    .cb-rt tr.cb-rt-main>td {
        display: flex;
        align-items: center;
        gap: 1rem;
        width: 100%;
        border: 0 !important;
        border-bottom: 1px solid #eef0f5 !important;
        border-radius: 0 !important;
        padding: .6rem .9rem;
        text-align: right;
        word-break: break-word;
    }

    .cb-rt tr.cb-rt-main>td:last-child {
        border-bottom: 0 !important;
    }

    .cb-rt tr.cb-rt-main>td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: .7rem;
        color: #8a93a8;
        text-transform: uppercase;
        letter-spacing: .3px;
        white-space: nowrap;
        margin-right: auto;
        text-align: left;
    }

    /* name = card header */
    .cb-rt tr.cb-rt-main>td.cb-rt-name-cell {
        background: #f6f7fb;
        text-align: left;
        padding: .85rem 2.6rem .85rem .9rem;
        border-radius: 12px 12px 0 0;
    }

    .cb-rt tr.cb-rt-main>td.cb-rt-name-cell::before {
        content: none;
    }

    /* arrow floats to the top-right of the card */
    .cb-rt tr.cb-rt-main>td.cb-rt-arrow-cell {
        position: absolute;
        top: 10px;
        right: 10px;
        width: auto;
        padding: 0 !important;
        border: 0 !important;
        background: transparent;
        display: block;
    }

    .cb-rt tr.cb-rt-main>td.cb-rt-arrow-cell::before {
        content: none;
    }

    .cb-rt-email {
        max-width: 60vw;
        white-space: normal;
        text-align: right;
    }

    /* detail stays hidden until .show is toggled */
    .cb-rt tr.cb-rt-detail {
        display: none;
        width: 100%;
    }

    .cb-rt tr.cb-rt-detail.show {
        display: block;
        width: 100%;
    }

    .cb-rt tr.cb-rt-detail.show>td {
        display: block;
        width: 100%;
    }

    .cb-rt-detail-card {
        border-radius: 0 0 12px 12px;
        margin: 0 0 1rem 0;
        border-top: 0;
        box-shadow: 0 3px 12px rgba(0, 0, 0, .06);
    }

    .cb-rt-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 520px) {
    .cb-rt-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    td .switch {
        margin-right: 18px !important;
    }
}

@media (max-width: 991px) {

    /* mobile cards: serial # row hide */
    .cb-rt-sr {
        display: none !important;
    }

    /* har card rounded + gap, aur absolute children ke liye base */
    .cb-rt tr.cb-rt-main {
        border-radius: 12px;
        margin: 0 0 1rem 0;
        position: relative;
    }

    /* detail apna alag block */
    .cb-rt-detail-card {
        border-radius: 12px;
        margin: -.6rem 0 1rem 0;
        border-top: 1px solid #e6e8ef;
    }

    /* checkbox: card ke top-LEFT, sabse upar, poora clickable */
    .cb-rt-selectable tr.cb-rt-main>td.cb-rt-check-cell {
        position: absolute;
        top: 14px;
        left: 12px;
        z-index: 50;
        /* z-index 20 -> 50 */
        width: auto;
        padding: 0 !important;
        border: 0 !important;
        background: transparent;
        display: block;
        pointer-events: auto;
        /* NAYA */
    }

    .cb-rt-selectable tr.cb-rt-main>td.cb-rt-check-cell::before {
        content: none;
    }

    .cb-rt-selectable tr.cb-rt-main>td.cb-rt-check-cell input[type="checkbox"]:checked {
        background-color: #0d6efd;
        /* Bootstrap primary blue */
        border-color: #0d6efd;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: center;
        background-size: 70%;
    }

    /* arrow: card ke top-RIGHT */
    .cb-rt-selectable tr.cb-rt-main>td.cb-rt-arrow-cell {
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 15;
        width: auto;
        padding: 0 !important;
        border: 0 !important;
        background: transparent;
        display: block;
    }

    .cb-rt-selectable tr.cb-rt-main>td.cb-rt-arrow-cell::before {
        content: none;
    }

    /* header me dono ke liye jagah (left=checkbox, right=arrow) */
    .cb-rt-selectable tr.cb-rt-main>td.cb-rt-name-cell {
        padding-left: 3rem;
        padding-right: 3rem;
        position: relative;
        z-index: 1;
        /* NAYA */
    }
}

/* dropdown khule to wrapper ka clipping hata do */
.cb-rt-wrap.dropdown-open {
    overflow: visible;
}

/* desktop pe row pe dropdown aane ke liye z-index */
.cb-rt tbody tr.cb-rt-main:has(.dropdown-menu.show) {
    z-index: 30;
    position: relative;
}

/* balance card: stack content + amount wraps on small screens */
.balance-amount {
    word-break: break-word;
}

/* ---------- DESKTOP: sidebar (filter + breakdown) sticky as one unit ---------- */
@media (min-width: 992px) {
    .col-lg-3 {
        position: sticky;
        top: 1rem;
        align-self: flex-start;
    }
}

/* ---------- TABLET / MOBILE: nothing sticky or fixed, normal flow ---------- */
@media (max-width: 991.98px) {

    .col-lg-3,
    .col-lg-3>.card,
    .filter-card,
    .card.filter-card,
    .card.mt-3 {
        position: static !important;
        top: auto !important;
        bottom: auto !important;
    }

    /* har card ke beech gap taake overlap na ho */
    .col-lg-3 .card {
        margin-bottom: 1rem;
    }

    .filter-card {
        margin-bottom: 1rem;
    }
}

/* ---------- SMALL PHONES ---------- */
@media (max-width: 575.98px) {

    /* balance card header: stack title and button */
    .balance-card .d-flex.justify-content-between.align-items-start {
        flex-direction: column;
        gap: .75rem;
    }

    .balance-card .btn-light {
        width: 100%;
    }

    .balance-amount {
        font-size: 1.6rem;
    }

    /* mini-stats: smaller */
    .mini-stat div:last-child {
        font-size: 1rem !important;
    }

    /* stats cards icon/heading tighter */
    .stats-card .stat-icon {
        font-size: 1.5rem;
    }

    .stats-card h3 {
        font-size: 1.15rem;
    }

    /* export buttons text wrap */
    .card-body .btn {
        white-space: normal;
    }

    /* module breakdown spacing */
    .breakdown-item {
        padding: .4rem 0;
    }
}

@media (max-width: 575.98px) {

    /* fetch-user row: input full width, button full width below */
    .fetch-user-row .col-10,
    .fetch-user-row .col-2 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }

    .fetch-user-row .btn {
        width: 100%;
    }

    /* info side cards spacing */
    .container-p-y .col-lg-4 .card {
        margin-bottom: 1rem;
    }
}

/* on tablet/mobile, info column comes after the form with a gap */
@media (max-width: 991.98px) {
    .col-lg-8 {
        margin-bottom: 1.25rem;
    }
}
.page-item .page-link {
    border-radius: 50rem!important;
}
