/* Grid Optimization - Remove padding and maximize space */

/* Remove default body padding/margin */
body {
    margin: 0;
    padding: 0;
}

/* Maximize container width */
.container {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
}

/* Remove padding from container-fluid */
.container-fluid {
    padding-left: 15px !important;
    padding-right: 15px !important;
}

/* Optimize table responsive wrapper */
.table-responsive {
    width: 100%;
    margin-bottom: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #ddd;
}

/* Prevent horizontal scroll on body */
html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Table optimization */
.table {
    width: 100%;
    max-width: 100%;
    margin-bottom: 0;
}

/* Compact table cells */
.table > thead > tr > th,
.table > tbody > tr > td {
    padding: 8px 5px;
    vertical-align: middle;
    white-space: nowrap;
}

/* Action buttons alignment - inline, max 2 rows */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-start;
    align-items: center;
    max-width: 100%;
}

.action-buttons .btn {
    margin: 2px;
    flex: 0 0 auto;
}

/* Ensure action column buttons stay inline */
td .btn-group {
    display: inline-flex;
    gap: 5px;
    flex-wrap: wrap;
}

/* Compact button sizing for tables */
.table .btn-xs {
    padding: 2px 8px;
    font-size: 11px;
    line-height: 1.5;
    min-width: 60px;
}

/* Form inline optimization */
.form-inline .form-group {
    margin-right: 10px;
    margin-bottom: 5px;
}

.form-inline .btn {
    margin-bottom: 5px;
}

/* Panel optimization */
.panel {
    margin-bottom: 15px;
}

.panel-body {
    padding: 10px;
}

/* Search and filter section optimization */
.search-filter-section {
    margin-bottom: 15px;
}

.search-filter-section .row {
    margin-left: -5px;
    margin-right: -5px;
}

.search-filter-section .col-md-3,
.search-filter-section .col-md-4,
.search-filter-section .col-md-6,
.search-filter-section .col-md-8 {
    padding-left: 5px;
    padding-right: 5px;
}

/* Export section optimization */
.export-section .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.export-section .btn-group .btn {
    margin: 2px;
}

/* Pagination optimization */
.pagination {
    margin: 10px 0;
    flex-wrap: wrap;
}

.pagination > li > a,
.pagination > li > span {
    padding: 5px 10px;
    margin: 2px;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 1200px) {
    .table > thead > tr > th,
    .table > tbody > tr > td {
        padding: 6px 3px;
        font-size: 12px;
    }
    
    .table .btn-xs {
        padding: 1px 5px;
        font-size: 10px;
        min-width: 50px;
    }
}

@media (max-width: 992px) {
    .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    .table > thead > tr > th,
    .table > tbody > tr > td {
        padding: 5px 2px;
        font-size: 11px;
    }
}

@media (max-width: 768px) {
    .container {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }
    
    .panel-body {
        padding: 8px;
    }
    
    .form-inline .form-group {
        margin-right: 5px;
    }
}

/* Ensure buttons in action columns wrap properly */
td[colspan] .btn,
th[colspan] .btn {
    margin: 2px;
}

/* Status column optimization */
.label {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    white-space: nowrap;
}

/* Fix for action columns with multiple buttons */
tbody td:last-child,
tbody td:nth-last-child(2),
tbody td:nth-last-child(3) {
    white-space: normal;
    max-width: 180px;
}

/* Button group wrapper for actions */
.btn-action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: flex-start;
}

.btn-action-group .btn {
    flex: 0 0 auto;
    margin: 1px;
}
