/* Premier History Section - Fixed Version */
/* Save as: /css/history-unified.css */

/* ============================================
   BASE STRUCTURE
   ============================================ */
#history-section {
    background: transparent;
}

.history-content-wrapper {
    background: #0a0a0a;
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: 16px;
    overflow: visible; /* Changed from hidden */
}

/* ============================================
   TABS
   ============================================ */
.history-tabs {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.08), transparent);
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.history-tabs::-webkit-scrollbar {
    display: none;
}

.history-tab {
    flex: 1;
    min-width: max-content;
    padding: 16px 20px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.history-tab:hover {
    background: rgba(255, 215, 0, 0.05);
    color: #FFD700;
}

.history-tab.active {
    color: #FFD700;
    background: rgba(255, 215, 0, 0.1);
}

.history-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to right, #FFD700, #FFA500);
}

.tab-badge {
    background: rgba(255, 215, 0, 0.2);
    color: #FFD700;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

/* ============================================
   CONTENT
   ============================================ */
.history-content {
    padding: 24px;
}

/* ============================================
   SUMMARY CARDS
   ============================================ */
.history-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: #1a1a1a;
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.summary-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.summary-icon i {
    color: #FFD700;
    font-size: 24px;
}

.summary-value {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.summary-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   TABLE STYLES
   ============================================ */
.history-table-container {
    background: #1a1a1a;
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: 12px;
    overflow: auto; /* Allow scrolling */
    max-height: 600px; /* Limit height for scroll */
    margin-bottom: 20px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px; /* Ensure minimum width */
}

.history-table thead {
    background: rgba(255, 215, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-table th {
    padding: 16px;
    text-align: left;
    color: #FFD700;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    background: rgba(0, 0, 0, 0.9);
}

.history-table td {
    padding: 14px 16px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
    font-size: 14px;
}

.history-table tbody tr:hover {
    background: rgba(255, 215, 0, 0.05);
}

/* Competition Title in Table */
.competition-title {
    font-weight: 600;
    color: #fff;
    display: block;
    margin-bottom: 2px;
}

.competition-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

/* Ticket Display */
.ticket-display {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ticket-count {
    background: rgba(255, 215, 0, 0.15);
    color: #FFD700;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.view-tickets-btn {
    background: transparent;
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: #FFD700;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-tickets-btn:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: #FFD700;
}

/* Status Badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.status-active {
    background: rgba(59, 130, 246, 0.2);
    color: #3B82F6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-ended {
    background: rgba(156, 163, 175, 0.2);
    color: #9CA3AF;
    border: 1px solid rgba(156, 163, 175, 0.3);
}

.status-winner {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 165, 0, 0.15));
    color: #FFD700;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.status-won {
    background: rgba(16, 185, 129, 0.2);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-lost {
    background: rgba(239, 68, 68, 0.2);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Prize Display */
.prize-display {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.prize-name {
    font-weight: 600;
    color: #FFD700;
}

.prize-value {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

/* Amount Display */
.amount-display {
    font-weight: 600;
    font-size: 14px;
}

.amount-spent {
    color: #EF4444;
}

.amount-won {
    color: #10B981;
}

/* Empty State */
.history-empty {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon-large {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 165, 0, 0.1));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.empty-icon-large i {
    font-size: 40px;
    color: #FFD700;
}

.empty-title {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
}

.empty-description {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 24px;
}

/* Loading */
.history-loading {
    text-align: center;
    padding: 60px 20px;
}

.history-loading i {
    font-size: 36px;
    color: #FFD700;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   MOBILE STYLES
   ============================================ */
@media (max-width: 768px) {
    .history-content {
        padding: 16px;
    }
    
    .history-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .summary-card {
        padding: 16px;
    }
    
    .summary-value {
        font-size: 20px;
    }
    
    .history-table-container {
        border-radius: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .history-table {
        font-size: 12px;
    }
    
    .history-table th,
    .history-table td {
        padding: 10px;
    }
    
    /* Hide some columns on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    .history-tabs {
        padding: 0;
    }
    
    .history-tab {
        padding: 14px 16px;
        font-size: 13px;
    }
    
    .history-tab i {
        display: none;
    }
}

/* ============================================
   TICKET MODAL
   ============================================ */
.ticket-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: auto;
}

.ticket-modal-content {
    background: linear-gradient(to bottom, #1a1a1a, #0a0a0a);
    border-radius: 16px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
    border: 2px solid rgba(255, 215, 0, 0.3);
}

.ticket-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ticket-modal-title {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ticket-modal-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.ticket-modal-close:hover {
    color: #FFD700;
}

.ticket-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    max-height: 50vh;
    overflow-y: auto;
    padding: 4px;
}

.ticket-number {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    font-weight: 600;
    color: #FFD700;
    transition: all 0.2s;
}

.ticket-number:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: scale(1.05);
}

@media (max-width: 640px) {
    .ticket-modal {
        padding: 0;
    }
    
    .ticket-modal-content {
        border-radius: 0;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
    }
}