/**
 * Bootstrap Enhanced Table Styles
 * - Horizontal scroll with mouse drag
 * - Touch swipe for mobile
 * - Filter row
 * - Action button groups
 * - Dropdown menu in header
 */

/* ===== HEADER DROPDOWN MENU ===== */
.index-header {
    position: relative;
    z-index: 100;
}

.index-header h2 {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

/* Dropdown wrapper */
.index-header .dropdown {
    position: relative;
}

/* Hide dropdown menu by default */
.index-header .dropdown-menu {
    display: none;
}

/* Show dropdown when Bootstrap adds 'show' class */
.index-header .dropdown-menu.show {
    display: block;
}

/* Icon button inline with title */
.index-header h2 .btn-link {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    transition: all 0.3s ease;
    padding: 0 !important;
}

.index-header h2 .btn-link:hover {
    color: #667eea !important;
    transform: scale(1.1);
}

.index-header h2 .btn-link:focus {
    box-shadow: none !important;
    outline: none !important;
}

.index-header h2 .btn-link i {
    font-size: 1.5rem;
}

/* Hide default dropdown toggle arrow */
.index-header .dropdown-toggle::after {
    display: none !important;
}

.dropdown-menu {
    min-width: 250px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px 0;
    margin-top: 8px !important;
    z-index: 1050;
}

.dropdown-header {
    font-weight: 600;
    color: #667eea;
    padding: 12px 16px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-divider {
    margin: 8px 0;
    border-color: #e0e0e0;
}

.dropdown-item {
    padding: 10px 16px;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #333;
}

.dropdown-item:hover {
    background: linear-gradient(to right, #f8f9fa, #e9ecef);
    padding-left: 24px;
    color: #667eea;
}

.dropdown-item:active {
    background-color: #667eea;
    color: white;
}

.dropdown-item i {
    width: 20px;
    margin-right: 10px;
    color: #667eea;
    font-size: 14px;
}

/* ===== HORIZONTAL SCROLLABLE TABLE ===== */
.table-scroll-wrapper {
    position: relative;
    overflow-x: auto;
    overflow-y: visible;
    cursor: grab;
    user-select: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    margin-bottom: 1.5rem;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.table-scroll-wrapper:active {
    cursor: grabbing;
}

.table-scroll-wrapper.dragging {
    cursor: grabbing;
    scroll-behavior: auto;
}

/* Custom scrollbar */
.table-scroll-wrapper::-webkit-scrollbar {
    height: 10px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Scroll indicators */
.scroll-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(102, 126, 234, 0.9);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.scroll-indicator.left {
    left: 10px;
}

.scroll-indicator.right {
    right: 10px;
}

.table-scroll-wrapper:hover .scroll-indicator {
    opacity: 1;
}

.table-scroll-wrapper.at-start .scroll-indicator.left,
.table-scroll-wrapper.at-end .scroll-indicator.right {
    opacity: 0 !important;
}

/* Enhanced table styles */
.table-enhanced {
    margin-bottom: 0;
    white-space: nowrap;
    border-collapse: separate;
    border-spacing: 0;
}

.table-enhanced thead th {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    padding: 1rem 0.75rem;
    border: none;
    z-index: 5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-enhanced tbody tr {
    transition: all 0.2s;
}

.table-enhanced tbody tr:hover {
    background-color: #f8f9fa;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.table-enhanced tbody td {
    padding: 0.875rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #e9ecef;
}

/* ===== FILTER ROW ===== */
.filter-row {
    background: #f8f9fa;
    position: sticky;
    top: 48px;
    z-index: 4;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.filter-row th {
    padding: 0.5rem;
    border-bottom: 2px solid #dee2e6;
    background: #e9ecef !important;
}

.filter-input {
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.filter-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    outline: none;
}

.filter-input::placeholder {
    color: #6c757d;
    font-style: italic;
}

/* Filter active indicator */
.filter-input.has-value {
    border-color: #667eea;
    background-color: #fff;
    font-weight: 500;
}

/* Clear filter button */
.clear-filter {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: none;
}

.filter-input.has-value + .clear-filter {
    display: block;
}

.clear-filter:hover {
    color: #dc3545;
}

/* ===== ACTION BUTTON GROUPS ===== */
.action-buttons {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    white-space: nowrap;
}

/* Table row with floating actions */
/* Table rows need relative positioning for absolute buttons */
.table tbody tr {
    position: relative;
}

.table-row-with-actions {
    position: relative;
}

/* New hover-based action buttons - Floating on right side */
.action-buttons-hover {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%) translateX(-10px);
    display: inline-flex;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Hide the td that contains action buttons */
td:has(.action-buttons-hover) {
    width: 0;
    padding: 0;
    border: none;
    overflow: visible;
}

tbody tr:hover .action-buttons-hover, tbody tr:hover td .action-buttons-hover { opacity: 1 !important; visibility: visible !important; transform: translateY(-50%) translateX(0) !important; }

.btn-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #2c3e50;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-action-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    color: white;
}

.btn-action-icon i {
    font-size: 14px;
}

/* Edit button - Yellow/Orange */
.btn-edit-icon {
    background: #f39c12;
}

.btn-edit-icon:hover {
    background: #e67e22;
}

/* Delete button - Red */
.btn-delete-icon {
    background: #e74c3c;
}

.btn-delete-icon:hover {
    background: #c0392b;
}

/* View/Plus button - Blue */
.btn-view-icon {
    background: #3498db;
}

.btn-view-icon:hover {
    background: #2980b9;
}

/* Actions column styling */
td.actions {
    text-align: center;
    vertical-align: middle;
    min-width: 120px;
}

/* Old button styles - kept for backward compatibility */
.btn-action {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    border: 1px solid transparent;
}

.btn-action i {
    font-size: 0.875rem;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-view {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
}

.btn-view:hover {
    background: linear-gradient(135deg, #138496, #117a8b);
    color: white;
}

.btn-edit {
    background: linear-gradient(135deg, #ffc107, #ff9800);
    color: #212529;
}

.btn-edit:hover {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: #212529;
}

.btn-delete {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.btn-delete:hover {
    background: linear-gradient(135deg, #c82333, #bd2130);
    color: white;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .table-enhanced thead th {
        font-size: 0.75rem;
        padding: 0.75rem 0.5rem;
    }
    
    .table-enhanced tbody td {
        font-size: 0.875rem;
        padding: 0.75rem 0.5rem;
    }
    
    .btn-action {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .btn-action span {
        display: none; /* Hide text, show icon only on mobile */
    }
    
    .filter-input {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .scroll-indicator {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }
}

/* Loading overlay */
.table-loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* No data message */
.no-data-message {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
    font-size: 1.1rem;
}

.no-data-message i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Badge styles for status columns */
.badge-status {
    padding: 0.35em 0.65em;
    font-size: 0.875em;
    font-weight: 600;
    border-radius: 0.25rem;
}

