/* Button Utilities - Small, Icon-Only, and Compact Styles */

/* Icon-only button helper classes */
.btn-icon {
    padding: 6px !important;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon i {
    margin: 0 !important;
    font-size: 12px;
    line-height: 1;
}

.btn-icon.btn-sm {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    padding: 4px !important;
}

.btn-icon.btn-sm i {
    font-size: 11px;
}

.btn-icon.btn-xs {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    padding: 3px !important;
}

.btn-icon.btn-xs i {
    font-size: 10px;
}

/* Hide text in icon-only buttons */
.btn-icon .btn-text,
.btn-icon span:not(.bi):not([class*="icon"]):not(.sr-only) {
    display: none !important;
}

/* Auto-detect and style buttons with only icons (no visible text) */
.btn:has(i:only-child),
.btn:has(> i:only-child),
.btn:has(i:not(:has(+ *)):not(:has(~ *:not(.sr-only)))) {
    padding: 6px !important;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
}

.btn:has(i:only-child) i,
.btn:has(> i:only-child) i {
    margin: 0 !important;
    font-size: 12px;
}

/* Table action buttons - make them smaller and icon-only where possible */
.table .btn {
    padding: 4px 8px;
    font-size: 10px;
    min-height: 24px;
}

.table .btn:has(i:only-child),
.table .btn:has(> i:only-child) {
    padding: 4px !important;
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
}

.table .btn-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    padding: 4px !important;
}

/* Common action button patterns - make them compact */
.btn-edit,
.btn-delete,
.btn-view,
.btn-print,
.btn-download,
.btn-upload,
.btn-save,
.btn-cancel {
    padding: 4px 8px;
    font-size: 10px;
    min-height: 24px;
}

/* Action buttons in tables - prefer icon-only */
.table .action-buttons .btn,
.table td .btn,
.table th .btn {
    margin: 0 2px;
    padding: 4px 6px;
    font-size: 10px;
}

/* Ensure buttons in action columns are compact */
.action-buttons .btn,
.btn-group .btn {
    margin: 0 2px;
}

/* Button groups - tighter spacing */
.btn-group-sm > .btn,
.btn-group > .btn-sm {
    padding: 4px 8px;
    font-size: 10px;
}

/* Prevent button text overflow */
.btn {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Tooltip support for icon-only buttons */
.btn-icon[title],
.btn-icon[data-bs-toggle="tooltip"],
.btn[title]:has(i:only-child) {
    cursor: pointer;
}

/* Make buttons with icons and minimal text more compact */
.btn i + span,
.btn i + .btn-text {
    margin-left: 4px;
    font-size: 10px;
}

/* Ensure buttons don't override each other */
.btn {
    position: relative;
    z-index: 1;
}

.btn:focus {
    z-index: 2;
}

.btn-group .btn {
    position: relative;
}

/* Button sizes - Action buttons should be clearly visible */
.btn-lg {
    padding: 8px 16px;
    font-size: 12px;
    min-height: 32px;
}

.btn {
    padding: 6px 12px;
    font-size: 11px;
    min-height: 28px;
}

/* Table action buttons - make them more visible */
.table .btn,
.table td .btn,
.table th .btn {
    padding: 5px 10px !important;
    font-size: 11px !important;
    min-height: 28px !important;
    margin: 0 !important;
    white-space: nowrap;
}

/* Action buttons wrapper in tables */
.table td .action-buttons {
    display: inline-flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
}

.table td .action-buttons .btn {
    padding: 5px 10px !important;
    font-size: 11px !important;
    min-height: 28px !important;
    margin: 0 !important;
    white-space: nowrap;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 11px;
    min-height: 28px;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 10px;
    min-height: 24px;
}

/* Action button groups - keep buttons adjacent */
.action-buttons,
.btn-action-group {
    display: inline-flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
}

.action-buttons .btn,
.btn-action-group .btn {
    margin: 0 !important;
    flex-shrink: 0;
    padding: 5px 10px;
}

/* Ensure action buttons in tables are visible and grouped */
.table td .action-buttons,
.table td .btn-action-group {
    display: inline-flex;
    gap: 4px;
    flex-wrap: nowrap;
}

/* Make sure buttons don't wrap in action columns */
.table td:last-child,
.table th:last-child {
    white-space: nowrap;
    width: auto;
    min-width: fit-content;
}

