/* ═══════════════════════════════════════════════════════════════════════════
   Squad Cards Plugin v1.0
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   Container
   ─────────────────────────────────────────────────────────────────────────── */
.squad-cards-container {
    padding: var(--listing-padding, 1rem);
}

.squad-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    justify-content: start;
    width: 100%;
    align-items: stretch; /* Ensure all grid items stretch to same height */
}

/* ─────────────────────────────────────────────────────────────────────────────
   Card
   ─────────────────────────────────────────────────────────────────────────── */
.squad-card {
    background: var(--card-bg, #ffffff);
    color: var(--card-text, #1f2937);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: var(--border-width, 0px) solid var(--border-color, transparent);
    height: 100%; /* Ensure card fills grid cell */
}

.squad-card-main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Card Structure
   ─────────────────────────────────────────────────────────────────────────── */
.squad-card-top-row {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Name styling - size controlled by Tailwind classes in HTML */

.value-pos {
    font-size: var(--position-size, 0.875rem);
    font-weight: 600;
    color: var(--position-text, #4b5563);
}

/* Stats Row */
.squad-card-stats-row {
    width: 100%;
    padding: 1rem;
    background: var(--team-stats-bg, rgba(0,0,0,0.015));
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* When sponsor is empty, extend stats background */
.squad-card-stats-row + .empty-sponsor {
    background: var(--team-stats-bg, rgba(0,0,0,0.015));
    border-top: none; /* Remove border between stats and empty sponsor */
    min-height: 100px; /* Ensure consistent height */
    flex-shrink: 0; /* Prevent shrinking */
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin-top: 0.5rem;
}

.stats-item {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.25rem;
}

/* Stats backgrounds/colors - Global */
.squad-card:not(.plain-stats) .stats-item:nth-child(1) { 
    background: #f3f4f6; /* Apps - Gray */
    border-radius: 0.5rem 0 0 0.5rem; /* Top left, bottom left */
}
.squad-card:not(.plain-stats) .stats-item:nth-child(1) .stats-value { color: #374151; }

.squad-card:not(.plain-stats) .stats-item:nth-child(2) { 
    background: #dcfce7; /* Wins - Green */
}
.squad-card:not(.plain-stats) .stats-item:nth-child(2) .stats-value { color: #166534; }

.squad-card:not(.plain-stats) .stats-item:nth-child(3) { 
    background: #fee2e2; /* Losses - Red */
}
.squad-card:not(.plain-stats) .stats-item:nth-child(3) .stats-value { color: #991b1b; }

.squad-card:not(.plain-stats) .stats-item:nth-child(4) { 
    background: #e0f2fe; /* Draws - Blue */
    border-radius: 0 0.5rem 0.5rem 0; /* Top right, bottom right */
}
.squad-card:not(.plain-stats) .stats-item:nth-child(4) .stats-value { color: #075985; }

/* Plain stats (no colored backgrounds) */
.squad-card.plain-stats .stats-item {
    background: transparent;
}
.squad-card.plain-stats .stats-item .stats-value {
    color: var(--stats-text, var(--card-text, #1f2937));
}
.squad-card.plain-stats .stats-item .stats-label {
    color: var(--stats-text, var(--card-text, #1f2937));
}

.stats-item.border-x {
    /* Borders removed in favor of background colors */
    border: none;
}

.stats-label {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0;
}

.stats-value {
    font-size: 1.25rem;
    font-weight: 900;
    color: #1f2937;
    margin: 0;
}

/* Sponsor Row */
.squad-card-sponsor-row {
    width: 100%;
    padding: 1rem;
    background: #fff;
    display: flex;
    flex-direction: column; /* Stack vertically */
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
    min-height: 100px; /* Fixed height for consistency */
    flex-shrink: 0; /* Prevent shrinking */
}

.sponsor-container {
    display: flex;
    flex-direction: column; /* Stack label and logo */
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit;
    gap: 0.25rem;
    width: 100%;
}

.sponsor-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
}

.sponsor-name {
    font-weight: 700;
    font-style: italic;
    font-size: 1rem;
}

.sponsor-logo {
    max-height: 32px;
    max-width: 32px;
    object-fit: contain;
}

.squad-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--hover-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
}

/* ─────────────────────────────────────────────────────────────────────────────
   Photo Section
   ─────────────────────────────────────────────────────────────────────────── */
.squad-card-photo-container {
    position: relative;
    width: 100%;
    padding-top: 100%; /* Square aspect ratio */
    background: rgba(0,0,0,0.03);
    overflow: hidden;
    flex-shrink: 0; /* Prevent shrinking */
}

.squad-card-photo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.squad-card:hover .squad-card-photo {
    transform: scale(1.05);
}

/* Photo Shapes */
.squad-card.photo-circle .squad-card-photo-container {
    padding-top: 100%;
    border-radius: 50%;
    margin: 1rem auto 0;
    width: 80%;
}

.squad-card.photo-square .squad-card-photo-container {
    border-radius: 0;
}

.squad-card.photo-rounded .squad-card-photo-container {
    border-radius: 1rem;
    margin: 1rem;
    width: calc(100% - 2rem);
    padding-top: calc(100% - 2rem);
}

/* Placeholder - Now uses CSS variables for colors */
.squad-card-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--avatar-placeholder-bg, rgba(0,0,0,0.1));
}

.squad-card-placeholder svg {
    width: 70%;
    height: 70%;
    color: var(--avatar-placeholder-icon, rgba(0,0,0,0.3));
    opacity: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Content Section
   ─────────────────────────────────────────────────────────────────────────── */
.squad-card-info-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 0.75rem;
    flex: 1;
}

.info-block {
    margin-bottom: 0.25rem;
}

.squad-card-name {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--name-text, inherit);
}

.squad-card-position {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    /* min-height removed - only reserve space if badge is shown */
}

.mj-graduate-badge.pill {
    background: var(--accent, #fbbf24);
    color: var(--mj-badge-text, var(--on-accent, #000));
    padding: 0.375rem 0.75rem; /* More y-padding */
    border-radius: 9999px; /* Fully rounded pill */
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
    display: inline-block; /* Don't fill whole width */
    /* Inherit text alignment from parent container */
}

/* Ball Icon Badge - Inherits badge text color */
.mj-round-badge svg {
    color: currentColor;
}
.mj-round-badge {
    position: absolute;
    width: 2rem;
    height: 2rem;
    background: var(--accent, #fbbf24);
    color: var(--mj-badge-text, var(--on-accent, #000));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mj-round-badge.top-left {
    top: 0.5rem;
    left: 0.5rem;
}

.mj-round-badge.top-right {
    top: 0.5rem;
    right: 0.5rem;
}

/* Remove extra space in content when badge is hidden */
.squad-card-info-container:has(.mj-graduate-badge:empty),
.squad-card-info-container:not(:has(.mj-graduate-badge)) {
    min-height: 80px; /* Slightly smaller when no badge */
}

/* ─────────────────────────────────────────────────────────────────────────────
   Stats Section
   ─────────────────────────────────────────────────────────────────────────── */
.squad-card-stats {
    padding: 0.75rem 1rem;
    background: rgba(0,0,0,0.02);
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--card-text, #1f2937);
}

.stats-heading {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    font-weight: 700;
    text-align: center;
    width: 100%;
}

.stats-data {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.9;
}

.stats-apps {
    color: var(--name-text, inherit);
}

.stats-separator {
    opacity: 0.4;
    font-weight: 400;
}

.stats-record {
    font-variant-numeric: tabular-nums;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Sponsor Section
   ─────────────────────────────────────────────────────────────────────────── */
.squad-card-sponsor {
    margin-top: auto;
    padding: 1rem;
    background: rgba(0,0,0,0.03);
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    height: 100px; /* Fixed height for consistency */
    justify-content: center;
}

.sponsor-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.6;
    text-align: center;
    margin-bottom: 0.25rem;
}

.sponsor-logo {
    max-height: 40px;
    max-width: 120px;
    object-fit: contain;
    /* Removed filter: grayscale(100%) - full color always */
    opacity: 1;
    transition: all 0.2s ease;
}

.sponsor-link:hover .sponsor-logo {
    filter: grayscale(0%);
    opacity: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Mobile Responsive
   ─────────────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .squad-cards-container {
        padding: 0.5rem;
    }

    .squad-cards-grid {
        grid-template-columns: 1fr; /* Full width columns */
        gap: 1rem;
    }
    
    .squad-card {
        height: auto;
    }

    /* Mobile: Horizontal Layout for Top Row */
    .squad-card-top-row {
        flex-direction: row; /* Side-by-side */
        border-bottom: 1px solid rgba(0,0,0,0.05); /* Divider */
    }

    /* Left: Image (50%) */
    .squad-card-photo-container {
        width: 50% !important;
        padding-top: 0 !important; /* Override aspect-ratio hack */
        aspect-ratio: 1/1; /* Ensure square */
        flex-shrink: 0;
        margin: 0 !important; /* Reset margins */
        border-radius: 0 !important; /* Square corners for mobile split view */
    }

    /* Right: Info (50%) */
    .squad-card-info-container {
        width: 50%;
        padding: 1rem;
        align-items: flex-start; /* Left align text */
        text-align: left;
        justify-content: center; /* Vertically center content */
        min-height: auto; /* Remove fixed height constraint */
    }
    
    /* Adjust text sizes for mobile context */
    .squad-card-name {
        font-size: 1.1rem;
        margin-bottom: 0.25rem;
    }
    
    .squad-card-position {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    /* Stats Row - Full Width */
    .squad-card-stats-row {
        padding: 0.5rem;
        flex-direction: column; /* Changed to column to stack heading above grid */
        /* Design implies full width block below top row */
        border-top: none; /* Already separated by top row border */
        background: var(--team-stats-bg, #f9fafb); /* Use CSS variable with fallback */
    }
    
    .stats-heading {
        display: block; /* Show heading on mobile */
        margin-bottom: 0.25rem;
    }

    /* Custom grid for stats matching mockup */
    .stats-grid {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr); /* 4 columns: Apps, W, L, D */
        gap: 0;
    }
    
    .stats-label {
        font-size: 0.65rem;
        text-transform: uppercase;
        color: #9ca3af;
        margin-bottom: 0.1rem;
    }
    
    .stats-value {
        font-size: 1.1rem;
        font-weight: 800;
        line-height: 1;
    }
    
    /* Hide the old stats structure elements if needed, or re-purpose them */
    .stats-apps, .stats-separator, .stats-record {
        display: none; /* Hide old inline stats */
    }

    .sponsor-logo {
        filter: none; /* Full color */
        opacity: 1;
        max-height: 48px; /* Slightly larger on mobile */
        max-width: 140px;
    }
}
