/**
 * ====================================================================
 * FM-STICKY-TABLE.CSS
 * ====================================================================
 * Modernes Tabellensystem mit Sticky Columns und Native Sortierung
 * Mobile-First Ansatz für optimale Performance
 * ====================================================================
 */

/* Table Container */
.sticky-table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    position: relative;
    border: 1px solid var(--fm-border-light);
    border-radius: 0.375rem;
    background-color: var(--fm-white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    .sticky-table-container {
        max-height: calc(100vh - 250px);
    }
}

/* Mobile scrolling hint */
@media (max-width: 991px) {
    .sticky-table-container {
        position: relative;
    }
    
    .sticky-table-container::after {
        content: '→ Scrollen';
        position: absolute;
        top: 50%;
        right: 10px;
        transform: translateY(-50%);
        background: var(--fm-gold);
        color: var(--fm-white);
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
        font-size: 0.75rem;
        opacity: 0.8;
        pointer-events: none;
        animation: fadeOut 3s forwards;
        animation-delay: 1s;
    }
    
    @keyframes fadeOut {
        to {
            opacity: 0;
        }
    }
}

/* Table Base Styles */
.fm-sticky-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.75rem;
}

/* Verhindere zu kleine Schrift auf sehr kleinen Geräten */
@media (max-width: 375px) {
    .fm-sticky-table {
        font-size: 0.75rem !important; /* Mindestgröße beibehalten */
    }
}

@media (min-width: 768px) {
    .fm-sticky-table {
        font-size: 0.875rem;
    }
}

/* Sticky Header */
.fm-sticky-table thead {
    position: sticky;
    top: 0;
    z-index: 30;
}

/* Shadow effect for sticky header */
.fm-sticky-table thead th {
    position: relative;
}

.fm-sticky-table thead::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -5px;
    height: 5px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* Add shadow when scrolled */
.table-scrolled .fm-sticky-table thead::after {
    opacity: 1;
}

/* Table Header Styles */
.fm-sticky-table thead th {
    background-color: var(--fm-dark);
    color: var(--fm-white);
    font-weight: 600;
    padding: 0.5rem;
    text-align: left;
    border-bottom: 2px solid var(--fm-gold);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: relative;
    font-size: 0.7rem;
}

@media (min-width: 768px) {
    .fm-sticky-table thead th {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

/* Sortable columns hover effect */
.fm-sticky-table thead th.sortable:hover {
    background-color: var(--fm-dark-gray);
}

/* Sort indicators */
.fm-sticky-table thead th.sortable::after {
    content: '\f0dc';
    font-family: 'Bootstrap-icons';
    position: absolute;
    right: 0.5rem;
    opacity: 0.3;
    font-size: 0.75rem;
}

.fm-sticky-table thead th.sort-asc::after {
    content: '\f0de';
    opacity: 1;
    color: var(--fm-gold);
}

.fm-sticky-table thead th.sort-desc::after {
    content: '\f0dd';
    opacity: 1;
    color: var(--fm-gold);
}

/* Sticky Columns - Position */
.fm-sticky-table th:first-child,
.fm-sticky-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 20;
    background-color: var(--fm-white);
    min-width: 40px;
    text-align: center;
}

@media (min-width: 768px) {
    .fm-sticky-table th:first-child,
    .fm-sticky-table td:first-child {
        min-width: 50px;
    }
}

/* Sticky Columns - Team */
.fm-sticky-table th:nth-child(2),
.fm-sticky-table td:nth-child(2) {
    position: sticky;
    left: 40px;
    z-index: 19;
    background-color: var(--fm-white);
    min-width: 60px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

@media (min-width: 576px) {
    .fm-sticky-table th:nth-child(2),
    .fm-sticky-table td:nth-child(2) {
        left: 40px;
        min-width: 100px;
    }
}

@media (min-width: 768px) {
    .fm-sticky-table th:nth-child(2),
    .fm-sticky-table td:nth-child(2) {
        left: 50px;
        min-width: 120px;
    }
}

@media (min-width: 992px) {
    .fm-sticky-table th:nth-child(2),
    .fm-sticky-table td:nth-child(2) {
        min-width: 180px;
        max-width: 230px;
    }
}

/* Ensure text doesn't overflow in team column */
.fm-sticky-table td:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sticky header cells need dark background */
.fm-sticky-table thead th:first-child,
.fm-sticky-table thead th:nth-child(2) {
    background-color: var(--fm-dark);
    z-index: 31;
}

/* Table Body Styles */
.fm-sticky-table tbody tr {
    border-bottom: 1px solid var(--fm-border-light);
    transition: background-color 0.2s ease;
}

.fm-sticky-table tbody tr:hover {
    background-color: rgba(182, 139, 71, 0.1);
}

.fm-sticky-table tbody tr:hover td:first-child,
.fm-sticky-table tbody tr:hover td:nth-child(2) {
    background-color: rgba(182, 139, 71, 0.1);
}

.fm-sticky-table td {
    padding: 0.5rem;
    vertical-align: middle;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .fm-sticky-table td {
        padding: 0.75rem;
    }
}

/* CSS Counter for Position Numbers */
.fm-sticky-table tbody {
    counter-reset: row-number;
}

.fm-sticky-table tbody tr {
    counter-increment: row-number;
}

.fm-sticky-table tbody td:first-child::before {
    content: counter(row-number);
    font-weight: bold;
    color: var(--fm-gold);
}

/* Team Cell Styles */
.team-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.team-logo {
    width: 30px;  /* Größere Logos auf Mobile */
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    object-fit: contain;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .team-logo {
        width: 35px;
        height: 35px;
        min-width: 35px;
        min-height: 35px;
    }
}

.team-link {
    text-decoration: none;
    color: var(--fm-text-primary);
    transition: color 0.2s ease;
    white-space: nowrap;
}

.team-link:hover {
    color: var(--fm-gold);
}

.team-name {
    font-weight: 500;
}

.team-short {
    display: none;
    font-weight: 500;
}

/* Responsive Team Display - Mobile First */
/* Default: Only logo visible */
.team-name,
.team-short {
    display: none;
}

/* Small devices: Still only logo */
@media (min-width: 480px) {
    /* Logo only until 768px */
}

/* Medium devices: Show short name */
@media (min-width: 768px) {
    .team-short {
        display: block;
        font-size: 0.875rem;
    }
}

/* Large devices: Show full name */
@media (min-width: 992px) {
    .team-name {
        display: block;
    }
    .team-short {
        display: none;
    }
}

/* Data cells alignment */
.text-end {
    text-align: right !important;
}

/* Number formatting */
.number-cell {
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
}

@media (min-width: 768px) {
    .number-cell {
        font-size: 0.9rem;
    }
}

/* Mobile table info */
.mobile-info {
    display: block;
    text-align: center;
    padding: 0.5rem;
    background-color: var(--fm-gold);
    color: var(--fm-white);
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

@media (min-width: 992px) {
    .mobile-info {
        display: none;
    }
}

/* ====================================================================
 * STICKY COLUMN BACKGROUND FIXES
 * ====================================================================
 * Verhindert das Durchscheinen von Inhalten beim horizontalen Scrollen
 * Diese Styles waren vorher in jeder einzelnen CSS-Datei dupliziert
 */

/* Standard Background für Sticky Columns */
.fm-sticky-table .position-column,
.fm-sticky-table .team-column {
    background-color: var(--bs-body-bg, #fff) !important;
}

/* Header Background für Sticky Columns */
.fm-sticky-table thead .position-column,
.fm-sticky-table thead .team-column {
    background-color: var(--fm-dark, #212529) !important;
}

/* Hover State für Sticky Columns - erbt die Hover-Farbe der Zeile */
.fm-sticky-table tbody tr:hover .position-column,
.fm-sticky-table tbody tr:hover .team-column {
    background-color: inherit !important;
}

/* Footer Background für Sticky Columns */
.fm-sticky-table tfoot .position-column,
.fm-sticky-table tfoot .team-column {
    background-color: var(--fm-dark, #212529) !important;
}

/* ====================================================================
 * PRINT OPTIMIZATIONS
 * ====================================================================
 * Deaktiviert Sticky-Verhalten beim Drucken
 */
@media print {
    .fm-sticky-table thead {
        position: static !important;
    }
    
    .fm-sticky-table th,
    .fm-sticky-table td {
        position: static !important;
        left: auto !important;
    }
    
    .sticky-table-container {
        overflow: visible !important;
        max-height: none !important;
    }
}