/* Hide summary row heading text "สรุป" but keep the cell for layout */
.fi-ta-summary-row-heading-cell {
    visibility: hidden;
    font-size: 0;
}
.fi-ta-summary-row-heading-cell * {
    visibility: hidden;
}

/* Topbar dropdown menu items styling */
.fi-topbar-item {
    transition: all 0.2s ease;
}

.fi-topbar-item-btn {
    transition: all 0.2s ease;
    color: rgb(107 114 128);
    text-align: center;
    font-size: 0.875rem;
    line-height: 1.25rem;
    min-height: 128px;
    width: 100%;
}

.fi-topbar-item-btn:hover {
    background-color: rgb(243 244 246);
    color: rgb(17 24 39);
}

.dark .fi-topbar-item-btn {
    color: rgb(156 163 175);
}

.dark .fi-topbar-item-btn:hover {
    background-color: rgb(31 41 55);
    color: rgb(243 244 246);
}

.fi-topbar-item.fi-active .fi-topbar-item-btn {
    background-color: rgb(251 191 36);
    color: rgb(17 24 39);
}

.dark .fi-topbar-item.fi-active .fi-topbar-item-btn {
    background-color: rgb(217 119 6);
    color: rgb(255 255 255);
}

/* Icon styling in topbar items */
.fi-topbar-item-btn .fi-icon {
    color: inherit;
}

.fi-topbar-item-btn:hover .fi-icon {
    color: inherit;
}

/* แก้ไขสำหรับข้อความไทยใน sidebar - ใช้ font rendering ที่ดี */
.fi-sidebar-header > div,
.fi-sidebar-item-btn,
.fi-sidebar-group-label {
    text-rendering: optimizeLegibility !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* ทำให้ตารางแคบลง - ความสูงเซลล์ข้อความ 46px */
.fi-ta-text:not(.fi-inline),
.fi-size-sm.fi-ta-text-item.fi-ta-text {
    font-size: 0.875rem !important;
    line-height: 1.375 !important;
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
    min-height: 46px !important;
    display: flex !important;
    align-items: center !important;
}

/* alignEnd / alignCenter ต้องทำงานร่วมกับ flex ด้านบน */
.fi-ta-text.fi-align-end {
    justify-content: flex-end !important;
    text-align: end !important;
}
.fi-ta-text.fi-align-center {
    justify-content: center !important;
    text-align: center !important;
}

/* header cell + data cell alignment */
.fi-ta-header-cell.fi-align-end {
    text-align: end !important;
}
.fi-ta-header-cell.fi-align-center {
    text-align: center !important;
}
.fi-ta-cell.fi-align-end .fi-ta-col {
    justify-content: flex-end !important;
    text-align: end !important;
}
.fi-ta-cell.fi-align-center .fi-ta-col {
    justify-content: center !important;
    text-align: center !important;
}

.fi-ta-cell:has(.fi-ta-actions),
.fi-ta-cell:has(.fi-ta-record-checkbox) {
    padding-top: 0.7rem !important;
    padding-bottom: 0.7rem !important;
}

/* Header ของตาราง */
.fi-ta-header-cell {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

/* Sidebar แคบลง */
.fi-sidebar-item-btn {
    padding-top: 0.4rem !important;
    padding-bottom: 0.4rem !important;
}

.fi-sidebar-group-btn {
    padding-top: 0.4rem !important;
    padding-bottom: 0.4rem !important;
}

/* Form fields แคบลง */
.fi-fo-field-wrp {
    margin-bottom: 0.75rem !important;
}

.fi-input-wrp {
    min-height: 2.25rem !important;
}

/* Section แคบลง */
.fi-section-content {
    padding: 0.75rem !important;
}

/* Header ของหน้าแคบลง */
.fi-header {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
}

/* Pagination แคบลง */
.fi-ta-pagination {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

/* Main content แคบลง */
.fi-main {
    padding: 0.75rem !important;
}

@media (min-width: 640px) {
    .fi-main {
        padding: 1rem !important;
    }
}

/* Main container */
.fi-main-ctn {
    gap: 0.5rem !important;
}

/* ลดช่องว่างระหว่าง header กับ content */
.fi-page > * + * {
    margin-top: 0.5rem !important;
}

.fi-header + * {
    margin-top: 0.5rem !important;
}

/* Table container */
.fi-ta-ctn {
    gap: 0 !important;
}

.fi-ta-header-ctn {
    padding: 0.5rem 0.75rem !important;
}

/* ลด padding ของ search box */
.fi-ta-header-toolbar {
    padding: 0.5rem !important;
}

/* ลดระยะห่างใน card/section */
.fi-section {
    gap: 0 !important;
}

.fi-section-header {
    padding: 0.5rem 0.75rem !important;
}

/* ลดช่องว่างหลัก */
.fi-body {
    padding-top: 0 !important;
}

.fi-ta-content-ctn {
    border-top: 0 !important;
}

/* ลด gap ของ page */
.fi-page {
    gap: 0.5rem !important;
}

/* Breadcrumb */
.fi-breadcrumbs {
    margin-bottom: 0.25rem !important;
}

/* ลดช่องว่างระหว่าง header กับ table */
.fi-resource-page > .fi-page > * {
    margin-top: 0.25rem !important;
}

.fi-wi-stats-overview, 
.fi-ta, 
.fi-section {
    margin-top: 0.5rem !important;
}

/* Stats overview - ป้องกันตัวเลขล้นขอบ ให้ card ขยายสมดุลกัน */
.fi-wi-stats-overview .fi-section-content > .fi-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)) !important;
}
.fi-wi-stats-overview-stat {
    min-width: 0;
}
.fi-wi-stats-overview-stat-value {
    overflow-wrap: break-word;
    word-break: break-word;
    position: relative;
    z-index: 2;
}
.fi-wi-stats-overview-stat-description {
    overflow-wrap: break-word;
    word-break: break-word;
    position: relative;
    z-index: 2;
}
/* แก้กราฟ sparkline บังตัวเลข - ลดความสูงและลด opacity */
.fi-wi-stats-overview-stat-chart {
    max-height: 3rem;
    opacity: 0.5;
    z-index: 1;
}

/* ลด padding ใน table container */
.fi-ta-ctn > div:first-child {
    padding: 0.5rem !important;
}

/* ลดช่องว่างระหว่าง topbar กับ content */
.fi-topbar + div {
    padding-top: 0 !important;
}

/* ลด margin-top ของ main content */
.fi-main > div:first-child {
    margin-top: 0 !important;
    padding-top: 0.5rem !important;
}

/* ลดช่องว่างระหว่าง header กับ table card */
.fi-header {
    margin-bottom: 0.5rem !important;
    padding-bottom: 0 !important;
}

/* ลด gap ของ simple page */
.fi-simple-page {
    padding-top: 0.5rem !important;
}

/* ลดช่องว่างบน body */
.fi-body > div {
    gap: 0 !important;
}

/* ช่องว่างระหว่าง topbar กับ breadcrumb */
.fi-main {
    padding-top: 0.25rem !important;
}

/* ช่องว่างระหว่าง header กับ table */
.fi-ta {
    margin-top: 0.25rem !important;
}

/* ลด padding ของ header wrapper */
.fi-header-heading {
    padding: 0 !important;
}

/* ลด gap ภายใน page */
[class*="fi-page"] > div {
    gap: 0.25rem !important;
}

/* ลดช่องว่างด้านบน breadcrumb */
.fi-breadcrumbs {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* ลด margin ของ header */
.fi-header {
    padding-top: 0.5rem !important;
    margin-top: 0 !important;
}

/* ลดช่องว่างระหว่าง header กับ table container */
.fi-ta-ctn {
    margin-top: 0 !important;
}

/* ลดช่องว่างด้านบนสุดของ main */
.fi-main {
    padding-top: 0 !important;
}

.fi-main > div {
    padding-top: 0.25rem !important;
}

/* ลดช่องว่างหลัง topbar */
.fi-topbar {
    margin-bottom: 0 !important;
}

/* Header ชิดบน */
.fi-header.fi-header-has-breadcrumbs {
    padding-top: 0.25rem !important;
    margin-top: 0.25rem !important;
}

.fi-page-header-main-ctn {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* Main container ไม่มี padding บน */
.fi-main-ctn {
    padding-top: 0 !important;
}

.fi-main > div:first-child {
    padding-top: 0 !important;
    margin-top: 0 !important;
}