/* ================================================ */
/*  GROUPS PAGE - WHITE LABEL THEME AWARE          */
/*  Uses CSS variables from theme-system.css       */
/* ================================================ */

/* ================================================ */
/*  GROUPS PAGE STYLES - Padel and Go Tournament   */
/*  Follows home page design with glow effects     */
/* ================================================ */
main {
    overflow: visible !important;
}

/* ===== HERO SECTION WITH ENHANCED GRADIENT ===== */
.hero-groups {
    position: relative;
    background: var(--bg-primary);
    overflow: visible;
    padding: 8rem 0 4rem;
    min-height: 40vh;
    display: flex;
    align-items: center;
}

/* Top-right glow */
.hero-groups::before {
    content: "";
    position: absolute;
    top: -20%;
    right: -15%;
    width: 60%;
    height: 80%;
    background: radial-gradient(
        circle at center,
        color-mix(in srgb, var(--accent-primary), 0.15) 0%,
        color-mix(in srgb, var(--accent-primary), 0.08) 30%,
        transparent 70%
    );
    pointer-events: none;
    z-index: 1;
    animation: pulse-glow 8s ease-in-out infinite;
    filter: blur(60px);
}

/* Bottom-left subtle glow */
.hero-groups::after {
    content: "";
    position: absolute;
    bottom: -20%;
    left: -15%;
    width: 50%;
    height: 60%;
    background: radial-gradient(
        circle at center,
        color-mix(in srgb, var(--accent-secondary), 0.1) 0%,
        color-mix(in srgb, var(--accent-secondary), 0.05) 30%,
        transparent 70%
    );
    pointer-events: none;
    z-index: 1;
    animation: pulse-glow 8s ease-in-out infinite 4s;
    filter: blur(60px);
}

.hero-groups > * {
    position: relative;
    z-index: 3;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

/* ===== MAIN SECTION WITH DIAGONAL GLOW ===== */
.groups-main-section {
    position: relative;
    overflow: visible;
}

.groups-main-section::before {
    content: "";
    position: absolute;
    top: 20%;
    left: -20%;
    width: 60%;
    height: 60%;
    background: radial-gradient(
        ellipse at center,
        color-mix(in srgb, var(--accent-secondary), 0.08) 0%,
        color-mix(in srgb, var(--accent-secondary), 0.04) 40%,
        transparent 70%
    );
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
}

.groups-main-section > * {
    position: relative;
    z-index: 1;
}

/* ===== SECTION HEADER CARDS ===== */
.section-header-card {
    background: linear-gradient(145deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent);
    border-radius: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
}

/* Glow behind card */
.section-header-card::before {
    content: "";
    position: absolute;
    inset: -15px;
    background: radial-gradient(
        circle at center,
        color-mix(in srgb, var(--accent-primary), 0.06) 0%,
        color-mix(in srgb, var(--accent-secondary), 0.04) 40%,
        transparent 70%
    );
    z-index: -1;
    opacity: 0.6;
    filter: blur(30px);
    pointer-events: none;
    border-radius: inherit;
}

/* Dot pattern */
.section-header-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(circle at 2px 2px, color-mix(in srgb, var(--text-primary) 5%, transparent) 1px, transparent 0);
    background-size: 20px 20px;
    opacity: 0.8;
    pointer-events: none;
    z-index: 1;
    border-radius: inherit;
}

.section-header-card > * {
    position: relative;
    z-index: 2;
}

/* ===== SMART DROPDOWN STYLES ===== */
.smart-dropdown {
    position: relative !important;
    width: 100%;
    z-index: 999999 !important;
    isolation: isolate;
}

.dropdown-trigger {
    background: color-mix(in srgb, var(--bg-secondary) 80%, transparent);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-primary);
    border-radius: 1rem;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    width: 100%;
    user-select: none;
    position: relative !important;
    z-index: 999998 !important;
}

.dropdown-trigger:hover {
    border-color: var(--accent-secondary);
    background: color-mix(in srgb, var(--bg-secondary) 90%, transparent);
    box-shadow: 0 0 20px color-mix(in srgb, var(--accent-secondary), 0.2);
}

.dropdown-trigger.open {
    border-color: var(--accent-secondary);
    border-radius: 1rem 1rem 0 0;
    background: var(--bg-secondary);
    box-shadow: 0 0 30px color-mix(in srgb, var(--accent-secondary), 0.3);
}

.dropdown-content {
    position: absolute !important;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    backdrop-filter: blur(15px);
    border: 1px solid var(--accent-secondary);
    border-top: none;
    border-radius: 0 0 1rem 1rem;
    max-height: 400px;
    min-height: 100px;
    overflow-y: auto;
    z-index: 999999 !important;
    display: none;
    box-shadow: var(--shadow-xl), 0 0 40px color-mix(in srgb, var(--accent-secondary), 0.2);
}

.dropdown-content.open {
    display: block !important;
    animation: slideDown 0.2s ease-out;
}

/* Force z-index hierarchy */
.mb-8:has(.smart-dropdown) {
    position: relative !important;
    z-index: 99999 !important;
}

.smart-dropdown .dropdown-content {
    z-index: 999999 !important;
    position: absolute !important;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dropdown search */
.dropdown-search {
    padding: 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent);
    position: relative;
}

.dropdown-search input {
    width: 100%;
    background: color-mix(in srgb, var(--bg-tertiary) 80%, transparent);
    border: 1px solid var(--border-primary);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.dropdown-search input:focus {
    outline: none;
    border-color: var(--accent-secondary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-secondary), 0.1);
}

.dropdown-search .search-icon {
    position: absolute;
    left: 1.75rem;
    top: 1.75rem;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* Dropdown categories and items */
.dropdown-category {
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--accent-secondary);
    background: color-mix(in srgb, var(--bg-tertiary) 60%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--text-primary) 5%, transparent);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-item {
    padding: 0.75rem 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    border-bottom: 1px solid color-mix(in srgb, var(--text-primary) 5%, transparent);
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    position: relative;
}

.dropdown-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-secondary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dropdown-item:hover {
    background: color-mix(in srgb, var(--accent-secondary), 0.1);
    color: var(--accent-secondary);
}

.dropdown-item:hover::before {
    opacity: 1;
}

.dropdown-item.selected {
    background: var(--gradient-primary);
    color: var(--bg-primary);
    font-weight: 600;
}

.dropdown-item.selected::before {
    opacity: 0;
}

.dropdown-item-icon {
    margin-right: 0.75rem;
    opacity: 0.7;
    font-size: 0.75rem;
}

.dropdown-content:empty::before {
    content: "No hay grupos disponibles";
    display: block;
    padding: 2rem;
    text-align: center;
    color: var(--text-tertiary);
    font-style: italic;
}

/* ===== ACTIVE FILTER DISPLAY ===== */
.active-filter-display {
    background: color-mix(in srgb, var(--accent-secondary), 0.1);
    border: 1px solid color-mix(in srgb, var(--accent-secondary), 0.3);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    display: none;
}

.active-filter-tag {
    background: var(--gradient-primary);
    color: var(--bg-primary);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 2px 10px color-mix(in srgb, var(--accent-secondary), 0.3);
}

.clear-filter-btn {
    background: none;
    border: none;
    color: var(--bg-primary);
    margin-left: 0.5rem;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.125rem;
    border-radius: 50%;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.clear-filter-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: rotate(90deg);
}

/* ===== GROUP CARDS ===== */
.group-content {
    position: relative !important;
    z-index: 1 !important;
}

.compact-group-card {
    background: linear-gradient(145deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent);
    border-radius: 1rem;
    overflow: visible;
    margin-bottom: 1.5rem;
    position: relative !important;
    z-index: 1 !important;
    transition: all 0.3s ease;
}

/* Glow behind group card */
.compact-group-card::before {
    content: "";
    position: absolute;
    inset: -10px;
    background: radial-gradient(
        circle at center,
        color-mix(in srgb, var(--accent-primary), 0.08) 0%,
        color-mix(in srgb, var(--accent-secondary), 0.06) 40%,
        transparent 70%
    );
    z-index: -1;
    opacity: 0;
    filter: blur(25px);
    pointer-events: none;
    border-radius: inherit;
    transition: opacity 0.3s ease;
}

.compact-group-card:hover::before {
    opacity: 1;
}

.compact-group-card:hover {
    border-color: color-mix(in srgb, var(--accent-secondary), 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Group header */
.compact-group-header {
    background: var(--gradient-primary);
    padding: 1rem 1.5rem;
    color: var(--bg-primary);
    border-radius: 1rem 1rem 0 0;
}

/* ===== TABLES ===== */
.compact-standings-table {
    background: transparent;
    border-radius: 0;
    overflow: hidden;
    border: none;
}

.compact-table-header {
    background: color-mix(in srgb, var(--bg-tertiary) 90%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--accent-secondary), 0.2);
}

.compact-table-row {
    border-bottom: 1px solid color-mix(in srgb, var(--text-primary) 5%, transparent);
    transition: all 0.2s ease;
    position: relative;
}

.compact-table-row::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.compact-table-row:hover {
    background: color-mix(in srgb, var(--bg-tertiary) 60%, transparent);
    box-shadow: 0 0 20px color-mix(in srgb, var(--accent-primary), 0.1);
}

.compact-table-row:hover::before {
    opacity: 1;
}

/* Position indicator */
.compact-position-indicator {
    background: var(--gradient-primary);
    border-radius: 50%;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--bg-primary);
    font-size: 0.75rem;
    box-shadow: 0 2px 10px color-mix(in srgb, var(--accent-secondary), 0.3);
}

/* Team icon */
.compact-team-icon {
    background: var(--gradient-primary);
    color: var(--bg-primary);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--accent-secondary), 0.3);
}

/* Stat badges */
.compact-stat-badge {
    background: color-mix(in srgb, var(--bg-tertiary) 80%, transparent);
    border-radius: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 2rem;
    text-align: center;
    transition: all 0.2s ease;
}

.compact-table-row:hover .compact-stat-badge {
    transform: scale(1.05);
}

.stats-positive {
    color: #10B981;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.stats-negative {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.stats-neutral {
    color: #6B7280;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
}

.stats-primary {
    color: var(--accent-secondary);
    background: color-mix(in srgb, var(--accent-secondary), 0.1);
    border: 1px solid color-mix(in srgb, var(--accent-secondary), 0.3);
    font-weight: bold;
}

/* ===== LEGEND ===== */
.legend-item {
    background: color-mix(in srgb, var(--bg-tertiary) 60%, transparent);
    border-radius: 0.5rem;
    padding: 0.5rem;
    border: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent);
    transition: all 0.3s ease;
}

.legend-item:hover {
    background: color-mix(in srgb, var(--bg-tertiary) 80%, transparent);
    border-color: color-mix(in srgb, var(--accent-secondary), 0.3);
    transform: translateY(-2px);
}

/* ===== EMPTY STATE ===== */
.no-groups-icon {
    background: var(--gradient-primary);
    color: var(--bg-primary);
    box-shadow: 0 8px 30px color-mix(in srgb, var(--accent-secondary), 0.3);
    animation: float 3s ease-in-out infinite;
}

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

/* ===== BACK TO TOP BUTTON ===== */
.back-to-top {
    background: var(--gradient-primary);
    color: var(--bg-primary);
    box-shadow: 0 4px 20px color-mix(in srgb, var(--accent-secondary), 0.4);
    transition: all 0.3s ease;
}

.back-to-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px color-mix(in srgb, var(--accent-secondary), 0.6);
}

.pulse-glow {
    animation: pulse-glow-button 2s infinite;
}

@keyframes pulse-glow-button {
    0%, 100% { 
        box-shadow: 0 4px 20px color-mix(in srgb, var(--accent-secondary), 0.4); 
    }
    50% { 
        box-shadow: 0 4px 30px color-mix(in srgb, var(--accent-secondary), 0.7); 
    }
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    .hero-groups {
        padding: 6rem 0 3rem;
        min-height: 40vh;
    }
    
    .compact-table-row td {
        padding: 0.5rem 0.25rem;
    }
    
    .compact-team-icon {
        width: 1.5rem;
        height: 1.5rem;
    }
    
    .compact-position-indicator {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.625rem;
    }
    
    .mobile-team-name {
        font-size: 0.75rem;
        line-height: 1.2;
    }
    
    .mobile-team-secondary {
        font-size: 0.625rem;
    }
    
    .section-header-card {
        padding: 1rem !important;
    }
    
    /* Reduce glow intensity on mobile */
    .hero-groups::before,
    .hero-groups::after,
    .groups-main-section::before {
        opacity: 0.5;
    }
    
    .section-header-card::before,
    .compact-group-card::before {
        opacity: 0.3;
    }
}

/* ===== TOUCH INTERACTIONS ===== */
.touch-action-manipulation {
    touch-action: manipulation;
}

.mobile-clickable {
    position: relative;
    z-index: 10;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ===== LOADING ANIMATIONS ===== */
.page-transition {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

.page-transition.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* ===== ACCESSIBILITY ===== */
.dropdown-trigger:focus,
.dropdown-search input:focus {
    outline: 2px solid var(--accent-secondary);
    outline-offset: 2px;
}

/* ===== SCROLLBAR STYLING ===== */
.dropdown-content::-webkit-scrollbar {
    width: 8px;
}

.dropdown-content::-webkit-scrollbar-track {
    background: color-mix(in srgb, var(--bg-tertiary) 50%, transparent);
    border-radius: 0 0 1rem 0;
}

.dropdown-content::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--accent-secondary), 0.5);
    border-radius: 4px;
}

.dropdown-content::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--accent-secondary), 0.7);
}

/* ===== PRINT STYLES ===== */
@media print {
    .hero-groups::before,
    .hero-groups::after,
    .groups-main-section::before,
    .section-header-card::before,
    .compact-group-card::before,
    .back-to-top,
    .smart-dropdown {
        display: none;
    }
    
    .compact-group-card {
        break-inside: avoid;
    }
}

/* ===== TABLE ALIGNMENT FIX ===== */

/* Ensure table layout is fixed and columns are properly aligned */
.compact-standings-table table {
    table-layout: fixed;
    width: 100%;
}

/* Define specific column widths for proper alignment */
.compact-standings-table thead th:nth-child(1),
.compact-standings-table tbody td:nth-child(1) {
    width: 60px; /* Position column */
    text-align: center;
    vertical-align: middle;
}

.compact-standings-table thead th:nth-child(2),
.compact-standings-table tbody td:nth-child(2) {
    width: auto; /* Team name column - takes remaining space */
    text-align: left;
    vertical-align: middle;
}

.compact-standings-table thead th:nth-child(3),
.compact-standings-table tbody td:nth-child(3),
.compact-standings-table thead th:nth-child(4),
.compact-standings-table tbody td:nth-child(4),
.compact-standings-table thead th:nth-child(5),
.compact-standings-table tbody td:nth-child(5),
.compact-standings-table thead th:nth-child(6),
.compact-standings-table tbody td:nth-child(6),
.compact-standings-table thead th:nth-child(7),
.compact-standings-table tbody td:nth-child(7) {
    width: 70px; /* Stats columns */
    text-align: center;
    vertical-align: middle;
}

/* Center the position indicator within its cell */
.compact-standings-table tbody td:nth-child(1) {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Make sure the position indicator doesn't cause overflow */
.compact-position-indicator {
    flex-shrink: 0;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    /* Smaller column widths for mobile */
    .compact-standings-table thead th:nth-child(1),
    .compact-standings-table tbody td:nth-child(1) {
        width: 45px;
    }
    
    .compact-standings-table thead th:nth-child(3),
    .compact-standings-table tbody td:nth-child(3),
    .compact-standings-table thead th:nth-child(4),
    .compact-standings-table tbody td:nth-child(4),
    .compact-standings-table thead th:nth-child(5),
    .compact-standings-table tbody td:nth-child(5),
    .compact-standings-table thead th:nth-child(6),
    .compact-standings-table tbody td:nth-child(6),
    .compact-standings-table thead th:nth-child(7),
    .compact-standings-table tbody td:nth-child(7) {
        width: 55px;
    }
}

/* Fix for search results table too */
#searchResults .compact-standings-table table {
    table-layout: fixed;
    width: 100%;
}

#searchResults .compact-standings-table thead th,
#searchResults .compact-standings-table tbody td {
    text-align: center;
    vertical-align: middle;
}

#searchResults .compact-standings-table thead th:nth-child(1),
#searchResults .compact-standings-table tbody td:nth-child(1),
#searchResults .compact-standings-table thead th:nth-child(2),
#searchResults .compact-standings-table tbody td:nth-child(2) {
    text-align: left;
}