/* ===== PROFESSIONAL TABLE STYLING ===== */
/* Table Container with Overflow Management */
.table-container {
    width: 100%;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
}

/* Modern Table Styling */
.modern-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.95rem;
    color: #333;
}

/* Table Header - Sticky with Professional Appearance */
.modern-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.modern-table thead th {
    padding: 6px 8px;
    text-align: left;
    color: white;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: none;
    white-space: nowrap;
    user-select: none;
}

.modern-table thead th:last-child {
    text-align: center;
    white-space: nowrap;
}

/* Table Body Styling */
.modern-table tbody {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
    display: block;
}

.modern-table thead {
    display: table;
    width: 100%;
    table-layout: fixed;
}

.modern-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.modern-table tbody tr:hover {
    background-color: #f8f9ff;
    box-shadow: inset 0 0 0 1px rgba(102, 126, 234, 0.1);
}

.modern-table tbody tr:last-child {
    border-bottom: none;
}

.modern-table tbody td {
    padding: 5px 8px;
    line-height: 1.2;
    vertical-align: middle;
    border: none;
    color: #555;
}

.modern-table tbody td:last-child {
    text-align: center;
}

/* Amount Cell Styling */
.modern-table .amount-cell {
    color: #2d5f2e;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Action Buttons Container */
.modern-table .action-btns {
    display: flex;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.modern-table .btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.modern-table .action-btn {
    padding: 2px 6px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.modern-table .action-btn.btn-primary {
    background-color: transparent;
    color: #0d6efd;
}

.modern-table .action-btn.btn-primary:hover {
    background-color: transparent;
    transform: none;
    box-shadow: none;
    opacity: 0.85;
}

.modern-table .action-btn.btn-danger {
    background-color: transparent;
    color: #dc3545;
}

.modern-table .action-btn.btn-danger:hover {
    background-color: transparent;
    transform: none;
    box-shadow: none;
    opacity: 0.85;
}

.modern-table .action-btn.btn-success {
    background-color: transparent;
    color: #198754;
}

.modern-table .action-btn.btn-success:hover {
    background-color: transparent;
    transform: none;
    box-shadow: none;
    opacity: 0.85;
}

.modern-table .action-btn.btn-info {
    background-color: transparent;
    color: #0dcaf0;
}

.modern-table .action-btn.btn-info:hover {
    background-color: transparent;
    transform: none;
    box-shadow: none;
    opacity: 0.85;
}

/* ===== GLOBAL COMPACT TABLES ===== */
/* Reduce row heights across Bootstrap tables without changing functionality */
table.table > :not(caption) > * > * {
    padding: 0.25rem 0.5rem;
    line-height: 1.2;
}

/* ===== ACTION COLUMN: TRANSPARENT BUTTONS + UNIFORM COLORS ===== */
/* Target common action containers used across the system. */
.action-btns .btn,
.action-btns .action-btn,
.action-buttons .btn,
.action-buttons .action-btn,
td.action-btns .btn,
td.action-btns .action-btn,
td.col-actions .btn,
td.col-actions .action-btn,
.controlled-drug-actions .btn,
.controlled-drug-actions .action-btn,
.drug-actions .btn,
.drug-actions .action-btn,
.refund-actions .btn,
.refund-actions .action-btn,
.cart-item-actions .btn,
.cart-item-actions .action-btn {
    background: transparent !important;
    background-image: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.action-btns .btn:hover,
.action-btns .action-btn:hover,
.action-buttons .btn:hover,
.action-buttons .action-btn:hover,
td.action-btns .btn:hover,
td.action-btns .action-btn:hover,
td.col-actions .btn:hover,
td.col-actions .action-btn:hover,
.controlled-drug-actions .btn:hover,
.controlled-drug-actions .action-btn:hover,
.drug-actions .btn:hover,
.drug-actions .action-btn:hover,
.refund-actions .btn:hover,
.refund-actions .action-btn:hover,
.cart-item-actions .btn:hover,
.cart-item-actions .action-btn:hover {
    opacity: 0.85;
}

/* Delete = red */
.action-btns .btn-danger,
.action-btns .btn-outline-danger,
.action-buttons .btn-danger,
.action-buttons .btn-outline-danger,
td.action-btns .btn-danger,
td.action-btns .btn-outline-danger,
td.col-actions .btn-danger,
td.col-actions .btn-outline-danger {
    color: #dc3545 !important;
}

/* Edit = blue (many templates use btn-warning for edit) */
.action-btns .btn-primary,
.action-btns .btn-outline-primary,
.action-btns .btn-warning,
.action-btns .btn-outline-warning,
.action-buttons .btn-primary,
.action-buttons .btn-outline-primary,
.action-buttons .btn-warning,
.action-buttons .btn-outline-warning,
td.action-btns .btn-primary,
td.action-btns .btn-outline-primary,
td.action-btns .btn-warning,
td.action-btns .btn-outline-warning,
td.col-actions .btn-primary,
td.col-actions .btn-outline-primary,
td.col-actions .btn-warning,
td.col-actions .btn-outline-warning {
    color: #0d6efd !important;
}

/* Info = sky blue */
.action-btns .btn-info,
.action-btns .btn-outline-info,
.action-buttons .btn-info,
.action-buttons .btn-outline-info,
td.action-btns .btn-info,
td.action-btns .btn-outline-info,
td.col-actions .btn-info,
td.col-actions .btn-outline-info {
    color: #0dcaf0 !important;
}

/* Add/Export = green */
.action-btns .btn-success,
.action-btns .btn-outline-success,
.action-buttons .btn-success,
.action-buttons .btn-outline-success,
td.action-btns .btn-success,
td.action-btns .btn-outline-success,
td.col-actions .btn-success,
td.col-actions .btn-outline-success {
    color: #198754 !important;
}

/* Responsive Tables - Hide actions on very small screens */
@media (max-width: 576px) {
    .modern-table thead th {
        padding: 12px 8px;
        font-size: 0.9rem;
    }
    
    .modern-table tbody td {
        padding: 10px 8px;
        font-size: 0.9rem;
    }
    
    .modern-table .action-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}

/* ===== MOBILE-FIRST STYLES ===== */
@media (max-width: 768px) {
    /* Make tables scroll horizontally */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Table Container Mobile */
    .table-container {
        border-radius: 6px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }
    
    /* Adjust form layout */
    .row.g-3 > [class^="col-"] {
        margin-bottom: 1rem;
    }
    
    /* Make buttons full width */
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Adjust card padding */
    .card-body {
        padding: 1rem;
    }
    
    /* Make navigation more compact */
    .navbar-brand {
        font-size: 1.1rem;
    }
}

/* Payroll Table Specific Styling */
#payroll-table thead th {
    padding: 10px 8px;
    font-size: 0.85rem;
    white-space: normal;
    word-break: break-word;
}

#payroll-table tbody tr {
    height: auto;
}

#payroll-table tbody td {
    padding: 8px 6px;
    font-size: 0.9rem;
    text-align: left;
    vertical-align: middle;
    word-break: break-word;
}

#payroll-table {
    table-layout: auto;
    min-width: 100%;
}

#payroll-table thead {
    display: table;
    width: 100%;
    table-layout: auto;
}

#payroll-table tbody {
    display: block;
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
}

#payroll-table tbody tr {
    display: table;
    width: 100%;
    table-layout: auto;
}

/* Column width adjustments for payroll table */
#payroll-table th:nth-child(1),
#payroll-table td:nth-child(1) {
    min-width: 40px;
    width: 3%;
}

#payroll-table th:nth-child(2),
#payroll-table td:nth-child(2) {
    min-width: 120px;
    width: 12%;
}

#payroll-table th:nth-child(3),
#payroll-table td:nth-child(3) {
    min-width: 100px;
    width: 10%;
}

#payroll-table th:nth-child(4),
#payroll-table td:nth-child(4) {
    min-width: 100px;
    width: 10%;
}

#payroll-table th:nth-child(5),
#payroll-table td:nth-child(5) {
    min-width: 100px;
    width: 10%;
}

#payroll-table th:nth-child(6),
#payroll-table td:nth-child(6) {
    min-width: 100px;
    width: 10%;
}

#payroll-table th:nth-child(7),
#payroll-table td:nth-child(7) {
    min-width: 100px;
    width: 10%;
}

#payroll-table th:nth-child(8),
#payroll-table td:nth-child(8) {
    min-width: 100px;
    width: 10%;
}

#payroll-table th:nth-child(9),
#payroll-table td:nth-child(9) {
    min-width: 100px;
    width: 10%;
}

#payroll-table th:nth-child(10),
#payroll-table td:nth-child(10) {
    min-width: 120px;
    width: 15%;
}

/* General improvements */
.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Make sure alerts are visible */
.alert {
    margin-bottom: 1rem;
}

/* Improve form input sizes */
.form-control, .form-select {
    padding: 0.375rem 0.75rem;
}

/* ===== GLOBAL FONT SIZE (SYSTEM-WIDE) ===== */
/* Force the entire system to use 9px text size. */
html, body {
    font-size: 9px !important;
}

/* Apply to all elements for consistent UI sizing across templates. */
body, body * {
    font-size: 9px !important;
}