﻿/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: auto;
    padding: var(--spacing-lg) var(--spacing-xl) 0 var(--spacing-xl);
}

/* ========== PAGE HEADER ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /*margin-bottom: var(--spacing-md);*/
    position: sticky;
    top: 0;
    background: var(--color-white);
    z-index: var(--z-footer);
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: 0;
}

.page-title-block h1 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-semibold);
    margin-bottom: 4px;
    letter-spacing: var(--letter-spacing-default);
    line-height: calc(var(--font-size-lg) * var(--line-height-tight));
}

.page-subtitle {
    font-size: var(--font-size-md);
    color: var(--color-text-tertiary);
}

/* ========== CONTENT HEADER ========== */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-xs);
    /*position: sticky;*/
    top: 135px;
    background: var(--color-white);
    z-index: var(--z-header);
}

.content-title {
    font-size: var(--font-size-sm);
    letter-spacing: var(--letter-spacing-default);
    line-height: calc(var(--font-size-lg) * var(--line-height-tight));
}

.content-action {
    display: flex;
    align-items: center;
    gap: var(--spacing-8);
}

.btn-filter {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--color-white);
    border: 1px solid var(--color-border-secondary);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    cursor: pointer;
}

    .btn-filter:hover {
        background-color: #f2f2f2;
    }
/* ========== TABLE CONTAINER WITH CUSTOM SCROLLBAR ========== */
.table-container {
    overflow: visible;
    position: relative;
    background: var(--color-white);
    flex: 1;
    display: flex;
    flex-direction: column;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-20);
    letter-spacing: var(--letter-spacing-default);
}

.dataTables_wrapper {
    overflow: visible !important;
    width: 100% !important;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Wrapper with border */
.dataTables_scroll {
    border-radius: 12px;
    border: 1px solid var(--color-border-secondary);
    overflow: hidden;
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ========== HIDE DEFAULT VERTICAL SCROLLBAR ========== */
.dataTables_scrollBody {
    overflow-y: scroll !important;
    overflow-x: scroll !important;
    max-height: calc(100vh - 300px);
    border-radius: 0 0 12px 12px;
    padding-bottom: 10px;
    margin-bottom: -20px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

    /* Hide vertical scrollbar for WebKit browsers */
    .dataTables_scrollBody::-webkit-scrollbar:vertical {
        display: none;
    }

    /* Keep horizontal scrollbar visible */
    .dataTables_scrollBody::-webkit-scrollbar:horizontal {
        height: 12px;
    }

    .dataTables_scrollBody::-webkit-scrollbar-track:horizontal {
        background: var(--color-bg-secondary);
    }

    .dataTables_scrollBody::-webkit-scrollbar-thumb:horizontal {
        background: var(--color-border-secondary);
        border-radius: 6px;
        border: 2px solid var(--color-bg-secondary);
    }

        .dataTables_scrollBody::-webkit-scrollbar-thumb:horizontal:hover {
            background: var(--color-text-secondary);
        }

/* ========== CUSTOM VERTICAL SCROLLBAR OUTSIDE TABLE ========== */
.custom-vertical-scrollbar {
    position: absolute;
    right: -16px; /* Position outside table */
    top: 0;
    width: 6px;
    height: 100%;
    background: transparent;
    z-index: 100;
    pointer-events: none;
}

.custom-vertical-scrollbar-track {
    position: absolute;
    right: 0;
    top: 4px;
    bottom: 4px;
    width: 8px;
    background: #F2F2F2;
    border-radius: 3px;
}

.custom-vertical-scrollbar-thumb {
    position: absolute;
    right: 0;
    top: 4px; /* Initial position */
    width: 8px;
    background: #BDBDBD;
    border-radius: 3px;
    cursor: pointer;
    pointer-events: all;
    transition: background 0.2s ease;
    will-change: top; /* Performance optimization */
}

    .custom-vertical-scrollbar-thumb:hover {
        background: #656668;
    }

    .custom-vertical-scrollbar-thumb:active {
        background: #757575;
    }

/* ========== HEADER ========== */
.dataTables_scrollHead {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    overflow: hidden;
    background: var(--color-bg-tertiary) !important;
}

    .dataTables_scrollHead > div,
    .dataTables_scrollHeadInner,
    .dataTables_scrollHead table {
        background: var(--color-bg-tertiary) !important;
    }

    .dataTables_scrollHead .dataTables_scrollHeadInner {
        background: var(--color-table-header) !important;
    }

/* Custom scrollbar container */
.custom-scrollbar {
    width: 100%;
    height: 8px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
    overflow: hidden;
    position: sticky;
    bottom: 0;
}

.custom-scrollbar-thumb {
    height: 100%;
    background: #BDBDBD;
    border-radius: var(--radius-sm);
    cursor: grab;
    position: absolute;
    left: 0;
    transition: background 0.2s;
}

    .custom-scrollbar-thumb:hover {
        background: #656668;
    }

    .custom-scrollbar-thumb:active {
        cursor: grabbing;
        background: #656668;
    }

.custom-scrollbar-thumb,
.custom-vertical-scrollbar-thumb {
    touch-action: none; /* Prevents browser touch gestures */
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on mobile */
}

/* Make thumbs slightly larger on touch devices for easier grabbing */
@media (hover: none) and (pointer: coarse) {
    .custom-scrollbar-thumb {
        height: 8px; /* Slightly taller on touch devices */
    }

    .custom-vertical-scrollbar-thumb {
        width: 8px; /* Slightly wider on touch devices */
    }
}

.dataTables_scrollHead {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    overflow: hidden;
    background: var(--color-table-header) !important; /* ✅ Add this - matches thead */
}

    /* Make sure the scrollhead inner div also has background */
    .dataTables_scrollHead > div,
    .dataTables_scrollHeadInner {
        background: var(--color-bg-tertiary) !important;
    }

    /* Also make sure the table inside has the same background */
    .dataTables_scrollHead table {
        background: var(--color-bg-tertiary) !important;
    }

    /* Ensure the wrapper div has the background too */
    .dataTables_scrollHead .dataTables_scrollHeadInner {
        background: var(--color-table-header) !important;
    }

table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: var(--color-white);
}


/* Remove sticky from thead since DataTables handles it */
thead {
    position: relative;
    z-index: var(--z-sticky);
}

th {
    text-align: left;
    padding: var(--spacing-sm) var(--spacing-lg);
    color: var(--color-black);
    border-bottom: 1px solid var(--color-border-secondary);
    background: var(--color-table-header);
    font-size: var(--font-size-sm);
    font-weight: 600;
    letter-spacing: var(--letter-spacing-default);
    line-height: var(--line-height-20);
}

td {
    padding: var(--spacing-sm) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border-secondary);
    vertical-align: middle;
}

tbody tr:hover td {
    background: var(--color-bg-secondary);
}

/* highlight row ตอน view */
tr.row-view-active td, tr.selected td {
    background: var(--color-dlb-hover);
}

.cell {
    display: flex;
    flex-direction: column;
}

.cell-primary {
    color: var(--color-text-primary);
    line-height: var(--line-height-loose);
}

.cell-secondary {
    color: var(--color-text-light);
    line-height: var(--line-height-loose);
}

.btn-view {
    color: var(--color-primary);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--font-size-base);
    letter-spacing: var(--letter-spacing-default);
    line-height: calc(var(--font-size-lg) * var(--line-height-tight));
}

/* ========== PAGINATION ========== */
.table-footer {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    color: var(--color-text-quaternary);
    /*padding: var(--spacing-lg) 0;*/
    padding-bottom: 0;
    background: var(--color-white);
    font-size: var(--font-size-base);
    letter-spacing: var(--letter-spacing-default);
    line-height: calc(var(--font-size-lg) * var(--line-height-tight));
}

.custom-pagination {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
}

.pagination-controls {
    display: flex;
    gap: var(--spacing-2xl);
    align-items: center;
}

.rows-per-page {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.rows-select {
    padding: var(--spacing-xs) var(--spacing-md);
    border: 1px solid var(--color-border-secondary);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    max-height: 30px;
}

.pagination {
    display: flex;
    gap: var(--spacing-xs);
}

.page-btn {
    min-width: var(--button-md);
    height: var(--button-md);
    /*padding: 6px var(--spacing-md);*/
    border: 1px solid var(--color-border-secondary);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    font-size: var(--font-size-sm);
    color: #1c1c1c;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .page-btn.active {
        background: var(--color-success);
        color: var(--color-white);
        border-color: var(--color-success);
    }

    .page-btn:hover:not(.active):not([disabled]) {
        background: var(--color-bg-secondary);
    }

    .page-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
    }

.footer-info {
    /*    font-size: var(--font-size-base);*/
}

.jump-to-page {
    width: 80px;
    padding: var(--spacing-xs) var(--spacing-md);
    border: 1px solid var(--color-border-secondary);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    text-align: center;
}

    .jump-to-page:focus {
        outline: none;
        border-color: var(--color-primary);
    }

.page-btn[data-page="first"] img {
    rotate: 90deg;
}

.page-btn[data-page="last"] img {
    rotate: -90deg;
}

/* Icon styling for first/last buttons */
.page-btn[data-page="first"] img,
.page-btn[data-page="last"] img {
    width: 12px;
    height: 12px;
    display: block;
}

/* Ensure button has proper padding */
.page-btn[data-page="first"],
.page-btn[data-page="last"] {
    /*padding: 6px 12px;*/
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== JUMP TO PAGE WITH ARROWS ========== */
.jump-to-page-container {
    position: relative;
    display: inline-block;
}

.jump-to-page {
    width: 80px;
    height: 32px;
    padding: 6px 28px 6px 12px;
    border: 1px solid var(--color-border-secondary);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-text-primary);
    text-align: center;
    max-height: 30px;
}

    .jump-to-page:focus {
        outline: none;
        border-color: var(--color-primary);
    }

    .jump-to-page::-webkit-outer-spin-button,
    .jump-to-page::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    .jump-to-page[type=number] {
        -moz-appearance: textfield;
    }

.jump-arrows {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.jump-arrow {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-white);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.jump-arrow-up {
    rotate: 180deg;
}

.jump-arrow-down {
    rotate: 0deg;
}

.jump-arrow:hover:not(:disabled) {
    background: var(--color-bg-hover);
}

.jump-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ✅ Icon styling */
.jump-arrow img {
    width: 12px;
    height: 12px;
    display: block;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.jump-arrow:hover:not(:disabled) img {
    opacity: 1;
}

/* บังคับไม่ให้คอลัมน์ยืด */
table {
    table-layout: fixed;
    width: 100%;
}

    /* คุมความกว้าง + ตัดข้อความ */
    table th,
    table td {
        min-width: 20px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

td.dtfc-fixed-left {
    background-color: var(--color-white);
}

table .badge {
    margin: auto;
}

.content {
    display: flex;
    flex-direction: column;
}

.table-footer {
    margin-top: auto;
    position: sticky;
    bottom: 0;
}

.invisable-pagination-desc .footer-info {
    display: none !important;
}

.invisible-custom-vertical-scrollbar .custom-vertical-scrollbar {
    display: none !important;
}

.invisible-custom-vertical-scrollbar .dataTables_scrollBody {
    max-height: unset;
}

.invisible-page-size .page-size {
    display: none !important;
}

.table-item-container {
    border: 1.5px solid var(--color-border-secondary);
    border-radius: var(--radius-12);
    padding: 24px 16px;
    overflow:visible;
}

.b-t-l-r{
    border-top-left-radius: 12px !important;
}

.b-t-r-r {
    border-top-right-radius: 12px !important;
}
