﻿/* Profile Tables Standardization CSS */
/* This file standardizes all table designs across player and team profile pages */
/* Based on the game log tab design as the template */

/* ========================================
   ROOT VARIABLES
   ======================================== */
:root {
    --brand-blue: #0A1931;
    --profile-table-border: #e5e7eb;
    --profile-table-bg-primary: white;
    --profile-table-bg-secondary: #f8f9fa;
    --profile-table-bg-hover: #f3f4f6;
    --profile-table-text-primary: #1f2937;
    --profile-table-text-secondary: #6b7280;
    --profile-table-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --profile-table-shadow-md: 0 2px 6px rgba(0, 0, 0, 0.1);
    --profile-table-shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
    --profile-table-radius: 8px;
    --profile-table-radius-lg: 12px;
    --profile-table-edge-gutter: clamp(0.2rem, 0.6vw, 0.5rem);
    --profile-table-cell-block: clamp(0.34rem, 0.6vw, 0.62rem);
    --profile-table-cell-inline: clamp(0.34rem, 0.75vw, 0.68rem);
    --profile-table-sort-icon-space: clamp(1rem, 1.2vw, 1.2rem);
}

/* ========================================
   CONTAINER STRUCTURE
   ======================================== */

/* Main wrapper for any table section */
.profile-table-section {
    width: 100%;
    max-width: 100%;
    margin: 1.5rem 0;
    position: relative;
    box-sizing: border-box;
}

/* Outer container for tables with proper overflow handling */
.profile-table-outer {
    width: 100%;
    max-width: 100%;
    margin: 1rem 0;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: var(--profile-table-radius);
}


/* Inner scrollable container */
.profile-table-inner {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--profile-table-border);
    border-radius: var(--profile-table-radius);
    background: var(--profile-table-bg-primary);
    position: relative;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    margin: 0;
    padding-inline: var(--profile-table-edge-gutter);
}


/* Scrollbar styling */
.profile-table-inner::-webkit-scrollbar {
    height: 12px;
    display: block !important;
    visibility: visible !important;
}

.profile-table-inner::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 6px;
}

.profile-table-inner::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 6px;
}

.profile-table-inner::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* ========================================
   FILTER SECTION
   ======================================== */

.profile-filter-section {
    background: var(--profile-table-bg-secondary);
    border-radius: var(--profile-table-radius-lg);
    padding: 1.25rem;
    margin: 1.5rem 0;
    border: 1px solid var(--profile-table-border);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.profile-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.profile-filter-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--profile-table-text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.profile-filter-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.profile-filter-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.profile-filter-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--profile-table-text-secondary);
    white-space: nowrap;
}

.profile-filter-select,
.profile-filter-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: var(--profile-table-radius);
    font-size: 0.85rem;
    background: white;
    color: var(--profile-table-text-primary);
    transition: all 0.2s ease;
    cursor: pointer;
}

.profile-filter-select {
    min-width: 150px;
}

.profile-filter-input {
    width: 80px;
}

.profile-filter-select:hover,
.profile-filter-input:hover {
    border-color: var(--primary-color);
}

.profile-filter-select:focus,
.profile-filter-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(10, 25, 49, 0.1);
}

.profile-filter-button {
    padding: 0.5rem 1rem;
    border-radius: var(--profile-table-radius);
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.profile-filter-apply {
    background: var(--primary-color, var(--brand-blue));
    color: white;
}

.profile-filter-apply:hover {
    background: var(--brand-blue);
    transform: translateY(-1px);
    box-shadow: var(--profile-table-shadow-md);
}

.profile-filter-clear {
    background: #ef4444;
    color: white;
}

.profile-filter-clear:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Filter badges for active filters */
.profile-filter-active {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.profile-filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--primary-color, var(--brand-blue));
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* ========================================
   TABLE STYLES
   ======================================== */

.profile-data-table {
    width: max-content;
    border-collapse: collapse;
    min-width: 100%;
    table-layout: auto;
}

.profile-data-table th,
.profile-data-table td {
    word-break: normal;
    overflow-wrap: normal;
}

/* Table Headers */
.profile-data-table th {
    background: var(--primary-color, var(--profile-table-bg-secondary));
    color: white;
    padding: var(--profile-table-cell-block) var(--profile-table-cell-inline);
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--profile-table-border);
    white-space: nowrap;
    position: relative;
    min-width: max-content;
    overflow: visible;
    text-overflow: clip;
}

/* Sortable headers */
.profile-data-table thead th.profile-sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    position: relative;
    padding-right: var(--profile-table-cell-inline);
}

.profile-data-table thead th.profile-sortable:hover {
    background: var(--primary-color, var(--profile-table-bg-secondary));
    color: white;
}

.profile-data-table thead th.profile-sortable i {
    display: none !important;
}

.profile-data-table thead th.profile-sortable:hover i {
    opacity: 1;
}

.profile-data-table thead th.profile-sortable::after {
    content: '';
    display: inline-block;
    margin-left: 0;
    width: auto;
    text-align: center;
    font-size: 0.62rem;
    line-height: 1;
    vertical-align: middle;
    opacity: 0.9;
}

.profile-data-table thead th.profile-sortable.sort-asc::after {
    content: '\2191';
    margin-left: 0.2rem;
}

.profile-data-table thead th.profile-sortable.sort-desc::after {
    content: '\2193';
    margin-left: 0.2rem;
}
/* Safety guard: sort glyphs should never render in tbody/tfoot cells. */
.profile-data-table tbody td.profile-sortable::after,
.profile-data-table tbody th.profile-sortable::after,
.profile-data-table tfoot td.profile-sortable::after,
.profile-data-table tfoot th.profile-sortable::after {
    content: none !important;
    display: none !important;
}

.profile-data-table tbody .sort-indicator,
.profile-data-table tfoot .sort-indicator,
.profile-data-table tbody i[class*="fa-sort"],
.profile-data-table tfoot i[class*="fa-sort"] {
    display: none !important;
}

/* Table Data Cells */
.profile-data-table td {
    padding: var(--profile-table-cell-block) var(--profile-table-cell-inline);
    border-bottom: 1px solid var(--profile-table-border);
    font-size: 0.8rem;
    white-space: nowrap;
    background: var(--profile-table-bg-primary);
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
}

.profile-data-table th:first-child,
.profile-data-table td:first-child {
    padding-left: calc(var(--profile-table-cell-inline) + var(--profile-table-edge-gutter));
}

.profile-data-table th:last-child,
.profile-data-table td:last-child {
    padding-right: calc(var(--profile-table-cell-inline) + var(--profile-table-edge-gutter));
}

/* Row hover effect */
.profile-data-table tbody tr {
    transition: background-color 0.2s ease;
}

.profile-data-table tbody tr:hover {
    background: var(--profile-table-bg-hover);
}

.profile-data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Sticky first column (for tables that need it) */
.profile-table-sticky .profile-data-table th:first-child,
.profile-table-sticky .profile-data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
}

.profile-table-sticky .profile-data-table th:first-child {
    background: var(--primary-color, var(--profile-table-bg-secondary));
}

.profile-table-sticky .profile-data-table td:first-child {
    background: var(--profile-table-bg-primary);
}

.profile-table-sticky .profile-data-table tbody tr:hover td:first-child:not(.profile-filtered):not(.profile-stat-filtered):not(.stat-highlight):not(.highlighted-cell):not(.sorted-col) {
    background: var(--profile-table-bg-hover);
}

/* Column highlighting for filtered columns */
.profile-data-table th.profile-filtered {
    background: var(--primary-color) !important;
    color: white !important;
    font-weight: 700;
}

.profile-data-table td.profile-stat-filtered {
    background: var(--primary-color) !important;
    color: white !important;
    font-weight: 700;
}

/* ========================================
   PAGINATION
   ======================================== */

.profile-pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 3rem;
    padding: 2rem 1rem;
    border-top: 2px solid var(--profile-table-border);
    background: var(--profile-table-bg-secondary);
    border-radius: var(--profile-table-radius-lg);
    position: relative;
}

.profile-pagination-btn {
    background: white;
    border: 2px solid var(--profile-table-border);
    border-radius: 10px;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--profile-table-text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 45px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--profile-table-shadow-sm);
}

.profile-pagination-btn:hover:not(:disabled) {
    background: var(--profile-table-bg-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--profile-table-shadow-md);
}

.profile-pagination-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(10, 25, 49, 0.3);
}

.profile-pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.profile-pagination-info {
    font-size: 0.9rem;
    color: var(--profile-table-text-secondary);
    margin: 0 1.5rem;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.profile-pagination-dots {
    color: var(--profile-table-text-secondary);
    font-size: 0.9rem;
    padding: 0 0.5rem;
}

/* ========================================
   STAT GUIDE / INFO TOOLTIPS
   ======================================== */

.profile-stat-guide-container {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    z-index: 1100;
}

.profile-stat-guide-btn {
    background: var(--profile-table-bg-secondary);
    border: 1px solid var(--profile-table-border);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    font-size: 0.85rem;
    color: var(--profile-table-text-secondary);
    transition: all 0.2s ease;
}

.profile-stat-guide-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Cell alignments */
.profile-text-left { text-align: left; }
.profile-text-center { text-align: center; }
.profile-text-right { text-align: right; }

/* Cell with team logo */
.profile-team-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.profile-team-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

/* Player cell with image */
.profile-player-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.profile-player-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--profile-table-border);
}

/* Result badges */
.profile-result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-result-badge.win {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
}

.profile-result-badge.loss {
    background: rgba(239, 68, 68, 0.15);
    color: #EF4444;
}

.profile-result-badge.draw {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
}

/* Score cells */
.profile-score-cell {
    font-weight: 500;
    font-size: 0.85rem;
}

.profile-score-cell strong {
    color: var(--primary-color);
}

/* Empty state */
.profile-empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--profile-table-text-secondary);
}

.profile-empty-icon {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.profile-empty-text {
    font-size: 1.1rem;
    margin: 0;
}

/* Loading state */
.profile-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    color: var(--profile-table-text-secondary);
}

.profile-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--profile-table-border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: profile-spin 1s linear infinite;
}

@keyframes profile-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 1200px) {
    .profile-filter-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .profile-pagination-container {
        gap: 0.5rem;
        padding: 1.5rem 0.75rem;
    }
    
    .profile-pagination-info {
        margin: 0 0.75rem;
    }
}

@media (max-width: 768px) {
    :root {
        --profile-table-edge-gutter: clamp(0.16rem, 1.2vw, 0.34rem);
        --profile-table-cell-block: clamp(0.3rem, 0.9vw, 0.48rem);
        --profile-table-cell-inline: clamp(0.3rem, 1.1vw, 0.54rem);
        --profile-table-sort-icon-space: clamp(0.9rem, 1.8vw, 1.1rem);
    }

    .profile-table-section {
        margin: 1rem 0;
    }
    
    .profile-filter-section {
        padding: 1rem;
    }
    
    .profile-filter-select {
        min-width: 100%;
    }
    
    .profile-pagination-container {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 1rem;
    }
    
    .profile-pagination-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .profile-data-table th,
    .profile-data-table td {
        padding: var(--profile-table-cell-block) var(--profile-table-cell-inline);
        font-size: clamp(0.7rem, 2.2vw, 0.78rem);
    }
}

@media (max-width: 500px) {
    :root {
        --profile-table-edge-gutter: clamp(0.14rem, 1.4vw, 0.28rem);
        --profile-table-cell-block: clamp(0.28rem, 0.9vw, 0.42rem);
        --profile-table-cell-inline: clamp(0.26rem, 1.2vw, 0.48rem);
        --profile-table-sort-icon-space: clamp(0.85rem, 1.6vw, 1rem);
    }

    .profile-filter-section {
        padding: 0.75rem;
    }
    
    .profile-pagination-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-width: 35px;
        min-height: 35px;
    }
    
    .profile-pagination-info {
        font-size: 0.8rem;
    }
    
    .profile-data-table th,
    .profile-data-table td {
        padding: var(--profile-table-cell-block) var(--profile-table-cell-inline);
        font-size: clamp(0.67rem, 2.4vw, 0.74rem);
    }
}

@media (max-width: 820px) {
    .stat-filter-info {
        display: none;
    }

    .home-sections[class*="team-"] .profile-pagination-container {
        justify-content: flex-start;
    }

    .home-sections[class*="team-"] .profile-pagination-container .profile-pagination-btn:last-child {
        margin-left: auto;
    }
}


