/*
==========================================================
SPI UI Framework
Component : Table
Version   : 1.0.0
Author    : StudioProjectID
==========================================================
*/


/*=========================================================
TABLE CONTAINER
=========================================================*/

.spi-table-container{

    width:100%;

    overflow-x:auto;

    position:relative;

    border:1px solid var(--border);

    border-radius:var(--spi-radius-lg);

    background:var(--bg-card);

    box-shadow:var(--spi-shadow-xs);

}


/*=========================================================
TABLE
=========================================================*/

.spi-table{

    width:100%;

    min-width:900px;

    border-collapse:collapse;

}


/*=========================================================
HEADER
=========================================================*/

.spi-table thead{

    background:var(--bg-secondary);

}


.spi-table thead th{

    padding:18px 20px;

    font-size:14px;

    font-weight:600;

    color:var(--text);

    text-align:left;

    white-space:nowrap;

    border-bottom:1px solid var(--border);

    background:var(--bg-secondary);

}


/*=========================================================
BODY
=========================================================*/

.spi-table tbody td{

    padding:18px 20px;

    color:var(--text);

    font-size:14px;

    vertical-align:middle;

    border-bottom:1px solid var(--border);

    background:var(--bg-card);

}


/*=========================================================
LAST ROW
=========================================================*/

.spi-table tbody tr:last-child td{

    border-bottom:none;

}


/*=========================================================
ROW
=========================================================*/

.spi-table tbody tr{

    transition:var(--spi-transition);

}


/*=========================================================
HOVER
=========================================================*/

.spi-table tbody tr:hover td{

    background:#f8fafc;

}


/*=========================================================
STRIPED
=========================================================*/

.spi-table-striped tbody tr:nth-child(even) td{

    background:#fafafa;

}


/*=========================================================
STRIPED + HOVER
=========================================================*/

.spi-table-striped tbody tr:nth-child(even):hover td{

    background:#f8fafc;

}


/*=========================================================
COMPACT
=========================================================*/

.spi-table-compact th,
.spi-table-compact td{

    padding:12px 14px;

}


/*=========================================================
BORDERED
=========================================================*/

.spi-table-bordered th,
.spi-table-bordered td{

    border:1px solid var(--border);

}


/*=========================================================
TEXT ALIGNMENT
=========================================================*/

.spi-text-center{

    text-align:center !important;

}


.spi-text-left{

    text-align:left !important;

}


.spi-text-right{

    text-align:right !important;

}


/*=========================================================
NUMBER
=========================================================*/

.spi-number{

    font-variant-numeric:tabular-nums;

}


/*=========================================================
IMAGE
=========================================================*/

.spi-table-image{

    width:42px;

    height:42px;

    border-radius:50%;

    object-fit:cover;

}


/*=========================================================
ACTION
=========================================================*/

.spi-table-action{

    display:flex;

    justify-content:center;

    align-items:center;

    flex-wrap:wrap;

    gap:8px;

}


/*=========================================================
BADGE
=========================================================*/

.spi-table-badge{

    display:inline-flex;

    align-items:center;

    justify-content:center;

    padding:5px 12px;

    border-radius:50px;

    font-size:12px;

    font-weight:600;

}


.spi-success{

    background:#dcfce7;

    color:#166534;

}


.spi-danger{

    background:#fee2e2;

    color:#991b1b;

}


.spi-warning{

    background:#fef3c7;

    color:#92400e;

}


.spi-info{

    background:#dbeafe;

    color:#1e40af;

}


/*=========================================================
TABLE FOOTER
=========================================================*/

.spi-table-footer{

    display:flex;

    justify-content:space-between;

    align-items:center;

    flex-wrap:wrap;

    gap:12px;

    padding:18px 22px;

    border-top:1px solid var(--border);

}


/*=========================================================
PAGINATION
=========================================================*/

.spi-pagination{

    display:flex;

    align-items:center;

    flex-wrap:wrap;

    gap:10px;

}


/*=========================================================
EMPTY
=========================================================*/

.spi-table-empty{

    padding:80px 20px;

    text-align:center;

    color:var(--text-muted);

}


.spi-table-empty h3{

    margin-top:10px;

    font-size:18px;

}


.spi-table-empty p{

    margin-top:8px;

    font-size:14px;

}


/*=========================================================
LOADING
=========================================================*/

.spi-loading{

    width:100%;

    height:16px;

    border-radius:8px;

    background:linear-gradient(
        90deg,
        #ececec,
        #f7f7f7,
        #ececec
    );

    background-size:200%;

    animation:spiLoading 1.4s infinite;

}


@keyframes spiLoading{

    from{

        background-position:200%;

    }

    to{

        background-position:-200%;

    }

}


/*=========================================================
SELECTABLE
=========================================================*/

.spi-table-selectable tbody tr{

    cursor:pointer;

}


/*=========================================================
ACTIVE ROW
=========================================================*/

.spi-table tbody tr.active td{

    background:#dbeafe;

}


/*=========================================================
SCROLLABLE TABLE
=========================================================*/

.spi-table-scroll{

    width:100%;

    max-height:650px;

    overflow:auto;

    position:relative;

    border-radius:var(--spi-radius-lg);

    background:#ffffff;

    isolation:isolate;

    scrollbar-width:thin;

    scrollbar-color:#cbd5e1 #f1f5f9;

}


/*=========================================================
TABLE INSIDE SCROLL CONTAINER
=========================================================*/

.spi-table-scroll .spi-table{

    margin:0;

    border:none;

    border-collapse:separate;

    border-spacing:0;

    background:#ffffff;

}


/*=========================================================
CELL BORDER
=========================================================*/

.spi-table-sticky thead th,
.spi-table-sticky tbody td{

    border-right:1px solid var(--border);

}


.spi-table-sticky thead th:last-child,
.spi-table-sticky tbody td:last-child{

    border-right:none;

}


/*=========================================================
STICKY TABLE HEADER
=========================================================*/

.spi-table-sticky thead th{

    position:sticky;

    top:0;

    z-index:30;

    background:#ffffff;

    color:var(--text);

    background-clip:padding-box;

    box-shadow:
        0 1px 0 var(--border);

}


/*=========================================================
STICKY COLUMN - NUMBER
=========================================================*/

.spi-table-sticky .spi-sticky-no{

    position:sticky;

    left:0;

    width:64px;
    min-width:64px;
    max-width:64px;

    z-index:20;

    background:#ffffff;

    background-clip:padding-box;

    border-right:1px solid #d8dee8;

}


/*=========================================================
STICKY NUMBER HEADER
=========================================================*/

.spi-table-sticky thead .spi-sticky-no{

    z-index:50;

    background:#ffffff;

}


/*=========================================================
STICKY COLUMN - PRODUCT
=========================================================*/

.spi-table-sticky .spi-sticky-product{

    position:sticky;

    left:64px;

    width:220px;
    min-width:220px;
    max-width:220px;

    z-index:19;

    background:#ffffff;

    background-clip:padding-box;

    border-right:1px solid #d8dee8;

    box-shadow:
        8px 0 14px -12px rgba(15,23,42,.45);

    white-space:normal;

    overflow-wrap:break-word;

    word-break:normal;

}


/*=========================================================
STICKY PRODUCT HEADER
=========================================================*/

.spi-table-sticky thead .spi-sticky-product{

    z-index:49;

    background:#ffffff;

    border-right:1px solid #d8dee8;

    box-shadow:
        8px 0 14px -12px rgba(15,23,42,.45);

}


/*=========================================================
STICKY PRODUCT AS FIRST COLUMN
=========================================================*/

.spi-table-sticky .spi-sticky-product-first{

    left:0 !important;

}


/*=========================================================
STICKY PRODUCT FIRST HEADER
=========================================================*/

.spi-table-sticky thead .spi-sticky-product-first{

    left:0 !important;

    z-index:50;

}


/*=========================================================
PRODUCT CONTENT
=========================================================*/

.spi-table-sticky .spi-sticky-product strong{

    display:block;

    line-height:1.45;

    margin-bottom:4px;

}


/*=========================================================
STICKY STRIPED ROW - EVEN
=========================================================*/

.spi-table-sticky.spi-table-striped
tbody tr:nth-child(even)
.spi-sticky-no,

.spi-table-sticky.spi-table-striped
tbody tr:nth-child(even)
.spi-sticky-product{

    background:#fafafa;

}


/*=========================================================
STICKY STRIPED ROW - ODD
=========================================================*/

.spi-table-sticky.spi-table-striped
tbody tr:nth-child(odd)
.spi-sticky-no,

.spi-table-sticky.spi-table-striped
tbody tr:nth-child(odd)
.spi-sticky-product{

    background:#ffffff;

}


/*=========================================================
STICKY HOVER
=========================================================*/

.spi-table-sticky tbody tr:hover
.spi-sticky-no,

.spi-table-sticky tbody tr:hover
.spi-sticky-product{

    background:#f8fafc;

}


/*=========================================================
ACTIVE STICKY ROW
=========================================================*/

.spi-table tbody tr.active
.spi-sticky-no,

.spi-table tbody tr.active
.spi-sticky-product{

    background:#dbeafe;

}


/*=========================================================
STICKY PRODUCT EDGE
=========================================================*/

.spi-table-sticky .spi-sticky-product::after{

    content:"";

    position:absolute;

    top:0;
    right:-1px;
    bottom:0;

    width:1px;

    background:#d8dee8;

    pointer-events:none;

}


/*=========================================================
SCROLLBAR - CHROME / EDGE / SAFARI
=========================================================*/

.spi-table-scroll::-webkit-scrollbar{

    width:10px;

    height:10px;

}


.spi-table-scroll::-webkit-scrollbar-track{

    background:#f1f5f9;

}


.spi-table-scroll::-webkit-scrollbar-thumb{

    background:#cbd5e1;

    border-radius:999px;

    border:2px solid #f1f5f9;

}


.spi-table-scroll::-webkit-scrollbar-thumb:hover{

    background:#94a3b8;

}


/*=========================================================
RESPONSIVE
=========================================================*/

@media(max-width:768px){

    .spi-table{

        min-width:720px;

    }


    .spi-table-scroll{

        max-height:560px;

    }


    /*
    =====================================================
    STICKY NUMBER
    =====================================================
    */

    .spi-table-sticky .spi-sticky-no{

        width:48px;
        min-width:48px;
        max-width:48px;

    }


    /*
    =====================================================
    PRODUCT AFTER NUMBER
    =====================================================
    */

    .spi-table-sticky .spi-sticky-product{

        left:48px;

        width:180px;
        min-width:180px;
        max-width:180px;

    }


    /*
    =====================================================
    PRODUCT AS FIRST COLUMN
    =====================================================
    */

    .spi-table-sticky
    .spi-sticky-product.spi-sticky-product-first{

        left:0 !important;

    }


    /*
    =====================================================
    CELL PADDING
    =====================================================
    */

    .spi-table thead th,
    .spi-table tbody td{

        padding:14px 16px;

    }

}


/*=========================================================
SMALL MOBILE
=========================================================*/

@media(max-width:480px){

    .spi-table{

        min-width:680px;

    }


    .spi-table-scroll{

        max-height:500px;

    }


    .spi-table-sticky .spi-sticky-no{

        width:44px;
        min-width:44px;
        max-width:44px;

    }


    .spi-table-sticky .spi-sticky-product{

        left:44px;

        width:165px;
        min-width:165px;
        max-width:165px;

    }


    .spi-table-sticky
    .spi-sticky-product.spi-sticky-product-first{

        left:0 !important;

    }


    .spi-table thead th,
    .spi-table tbody td{

        padding:12px 14px;

        font-size:13px;

    }

}