/* ========================================
   SALES MANAGEMENT SYSTEM
   Table Standardization Stylesheet
   Brand Color: #fe0000 (Salesmedia Red)
   ======================================== */

/* Critical Override - Force Light Background on Table Headers */
table thead.table-header-modern,
table.table-standard thead.table-header-modern,
.table thead.table-header-modern {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    background-color: #f8f9fa !important;
}

table thead.table-header-modern th,
table.table-standard thead.table-header-modern th,
.table thead.table-header-modern th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    background-color: #f8f9fa !important;
    color: #6c757d !important;
}

/* Table Container */
.table-responsive {
    border-radius: 16px;
    overflow-x: auto;
    overflow-y: visible;
}

.table-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

/* Base Table */
.table-standard {
    margin-bottom: 0;
    width: 100%;
}

.table-standard th,
.table-standard td {
    padding: 1rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f3f5;
}

/* Modern Table Header */
.table-header-modern {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
}

.table-header-modern th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    text-transform: uppercase !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    color: #6c757d !important;
    letter-spacing: 0.5px !important;
    border-bottom: 2px solid #dee2e6 !important;
    padding: 1rem 0.75rem !important;
}

/* Override any dark/black background from other CSS */
.table-header-modern th,
.table.table-header-modern th,
thead.table-header-modern th {
    background-color: #f8f9fa !important;
    background-image: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
}

.table-header-modern th i {
    margin-right: 0.25rem;
    opacity: 0.7;
    color: #6c757d !important;
}

/* Table Row Hover */
.table-hover tbody tr {
    transition: all 0.3s ease;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f5;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transform: translateX(2px);
}

/* Improve table row spacing and borders */
.table-standard tbody tr {
    border-bottom: 1px solid #f1f3f5;
}

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

/* Action Buttons */
button.table-action-btn,
a.table-action-btn,
.table-action-btn {
    border-radius: 8px !important;
    padding: 0.4rem 0.75rem !important;
    font-weight: 500;
    font-size: 0.8rem !important;
    transition: all 0.3s ease;
    border-width: 2px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.25rem;
    min-height: 36px !important;
    max-height: 36px;
    min-width: 36px;
}

.btn-gradient-red {
    background: linear-gradient(135deg, #E50020 0%, #BC0000 100%);
    color: white !important;
    border: none;
    box-shadow: 0 2px 6px rgba(229, 0, 32, 0.2);
}

.btn-gradient-red:hover {
    background: linear-gradient(135deg, #BC0000 0%, #8B0000 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(229, 0, 32, 0.3);
    color: white !important;
}

.btn-outline-primary {
    color: #5e72e4;
    border-color: #5e72e4;
    background: transparent;
}

.btn-outline-primary:hover {
    background: #5e72e4;
    border-color: #5e72e4;
    color: white;
    transform: translateY(-2px);
}

.btn-outline-danger {
    color: #f5365c;
    border-color: #f5365c;
    background: transparent;
}

.btn-outline-danger:hover {
    background: #f5365c;
    border-color: #f5365c;
    color: white;
    transform: translateY(-2px);
}

/* Action Button Group */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
}

.action-buttons .btn,
.action-buttons button,
.action-buttons a {
    margin: 0 !important;
    min-height: 36px !important;
    max-height: 36px !important;
}

/* Status Badges */
.badge-custom {
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.3s ease;
}

.badge-custom:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.badge-gradient-role {
    background: linear-gradient(135deg, #ffd89b 0%, #ff6b6b 100%);
    color: #fff;
    box-shadow: 0 2px 4px rgba(255, 107, 107, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge-gradient-success {
    background: linear-gradient(135deg, #2dce89 0%, #23a570 100%);
    color: #fff;
    box-shadow: 0 2px 4px rgba(45, 206, 137, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge-gradient-warning {
    background: linear-gradient(135deg, #fb6340 0%, #d84315 100%);
    color: #fff;
    box-shadow: 0 2px 4px rgba(251, 99, 64, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge-gradient-info {
    background: linear-gradient(135deg, #11cdef 0%, #0da5c0 100%);
    color: #fff;
    box-shadow: 0 2px 4px rgba(17, 205, 239, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Number Badge */
.badge-number {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #344767;
    border: 1px solid #dee2e6;
    font-size: 0.875rem;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Empty State */
.table-empty-state {
    padding: 4rem 2rem;
    text-align: center;
}

.table-empty-state i {
    font-size: 3rem;
    color: #adb5bd;
    margin-bottom: 1rem;
    display: block;
    opacity: 0.6;
}

.table-empty-state p {
    color: #6c757d;
    font-size: 0.9rem;
    margin: 0;
}

.table-empty-state .empty-icon {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Search Box */
.table-search-box {
    margin-bottom: 1.5rem;
}

.table-search-box .input-group {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table-search-box .input-group-text {
    background: white;
    border-right: 0;
    padding: 0.75rem 1rem;
}

.table-search-box .form-control {
    border-left: 0;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

.table-search-box .form-control:focus {
    border-left: 0;
    box-shadow: none;
    border-color: #fe0000;
}

.table-search-box .input-group:focus-within {
    box-shadow: 0 4px 12px rgba(254, 0, 0, 0.15);
}

/* Loading Overlay */
.table-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 16px;
    backdrop-filter: blur(4px);
}

.table-loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* Export Buttons */
.export-buttons {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.export-buttons .btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-export-pdf {
    background: linear-gradient(135deg, #ea0606 0%, #BC0000 100%);
    color: white;
    border: none;
}

.btn-export-pdf:hover {
    background: linear-gradient(135deg, #BC0000 0%, #8B0000 100%);
    color: white;
    transform: translateY(-2px);
}

.btn-export-excel {
    background: linear-gradient(135deg, #2dce89 0%, #23a570 100%);
    color: white;
    border: none;
}

.btn-export-excel:hover {
    background: linear-gradient(135deg, #23a570 0%, #1a8056 100%);
    color: white;
    transform: translateY(-2px);
}

/* Table Filters */
.table-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.table-filter-item {
    flex: 1;
    min-width: 200px;
}

.table-filter-item label {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Pagination Styling */
.pagination {
    margin-top: 1.5rem;
    gap: 0.5rem;
}

.pagination .page-link {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    color: #344767;
    padding: 0.5rem 0.75rem;
    transition: all 0.3s ease;
}

.pagination .page-link:hover {
    background: #f8f9fa;
    border-color: #fe0000;
    color: #fe0000;
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #E50020 0%, #BC0000 100%);
    border-color: #E50020;
    color: white;
}

/* Table Info Text */
.table-info-text {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 1rem;
}

/* Responsive Design */
@media (max-width: 992px) {
    .table-container {
        padding: 1rem;
    }

    .action-buttons {
        flex-wrap: wrap;
    }

    .export-buttons {
        justify-content: center;
    }

    .table-filters {
        flex-direction: column;
    }

    .table-filter-item {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .table-standard th,
    .table-standard td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8125rem;
    }

    .table-header-modern th {
        font-size: 0.7rem;
        padding: 0.75rem 0.5rem;
    }
    
    button.table-action-btn,
    a.table-action-btn,
    .table-action-btn {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.75rem !important;
        min-height: 36px !important;
        max-height: 36px !important;
        min-width: 36px !important;
    }
    
    .action-buttons .btn,
    .action-buttons button,
    .action-buttons a {
        min-height: 36px !important;
        max-height: 36px !important;
    }

    .table-action-btn span {
        display: none;
    }

    .action-buttons {
        gap: 0.25rem;
    }

    .badge-custom {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }

    .table-empty-state {
        padding: 3rem 1rem;
    }

    .table-empty-state i {
        font-size: 2rem;
    }

    .table-search-box .input-group-text,
    .table-search-box .form-control {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 576px) {
    .table-container {
        padding: 0.75rem;
        border-radius: 12px;
    }

    .table-responsive {
        border-radius: 12px;
    }

    .table-header-modern th {
        font-size: 0.65rem;
        padding: 0.625rem 0.375rem;
    }

    .table-standard th,
    .table-standard td {
        padding: 0.625rem 0.375rem;
        font-size: 0.75rem;
    }

    .action-buttons {
        flex-direction: column;
        gap: 0.25rem;
        width: 100%;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .export-buttons {
        width: 100%;
    }

    .export-buttons .btn {
        flex: 1;
    }
}

/* Print Styles */
@media print {
    .table-action-btn,
    .export-buttons,
    .table-search-box,
    .table-filters {
        display: none !important;
    }

    .table-container {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }

    .table-standard {
        font-size: 10pt;
    }
}

/* Legacy Compatibility Utilities */
.table-gradient-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
}

.btn-red-gradient {
    background: linear-gradient(135deg, #E50020 0%, #BC0000 100%) !important;
    color: white !important;
    border: none !important;
}

.btn-red-solid {
    background-color: #fe0000 !important;
    color: white !important;
    border: none !important;
}

/* Icon-Only Button Touch Targets */
button.table-action-btn:not(:has(span)),
a.table-action-btn:not(:has(span)),
.table-action-btn.icon-only {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0.5rem !important;
}

@media (max-width: 768px) {
    button.table-action-btn:not(:has(span)),
    a.table-action-btn:not(:has(span)),
    .table-action-btn.icon-only {
        min-width: 44px !important;
        min-height: 44px !important;
    }
}

/* Dark Mode Support (if needed in future) */
@media (prefers-color-scheme: dark) {
    .table-container {
        background: #1a1a1a;
        color: #e0e0e0;
    }

    .table-header-modern {
        background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    }

    .table-header-modern th {
        color: #b0b0b0;
    }

    .table-hover tbody tr:hover {
        background-color: #2a2a2a;
    }

    .table-standard th,
    .table-standard td {
        border-bottom-color: #333;
    }

    .badge-number {
        background: #2a2a2a;
        color: #e0e0e0;
        border-color: #444;
    }
}
