/* ==========================================================================
   AoE2 Unit Analyzer - Team Analysis Page Styles
   Extends base.css — do NOT duplicate body, container, header, nav, or h1 rules.
   ========================================================================== */

/* --- Team Picker Layout --- */
.team-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.team-panel {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
}

.team1-panel { border-color: rgba(192, 57, 43, 0.4); }
.team2-panel { border-color: rgba(41, 128, 185, 0.4); }

.team-title {
    text-align: center;
    margin: 0 0 12px;
    font-size: 1rem;
    font-family: "Cinzel", serif;
}
.team1-title { color: var(--team1); }
.team2-title { color: var(--team2); }

/* --- Team Slots (selected civs) --- */
.team-slots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
    min-height: 70px;
}

.team-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
    cursor: pointer;
    transition: opacity 0.2s;
}
.team-slot:hover { opacity: 0.7; }

.team-slot .slot-emblem {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border);
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
}
.team-slot.filled .slot-emblem { border-color: var(--gold); }

.team-slot .slot-label {
    font-size: 0.65rem;
    text-align: center;
    margin-top: 3px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60px;
}
.team-slot.empty .slot-emblem {
    border-style: dashed;
    opacity: 0.4;
}

/* --- Civ Grid (inside each team panel) --- */
.team-panel .civ-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
}

.team-panel .civ-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px 5px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text);
}
.team-panel .civ-card:hover {
    transform: translateY(-1px);
    border-color: rgba(201, 168, 76, 0.3);
}
.team-panel .civ-card .civ-emblem {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(201, 168, 76, 0.3);
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 3px;
}
.team-panel .civ-card .civ-card-name {
    font-size: 0.6rem;
    text-align: center;
    line-height: 1.1;
}

.team1-panel .civ-card.selected {
    border-color: var(--team1);
    background: rgba(192, 57, 43, 0.15);
}
.team2-panel .civ-card.selected {
    border-color: var(--team2);
    background: rgba(41, 128, 185, 0.15);
}
.team-panel .civ-card.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* --- Analyze Button (reuse matchup pattern) --- */
.compare-btn {
    display: block;
    margin: 10px auto 20px;
    padding: 15px 40px;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    border: none;
    border-radius: 25px;
    color: var(--bg-deep);
    font-family: "Cinzel", serif;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.compare-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.compare-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 168, 76, 0.4);
}

/* --- Results Container --- */
.results-container {
    max-width: 1000px;
    margin: 0 auto;
}

/* --- Stage Card --- */
.stage-card {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.02);
}

.stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.stage-title {
    font-family: "Cinzel", serif;
    font-size: 1.2rem;
    color: var(--gold);
}
.stage-advantage {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 8px;
}
.stage-advantage.team1 {
    color: var(--team1);
    background: rgba(192, 57, 43, 0.15);
}
.stage-advantage.team2 {
    color: var(--team2);
    background: rgba(41, 128, 185, 0.15);
}
.stage-advantage.even {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
}

/* --- Stage Tabs (sub-category breakdown) --- */
.stage-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}
.stage-tab {
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}
.stage-tab:hover {
    color: var(--text);
}
.stage-tab.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

/* --- Stage Columns (team1 vs team2) --- */
.stage-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.stage-column-header {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.stage-column-header.team1 { color: var(--team1); }
.stage-column-header.team2 { color: var(--team2); }

/* --- Unit Cards in Stage --- */
.unit-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.unit-entry-icons {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.unit-entry .civ-emblem {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(201, 168, 76, 0.3);
    object-fit: cover;
    flex-shrink: 0;
}
.unit-entry .unit-icon {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
}
.unit-entry-info {
    flex: 1;
    min-width: 0;
}
.unit-entry-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}
.unit-entry-civ {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.unit-entry-stats {
    text-align: right;
    flex-shrink: 0;
}
.unit-entry-score {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold);
}
.unit-entry-meta {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.no-units-msg {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 8px 0;
}

/* --- Footer: civs without above-median units --- */
.stage-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Loading spinner --- */
.loading-indicator {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}

/* --- Light Mode Overrides --- */
[data-theme="light"] .team-panel {
    background: rgba(0, 0, 0, 0.02);
}
[data-theme="light"] .team-panel .civ-card {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .team-panel .civ-card:hover {
    border-color: rgba(139, 105, 20, 0.35);
}
[data-theme="light"] .team1-panel .civ-card.selected {
    background: rgba(176, 41, 28, 0.1);
}
[data-theme="light"] .team2-panel .civ-card.selected {
    background: rgba(26, 108, 160, 0.1);
}
[data-theme="light"] .stage-card {
    background: rgba(0, 0, 0, 0.02);
}
[data-theme="light"] .unit-entry {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .stage-advantage.team1 {
    background: rgba(176, 41, 28, 0.1);
}
[data-theme="light"] .stage-advantage.team2 {
    background: rgba(26, 108, 160, 0.1);
}
[data-theme="light"] .stage-advantage.even {
    background: rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .team-slot .slot-emblem {
    background: rgba(0, 0, 0, 0.06);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .team-picker {
        grid-template-columns: 1fr;
    }
    .stage-columns {
        grid-template-columns: 1fr;
    }
}
