﻿/* =========================================================
   GRID COMMON CSS
   NOTE: App.razor me yeh file app.css ke BAAD link honi chahiye
========================================================= */

/* ===== Theme tokens ===== */
:root {
    --navy-900: #0A2036;
    --navy-800: #0D2A45;
    --cyan-500: #1CC7DE;
    --cyan-400: #4FDCEE;
    --cyan-050: #E8FBFC;
    --ink-900: #0F2439;
    --ink-600: #5B7086;
    --ink-400: #93A3B4;
    --line: #E4EAF1;
    --card: #fff;
    --green: #17A673;
    --amber: #F59E0B;
    /* Card ke upar jitni jagah (navbar + breadcrumb + page title + gap) ghiri hai.
       Isse grid ki max height = screen height - offset hoti hai. */
    --grid-offset: 202px;
    --grid-page-pad: 0 18px;
    --ctl-h: 40px; /* toolbar controls ki height */
}

/* ===== Page shell (height fixed nahi, content ke hisaab se) ===== */
.grid-page {
    padding: var(--grid-page-pad);
}

/* ===== Page header ===== */
.page-headdata {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.page-head {
    margin-bottom: 18px;
}

    .page-head h1 {
        margin: 0 0 4px;
        font-size: 24px;
        font-weight: 700;
        color: var(--navy-900);
    }

    .page-head p {
        margin: 0;
        color: var(--ink-600);
        font-size: 13.5px;
    }

/* ===== Buttons ===== */
.app-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 10px;
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    padding: 0 16px;
    height: var(--ctl-h);
    cursor: pointer;
    white-space: nowrap;
    transition: transform .12s ease, box-shadow .12s ease, background .12s;
}

    .app-btn:active {
        transform: translateY(1px);
    }

    .app-btn:disabled {
        opacity: .55;
        cursor: not-allowed;
    }

.app-btn-primary {
    background: linear-gradient(135deg, #071A2E, #0D2A45);
    color: #fff;
}

    .app-btn-primary:hover {
        background: #12304F;
        color: #fff;
    }

.app-btn-ghost {
    background: #fff;
    color: var(--ink-600);
    border: 1px solid var(--line);
}

    .app-btn-ghost:hover {
        color: var(--navy-900);
        border-color: #c9d4e0;
    }

/* ===== Card: height = data ke hisaab se, max = screen ===== */
.grid-card {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 2px 14px rgba(15, 36, 57, .04);
    overflow: hidden;
    min-height: 0;
    max-height: max(320px, calc(100vh - var(--grid-offset)));
    max-height: max(320px, calc(100dvh - var(--grid-offset)));
}

/* ===== Toolbar ===== */
.grid-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 12px 22px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Dropdown (app.css ke .form-select ko override) */
.grid-toolbar .form-select {
    width: 170px;
    max-width: 100%;
    height: var(--ctl-h);
    padding: 0 34px 0 12px !important;
    font-size: 13.5px;
    line-height: normal;
    border: 1px solid var(--line) !important;
    border-radius: 10px !important;
    background-color: #fff;
    color: var(--ink-900);
    box-shadow: none !important;
}

    .grid-toolbar .form-select:focus {
        border-color: var(--cyan-500) !important;
    }

/* ===== Search ===== */
.search-wrap {
    position: relative;
    width: 270px;
    max-width: 100%;
}

    .search-wrap input.form-control {
        width: 100%;
        height: var(--ctl-h);
        padding: 0 34px !important;
        font-size: 13.5px;
        border: 1px solid var(--line) !important;
        border-radius: 10px !important;
        background: #fff;
        box-shadow: none !important;
    }

        .search-wrap input.form-control:focus {
            border-color: var(--cyan-500) !important;
        }

.search-icon, .clear-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-400);
    font-size: 12px;
}

.search-icon {
    left: 12px;
    pointer-events: none;
}

.clear-icon {
    right: 12px;
    cursor: pointer;
}

/* ===== Bulk bar ===== */
.bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--navy-900);
    color: #fff;
    padding: 10px 22px;
    flex-shrink: 0;
}

.bulk-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 700;
}

.bulk-count {
    background: var(--cyan-500);
    color: var(--navy-900);
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

    .bulk-actions button {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border: 1px solid rgba(255,255,255,.16);
        background: rgba(255,255,255,.06);
        color: #fff;
        font: inherit;
        font-size: 12.5px;
        font-weight: 700;
        padding: 7px 12px;
        border-radius: 8px;
        cursor: pointer;
        transition: background .12s;
    }

        .bulk-actions button:hover {
            background: rgba(255,255,255,.14);
        }

        .bulk-actions button.danger:hover {
            background: rgba(239,68,68,.24);
            border-color: rgba(239,68,68,.4);
        }

/* ===== Table area: sirf yahi scroll hota hai ===== */
.grid-body {
    flex: 0 1 auto; /* data kam => chhota, data zyada => card ki max height tak, phir scroll */
    min-height: 0;
    overflow: auto;
}

    /* Slim rounded scrollbar (Chrome / Edge / Safari) */
    .grid-body::-webkit-scrollbar {
        width: 6px;
        height: 8px;
    }

    .grid-body::-webkit-scrollbar-track {
        background: #F1F4F9;
        border-radius: 4px;
    }

    .grid-body::-webkit-scrollbar-thumb {
        background: #C3CDDD;
        border-radius: 8px;
    }

        .grid-body::-webkit-scrollbar-thumb:hover {
            background: #A9B6CB;
        }

    .grid-body::-webkit-scrollbar-button {
        display: none;
        width: 0;
        height: 0;
    }

    .grid-body::-webkit-scrollbar-corner {
        background: transparent;
    }
/* Firefox */
@supports not selector(::-webkit-scrollbar) {
    .grid-body {
        scrollbar-width: thin;
        scrollbar-color: #C3CDDD #F1F4F9;
    }
}

/* ===== Table ===== */
.grid-table {
    width: 100%;
    min-width: 720px;
    margin: 0;
    border-collapse: collapse;
}

    .grid-table thead th {
        position: sticky;
        top: 0;
        z-index: 1;
        text-align: left;
        font-size: 11px;
        letter-spacing: .4px;
        text-transform: uppercase;
        color: var(--ink-400);
        font-weight: 700;
        padding: 10px 14px;
        background: #F8FAFC;
        border-bottom: 1px solid var(--line);
        white-space: nowrap;
    }

    .grid-table tbody td {
        padding: 0 10px;
        height: 38px;
        font-size: 12px;
        color: var(--ink-900);
        border-bottom: 1px solid var(--line);
        vertical-align: middle;
        max-width: 260px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .grid-table tbody tr:last-child td {
        border-bottom: none;
    }

    .grid-table tbody tr {
        cursor: pointer;
        transition: background .12s;
    }

        .grid-table tbody tr:hover {
            background: #F9FBFD;
        }

        .grid-table tbody tr.selected-row {
            background: var(--cyan-050);
        }

    .grid-table .col-chk {
        width: 44px;
        min-width: 44px;
        max-width: 44px;
        text-align: center;
        padding: 0 !important;
    }

.chk {
    width: 16px;
    height: 16px;
    accent-color: var(--cyan-500);
    cursor: pointer;
}

.name-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.name-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11.5px;
    color: #fff;
}

.name-cell .tag-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
}

    .status .dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: currentColor;
    }

.status-active {
    color: var(--green);
}

.status-archived {
    color: var(--amber);
}

/* ===== Footer / Pagination (app.css ke .table-footer-bar, .pagination ko override) ===== */
.grid-card .table-footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin: 0;
    padding: 10px 22px;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
    flex-shrink: 0;
}

.grid-card .footer-pagesize {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--ink-600);
    font-weight: 600;
}

    .grid-card .footer-pagesize select.form-select {
        width: 72px;
        height: 32px;
        padding: 0 26px 0 8px !important;
        font-size: 13px;
        border: 1px solid var(--line) !important;
        border-radius: 6px !important;
        box-shadow: none !important;
    }

.grid-card .footer-info {
    font-size: 13px;
    color: var(--ink-600);
}

    .grid-card .footer-info strong {
        color: var(--navy-900);
    }

.grid-card .custom-pagination {
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    flex-wrap: wrap;
}

    .grid-card .custom-pagination .page-item .page-link {
        width: 32px;
        height: 32px;
        padding: 0;
        border-radius: 8px;
        border: 1px solid var(--line);
        background: #fff;
        font-size: 13px;
        font-weight: 700;
        color: var(--ink-600);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        text-decoration: none;
        box-shadow: none;
    }

    .grid-card .custom-pagination .page-item.active .page-link {
        background: var(--navy-900) !important;
        color: #fff;
        border-color: var(--navy-900);
    }

    .grid-card .custom-pagination .page-item:not(.active):not(.disabled) .page-link:hover {
        background: #fff;
        border-color: var(--cyan-500);
        color: var(--cyan-500);
    }

    .grid-card .custom-pagination .page-item.disabled .page-link {
        background: #F9FAFB;
        color: var(--ink-400);
        cursor: not-allowed;
    }

/* ===== Responsive ===== */
@media (max-width: 991px) {
    :root {
        --grid-page-pad: 0 16px;
        --grid-offset: 290px;
    }

    .grid-toolbar, .grid-card .table-footer-bar, .bulk-bar {
        padding-left: 14px;
        padding-right: 14px;
    }
}

@media (max-width: 640px) {
    :root {
        --grid-page-pad: 0 10px;
        --grid-offset: 340px;
    }

    .page-head h1 {
        font-size: 20px;
    }

    .toolbar-actions {
        width: 100%;
    }

        .toolbar-actions .form-select {
            flex: 1;
            width: auto;
        }

    .search-wrap {
        width: 100%;
    }

    .grid-card .table-footer-bar {
        justify-content: center;
    }

    .grid-card .footer-info {
        order: 3;
        width: 100%;
        text-align: center;
    }

    .grid-table tbody td {
        font-size: 12px;
    }

    /* The toolbar stacks tall on phones, so a screen-height cap left only one or two rows visible; let the page scroll instead */
    .grid-card {
        max-height: none;
    }

    /* Drop fixed inline table widths on phones; nowrap headers still size the table to its content */
    .grid-body > .grid-table[style*="min-width"] {
        min-width: 720px !important;
    }
}

/* ===== Sortable headers ===== */
.grid-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.sort-icon {
    margin-left: 10px;
    font-size: 10px;
    opacity: .5;
    transition: opacity .12s, color .12s;
}

th.sortable:hover .sort-icon {
    opacity: 1;
}

th.sorted .sort-icon {
    opacity: 1;
    color: var(--cyan-500);
}


.grid-page.grid-embedded {
    padding: 0;
    width: 100%;
    min-width: 0;
}

.grid-embedded .grid-card {
    width: 100%;
    min-width: 0;
    max-height: calc(100dvh - 380px); /* tab height minus tab padding and the h5 */
}

.grid-embedded .grid-body {
    min-width: 0;
    overflow: auto; /* horizontal and vertical scroll stay inside the card */
}

.grid-embedded .grid-table {
    
    min-width: 900px;
}

    .grid-embedded .grid-table tbody td {
        max-width: 180px;
    }


/* Two or more small grids stacked in one tab */
.grid-embedded .grid-card.grid-compact {
    max-height: 300px;
}

.sub-heading {
    font-weight: 600;
}