/* ==============================================
   SOIKEOPRO - COMPONENTS V1.0
   Reusable UI components with consistent styling
   ============================================== */

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-lg);
    transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--color-brand-primary);
    color: var(--color-text-primary);
}

.btn-primary:hover {
    background-color: var(--color-brand-hover);
    /* ❌ REMOVED: transform: translateY(-1px); - causes jank */
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.btn-secondary:hover {
    background-color: var(--color-border-secondary);
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-md) var(--space-xl);
    font-size: var(--text-lg);
}

/* ========================================
   TAB FILTERS - FIXED VERSION
   ======================================== */
.tab-container {
    display: flex;
    align-items: center;
    background-color: var(--color-bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xs);
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.tab-button {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast), color var(--transition-fast);
    cursor: pointer;
    border: none;
    background-color: transparent;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.tab-button:hover:not(.active) {
    background-color: rgba(148, 163, 184, 0.1);
    color: var(--color-text-primary);
}

.tab-button.active {
    background-color: var(--color-brand-primary) !important;
    color: #0f172a !important; /* Force dark text on brand background */
}

/* Mobile responsiveness */
@media (max-width: 640px) {
    .tab-container {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .tab-button {
        flex-shrink: 0;
    }
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background-color: var(--color-bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--card-padding); /* Sử dụng CSS variable ⭐ */
    box-shadow: var(--shadow-lg);
    /* No margins - let parent container (space-y-4) handle spacing */
}

/* Responsive card padding */
@media (min-width: 768px) {
    .card {
        padding: var(--card-padding-lg); /* 20px desktop */
    }
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.card-title {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--color-text-primary);
}

.card-body {
    color: var(--color-text-secondary);
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    border-radius: var(--radius-md);
    white-space: nowrap;
}

.badge-live {
    background-color: var(--color-live);
    color: white;
    animation: pulse-live 2s ease-in-out infinite;
}

.badge-finished {
    background-color: var(--color-finished);
    color: white;
}

.badge-ns {
    background-color: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
}

@keyframes pulse-live {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* ========================================
   TABLES
   ======================================== */
.table {
    width: 100%;
    text-align: center;
    table-layout: fixed;
}

.table thead {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    background-color: var(--color-bg-tertiary);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.table thead th {
    padding: var(--space-sm);
    font-weight: var(--font-semibold);
}

.table tbody tr {
    border-bottom: 1px solid var(--color-border-primary);
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
    background-color: var(--color-bg-secondary);
}

.table tbody td {
    padding: var(--space-sm);
    font-size: var(--text-xs);
}

/* ========================================
   MATCH CARDS (Mobile)
   ======================================== */
.match-card {
    background-color: var(--color-bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
}

.match-card:hover {
    box-shadow: var(--shadow-md);
    /* ❌ REMOVED: transform: translateY(-2px); - causes jank */
}

.match-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
}

.match-card-teams {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.match-card-team {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.match-card-team-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.match-card-team-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
}

.match-card-score {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--color-text-primary);
    text-align: center;
    margin: var(--space-sm) 0;
}

/* ========================================
   LOADING STATES
   ======================================== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--color-border-primary);
    border-top-color: var(--color-brand-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-tertiary) 25%,
        var(--color-border-primary) 50%,
        var(--color-bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   MODALS
   ======================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.modal {
    background-color: var(--color-bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: var(--z-modal);
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-border-primary);
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--color-border-primary);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* ========================================
   ALERTS
   ======================================== */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    border-left: 4px solid;
    margin-bottom: var(--space-md);
}

.alert-success {
    background-color: var(--color-success-light);
    border-color: var(--color-success);
    color: var(--color-success-dark);
}

.alert-warning {
    background-color: var(--color-warning-light);
    border-color: var(--color-warning);
    color: var(--color-warning-dark);
}

.alert-error {
    background-color: var(--color-error-light);
    border-color: var(--color-error);
    color: var(--color-error-dark);
}

.alert-info {
    background-color: var(--color-info-light);
    border-color: var(--color-info);
    color: var(--color-info-dark);
}

/* ========================================
   TOOLTIPS
   ======================================== */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: var(--space-xs) var(--space-sm);
    background-color: var(--color-text-primary);
    color: var(--color-bg-primary);
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: var(--z-tooltip);
}

.tooltip:hover::after {
    opacity: 1;
}

/* ========================================
   STICKY SIDEBAR BANNERS
   ======================================== */
.sidebar-sticky-banner {
    position: -webkit-sticky; /* Safari */
    position: sticky;
    top: 60px; /* Closer to menu */
    z-index: 1; /* Very low - content scrolls over and covers banner */
    /* No margins - let parent container (space-y-3) handle spacing */
}

/* Sidebar content covers banner when scrolling */
.sidebar-sticky-banner ~ * {
    position: relative;
    z-index: 10; /* Higher than banner */
    background: var(--color-bg-primary);
}

/* Card components */
.card {
    position: relative;
    z-index: 10;
    background: white;
}

.dark .card {
    background: var(--color-bg-secondary);
}

/* Mobile - không sticky */
@media (max-width: 1023px) {
    .sidebar-sticky-banner {
        position: relative;
        top: 0;
    }

    .sidebar-sticky-banner ~ * {
        z-index: auto;
    }
}

/* ========================================
   SPACING CONSISTENCY FIX
   Trust Tailwind's space-y-3 to handle ALL vertical spacing
   ======================================== */

/*
   Strategy: Remove ALL custom margins and let space-y-3 work naturally
   space-y-3 adds 0.75rem (12px) margin-top to all children except first
   This ensures consistent spacing across all elements
*/
