/* ====================================================================
 * STICKY TABLE COLUMNS SYSTEM
 * ====================================================================
 * Zentrales System für sticky Spalten in allen Bootstrap 5 Tabellen
 * 
 * Verwendung:
 * 1. Wrapper: <div class="fm-sticky-table">
 * 2. Team-Spalte: <td class="fm-sticky-column fm-team-cell">
 * 3. Rank-Spalte: <td class="fm-rank-column">
 * 
 * Features:
 * - Sticky Vereinsspalte beim horizontalen Scrollen
 * - Responsive: Mobile zeigt nur Logo, Desktop Logo + Name
 * - Einheitlicher Hover-Effekt über alle Spalten
 */

/* ====================================================================
 * Base Configuration
 * ====================================================================*/
:root {
    --sticky-column-bg: var(--bs-body-bg, #fff);
    --sticky-column-shadow: 2px 0 2px -1px rgba(0, 0, 0, 0.1);
    --sticky-column-z-index: 3;
}

/* Override Bootstrap's border-width globally for sticky tables */
.fm-sticky-table {
    --bs-border-width: 0 !important;
}

/* ====================================================================
 * Sticky Table Container
 * ====================================================================*/
.fm-sticky-table {
    position: relative;
    isolation: isolate;
}

.fm-sticky-table .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.fm-sticky-table .table {
    width: auto !important;
    min-width: 100%;
}

/* ====================================================================
 * Border-Width Fix (löst Text-Durchscheinen)
 * ====================================================================*/
/* Override Bootstrap table defaults completely */
.fm-sticky-table table,
.fm-sticky-table table.table,
.fm-sticky-table .table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

/* Kill all borders with maximum specificity */
.fm-sticky-table table td,
.fm-sticky-table table th,
.fm-sticky-table table.table td,
.fm-sticky-table table.table th,
.fm-sticky-table .table td,
.fm-sticky-table .table th {
    border: 0 !important;
    border-width: 0 !important;
    border-top: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    vertical-align: middle;
}

/* Override Bootstrap's CSS variables */
.fm-sticky-table table.table {
    --bs-table-border-color: transparent !important;
    --bs-border-width: 0 !important;
}

/* Body cells get body background */
.fm-sticky-table tbody td {
    background-color: var(--bs-body-bg) !important;
}

/* ALL header cells get dark background */
.fm-sticky-table thead th,
.fm-sticky-table thead th.fm-rank-column,
.fm-sticky-table thead th.fm-sticky-column {
    background-color: var(--bs-dark) !important;
}

/* ====================================================================
 * Sticky Column Setup
 * ====================================================================*/

/* Rank Column (First Sticky) */
.fm-sticky-table td.fm-rank-column,
.fm-sticky-table th.fm-rank-column {
    position: sticky !important;
    left: 0 !important;
    z-index: 3 !important;
    width: 50px;
    min-width: 50px;
    text-align: center;
}

/* Rank column body cells */
.fm-sticky-table tbody td.fm-rank-column {
    background-color: var(--bs-body-bg) !important;
}

/* Team Column (Second Sticky) */
.fm-sticky-table td.fm-sticky-column,
.fm-sticky-table th.fm-sticky-column {
    position: sticky !important;
    left: 50px !important;
    z-index: 2 !important;
}

/* Team column shadow effect */
.fm-sticky-table td.fm-sticky-column {
    box-shadow: var(--sticky-column-shadow);
}

/* Team column body cells */
.fm-sticky-table tbody td.fm-sticky-column {
    background-color: var(--bs-body-bg) !important;
}

/* Dynamic positioning with rank column */
.fm-sticky-table.has-rank-column td.fm-sticky-column,
.fm-sticky-table.has-rank-column th.fm-sticky-column {
    left: 50px !important;
}

/* ====================================================================
 * Unified Hover Effects
 * ====================================================================*/

/* Base hover for ALL cells */
.fm-sticky-table tbody tr:hover td {
    background-color: rgba(0, 0, 0, 0.075) !important;
}

/* Override Bootstrap's table-hover */
.fm-sticky-table.table-hover tbody tr:hover > td,
.fm-sticky-table .table-hover tbody tr:hover > td {
    --bs-table-accent-bg: rgba(0, 0, 0, 0.075) !important;
    background-color: rgba(0, 0, 0, 0.075) !important;
}

/* Disable transform and shadow effects from fm-table */
.fm-table.fm-sticky-table tbody tr:hover,
.fm-sticky-table.fm-table tbody tr:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* ====================================================================
 * Team Cell Styles
 * ====================================================================*/
.fm-team-cell {
    min-width: 220px;
    white-space: nowrap;
    padding-right: 2.5rem !important;
}

.fm-team-cell .team-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.fm-team-cell .team-logo {
    width: var(--fm-logo-md);
    height: var(--fm-logo-md);
    object-fit: contain;
    flex-shrink: 0;
}

.fm-team-cell .team-name {
    font-weight: 600;
    color: var(--fm-text-primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Text hover effect only (no background change) */
.fm-team-cell .team-name:hover {
    color: var(--fm-gold);
}

/* ====================================================================
 * Rank Column Styles
 * ====================================================================*/
.fm-rank-column {
    width: 50px;
    min-width: 50px;
    text-align: center;
}

/* ====================================================================
 * Responsive Behavior
 * ====================================================================*/

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .fm-team-cell {
        min-width: 180px;
    }
    
    .fm-team-cell .team-name {
        font-size: 0.9rem;
    }
    
    .fm-team-cell .team-logo {
        width: var(--fm-logo-sm);
        height: var(--fm-logo-sm);
    }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
    /* Rank column bleibt sticky */
    .fm-rank-column {
        width: 40px;
        min-width: 40px;
        font-size: 0.85rem;
        position: sticky !important;
        left: 0 !important;
        z-index: 3 !important;
    }
    
    /* Team column bleibt sticky */
    .fm-sticky-table td.fm-sticky-column,
    .fm-sticky-table th.fm-sticky-column {
        position: sticky !important;
        left: 40px !important;
        z-index: 2 !important;
    }
    
    /* Header backgrounds müssen erhalten bleiben */
    .fm-sticky-table thead th.fm-rank-column,
    .fm-sticky-table thead th.fm-sticky-column {
        background-color: var(--bs-dark) !important;
    }
    
    /* Body cell backgrounds */
    .fm-sticky-table tbody td.fm-rank-column,
    .fm-sticky-table tbody td.fm-sticky-column {
        background-color: var(--bs-body-bg) !important;
    }
    
    .fm-sticky-table.has-rank-column td.fm-sticky-column,
    .fm-sticky-table.has-rank-column th.fm-sticky-column {
        left: 40px !important;
    }
    
    .fm-team-cell {
        min-width: 60px;
        padding-right: 0.5rem !important;
    }
    
    .fm-team-cell .team-name {
        display: none;
    }
    
    .fm-team-cell .team-wrapper {
        justify-content: center;
    }
    
    .fm-team-cell .team-logo {
        width: var(--fm-logo-sm);
        height: var(--fm-logo-sm);
    }
}

/* Very small mobile (< 576px) */
@media (max-width: 575px) {
    /* Rank column bleibt sticky */
    .fm-rank-column {
        width: 30px;
        min-width: 30px;
        font-size: 0.8rem;
        position: sticky !important;
        left: 0 !important;
        z-index: 3 !important;
    }
    
    /* Team column bleibt sticky */
    .fm-sticky-table td.fm-sticky-column,
    .fm-sticky-table th.fm-sticky-column {
        position: sticky !important;
        left: 30px !important;
        z-index: 2 !important;
    }
    
    /* Header backgrounds müssen erhalten bleiben */
    .fm-sticky-table thead th.fm-rank-column,
    .fm-sticky-table thead th.fm-sticky-column {
        background-color: var(--bs-dark) !important;
    }
    
    /* Body cell backgrounds */
    .fm-sticky-table tbody td.fm-rank-column,
    .fm-sticky-table tbody td.fm-sticky-column {
        background-color: var(--bs-body-bg) !important;
    }
    
    .fm-sticky-table.has-rank-column td.fm-sticky-column,
    .fm-sticky-table.has-rank-column th.fm-sticky-column {
        left: 30px !important;
    }
    
    .fm-team-cell {
        min-width: 50px;
    }
    
    .fm-team-cell .team-logo {
        width: 24px;
        height: 24px;
    }
}

/* ====================================================================
 * Shadow effect when scrolling
 * ====================================================================*/
.fm-sticky-table.is-scrolling .fm-sticky-column {
    box-shadow: var(--sticky-column-shadow);
}

/* ====================================================================
 * Scrollbar Styling
 * ====================================================================*/
.fm-sticky-table .table-responsive::-webkit-scrollbar {
    height: 12px;
}

.fm-sticky-table .table-responsive::-webkit-scrollbar-track {
    background: var(--bs-gray-200);
    border-radius: 6px;
}

.fm-sticky-table .table-responsive::-webkit-scrollbar-thumb {
    background: var(--bs-gray-500);
    border-radius: 6px;
}

.fm-sticky-table .table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--fm-gold);
}

/* ====================================================================
 * Bootstrap-table Integration Fix
 * ====================================================================*/
/* When fm-sticky-table is on bootstrap-table container */
.bootstrap-table.fm-sticky-table .fixed-table-container {
    position: static !important;
    overflow: visible !important;
}

.bootstrap-table.fm-sticky-table .fixed-table-body {
    overflow-x: auto !important;
    overflow-y: visible !important;
    height: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* Original rules for nested structure */
.fm-sticky-table .fixed-table-container,
.fm-sticky-table .bootstrap-table .fixed-table-container {
    position: static !important;
    overflow: visible !important;
}

.fm-sticky-table .fixed-table-body,
.fm-sticky-table .bootstrap-table .fixed-table-body {
    overflow: visible !important;
    height: auto !important;
}

/* The scrolling should happen on table-responsive, not fixed-table-body */
.fm-sticky-table .table-responsive {
    position: relative !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
}

/* Force sticky on all screen sizes */
.fm-sticky-table .fm-rank-column,
.fm-sticky-table .fm-sticky-column,
.bootstrap-table.fm-sticky-table .fm-rank-column,
.bootstrap-table.fm-sticky-table .fm-sticky-column {
    position: -webkit-sticky !important;
    position: sticky !important;
}

/* Fix borders for Bootstrap-table */
.bootstrap-table.fm-sticky-table table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

.bootstrap-table.fm-sticky-table td,
.bootstrap-table.fm-sticky-table th {
    border: none !important;
}

/* ====================================================================
 * Utility Classes
 * ====================================================================*/
.fm-sticky-always {
    position: sticky !important;
    left: 0 !important;
}

@media (min-width: 1200px) {
    .fm-sticky-table.sticky-disabled-xl .fm-sticky-column {
        position: static;
    }
}

/* ====================================================================
 * Print Styles
 * ====================================================================*/
@media print {
    .fm-sticky-column {
        position: static !important;
    }
    
    .fm-team-cell .team-name {
        display: inline !important;
    }
}