/* ==========================================================================
   AoE2 Unit Analyzer - Matchup Advisor Styles
   Extends base.css -- do NOT duplicate body, container, header, nav, or h1 rules.
   ========================================================================== */

/* --- Civ Picker --- */
.ma-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}
.ma-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 130px;
    min-height: 100px;
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.25s ease;
}
.ma-slot:hover {
    border-color: rgba(255, 255, 255, 0.2);
}
.ma-slot.active {
    border-color: var(--gold);
    box-shadow: 0 0 16px rgba(201, 168, 76, 0.2);
}
.ma-slot-left.filled {
    border-color: var(--gold);
    background: rgba(201, 168, 76, 0.08);
}
.ma-slot-right.filled {
    border-color: var(--team2);
    background: rgba(52, 152, 219, 0.08);
}
.ma-slot-placeholder {
    color: var(--text-dim);
    font-size: 0.85rem;
}
.ma-slot-emblem {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(201, 168, 76, 0.4);
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 6px;
}
.ma-slot-right .ma-slot-emblem {
    border-color: rgba(52, 152, 219, 0.5);
}
.ma-slot-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}
.ma-vs {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* --- Civ Grid --- */
.ma-civ-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 6px;
    max-width: 900px;
    margin: 0 auto 24px;
}
.ma-civ-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    color: var(--text);
}
.ma-civ-card:hover {
    transform: translateY(-2px);
    border-color: rgba(201, 168, 76, 0.3);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.ma-civ-card.selected-left {
    border-color: var(--gold);
    background: rgba(201, 168, 76, 0.15);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.3);
}
.ma-civ-card.selected-right {
    border-color: var(--team2);
    background: rgba(52, 152, 219, 0.15);
    box-shadow: 0 0 12px rgba(52, 152, 219, 0.3);
}
.ma-civ-emblem {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(201, 168, 76, 0.4);
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 4px;
}
.ma-civ-card-name {
    font-size: 0.7rem;
    text-align: center;
    line-height: 1.2;
}

/* --- Age Toggle --- */
.ma-controls {
    text-align: center;
    margin-bottom: 20px;
}
.ma-age-toggle {
    display: inline-flex;
    gap: 0;
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: 8px;
    overflow: hidden;
}
.ma-age-btn {
    padding: 6px 18px;
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ma-age-btn:hover {
    background: rgba(201, 168, 76, 0.1);
}
.ma-age-btn.active {
    background: rgba(201, 168, 76, 0.2);
    color: var(--gold);
}

/* --- Section Cards (Cavalry, Ranged, Infantry, Siege) --- */
.ma-sections {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    max-width: 1100px;
    margin: 0 auto;
}
.ma-section {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}
.ma-section-header {
    padding: 10px 14px;
    background: rgba(201, 168, 76, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gold);
    text-align: center;
}
.ma-section-body {
    padding: 10px;
}

/* --- Unit Line Row --- */
.ma-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.ma-row:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.ma-row-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 6px;
}

/* --- Unit Side (one civ in a row) --- */
.ma-unit-side {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s ease;
}
.ma-unit-side.winner {
    background: rgba(46, 204, 113, 0.06);
    border-color: rgba(46, 204, 113, 0.15);
}
.ma-unit-side.na {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.35;
}
.ma-na-text {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-style: italic;
}

/* --- Unit Name Row --- */
.ma-unit-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.ma-unit-emblem {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid rgba(201, 168, 76, 0.3);
    object-fit: cover;
    flex-shrink: 0;
}
.ma-unit-icon {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
}
.ma-unit-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* --- Percentile Bar --- */
.ma-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ma-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
}
.ma-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}
.ma-percentile {
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 36px;
    text-align: right;
}

/* --- Strength Label --- */
.ma-strength {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* --- Multi-unit (additional units in same line) --- */
.ma-extra-unit {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.06);
    opacity: 0.8;
}

/* --- Loading --- */
.ma-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px;
    color: var(--text-muted);
}
.ma-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(201, 168, 76, 0.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: maSpin 0.8s linear infinite;
    margin-bottom: 10px;
}
@keyframes maSpin {
    to { transform: rotate(360deg); }
}

/* --- Beats Row (sim overlay) --- */
.ma-beats-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    min-height: 20px;
    flex-wrap: wrap;
}
.ma-beats-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 2px;
}
.ma-beats-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}
.ma-beats-icon {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}
.ma-beats-icon:hover {
    transform: scale(1.3);
    z-index: 1;
}
.ma-beats-icon.exclusive {
    border-color: var(--gold);
    box-shadow: 0 0 6px rgba(201, 168, 76, 0.4);
}
.ma-beats-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(201, 168, 76, 0.15);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: maSpin 0.8s linear infinite;
}

/* --- Sim overlay extra rows (pop wins, eco wins, losses) --- */
.ma-sim-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    min-height: 0;
    flex-wrap: wrap;
}
.ma-sim-row:empty {
    display: none;
}
.ma-label-pop {
    color: #3498db;
}
.ma-label-eco {
    color: #f39c12;
}
.ma-label-loss {
    color: #e74c3c;
}
.ma-beats-icon.pop-win {
    border-color: rgba(52, 152, 219, 0.4);
    opacity: 0.75;
}
.ma-beats-icon.eco-win {
    border-color: rgba(243, 156, 18, 0.4);
    opacity: 0.75;
}
.ma-beats-icon.loss {
    border-color: rgba(231, 76, 60, 0.4);
    opacity: 0.65;
}

/* --- Gap icon categories (combo card) --- */
.ma-gap-icon {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}
.ma-gap-icon:hover {
    transform: scale(1.3);
    z-index: 1;
}
.ma-gap-icon.gap-loss {
    border: 2px solid #e74c3c;
    opacity: 1;
}
.ma-gap-icon.gap-pop {
    border: 2px dashed #3498db;
    opacity: 0.8;
}
.ma-gap-icon.gap-eco {
    border: 2px dashed #f39c12;
    opacity: 0.8;
}
.ma-combo-gap-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}

/* --- Top Units Section --- */
.ma-top-units {
    max-width: 1100px;
    margin: 0 auto 20px;
    border: 1px solid rgba(201, 168, 76, 0.2);
    border-radius: 10px;
    background: rgba(201, 168, 76, 0.04);
    overflow: hidden;
}
.ma-top-units-header {
    padding: 8px 14px;
    background: rgba(201, 168, 76, 0.1);
    border-bottom: 1px solid rgba(201, 168, 76, 0.15);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gold);
    text-align: center;
}
.ma-top-units-body {
    display: flex;
    gap: 16px;
    padding: 12px;
}
.ma-top-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ma-top-empty {
    padding: 16px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    font-style: italic;
}

/* --- Gold Combo Card --- */
.ma-gold-combo-card {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(218, 165, 32, 0.08);
    border: 1px solid rgba(218, 165, 32, 0.25);
    margin-bottom: 10px;
}
.ma-gold-combo-header {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}
.ma-gold-combo-pair {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.ma-gold-combo-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
}
.ma-gold-combo-plus {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gold);
    margin: 0 2px;
}
.ma-gold-combo-summary {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 4px 0;
}
.ma-gold-combo-summary strong {
    color: var(--gold);
    font-weight: 700;
}

/* --- Ease statements on combo cards --- */
.ma-ease-statement {
    font-size: 0.68rem;
    line-height: 1.35;
    margin-top: 6px;
    padding: 5px 8px;
    border-radius: 6px;
    font-style: italic;
}
.ma-ease-upside {
    color: #7ebd7e;
    background: rgba(126, 189, 126, 0.08);
    border-left: 2px solid rgba(126, 189, 126, 0.3);
}
.ma-ease-downside {
    color: #d4856a;
    background: rgba(212, 133, 106, 0.08);
    border-left: 2px solid rgba(212, 133, 106, 0.3);
}
.ma-ease-neutral {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border-left: 2px solid rgba(255, 255, 255, 0.1);
}

/* --- Light Mode Overrides --- */
[data-theme="light"] .ma-slot {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .ma-slot-left.filled {
    background: rgba(139, 105, 20, 0.06);
}
[data-theme="light"] .ma-slot-right.filled {
    background: rgba(52, 152, 219, 0.06);
}
[data-theme="light"] .ma-civ-card {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .ma-civ-card:hover {
    border-color: rgba(139, 105, 20, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .ma-civ-card.selected-left {
    background: rgba(139, 105, 20, 0.1);
}
[data-theme="light"] .ma-civ-card.selected-right {
    background: rgba(52, 152, 219, 0.1);
}
[data-theme="light"] .ma-section {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .ma-section-header {
    background: rgba(139, 105, 20, 0.08);
    border-bottom-color: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .ma-unit-side {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .ma-unit-side.winner {
    background: rgba(42, 154, 80, 0.06);
    border-color: rgba(42, 154, 80, 0.15);
}
[data-theme="light"] .ma-bar {
    background: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .ma-age-toggle {
    border-color: rgba(139, 105, 20, 0.3);
}
[data-theme="light"] .ma-age-btn {
    background: rgba(0, 0, 0, 0.02);
}
[data-theme="light"] .ma-age-btn.active {
    background: rgba(139, 105, 20, 0.12);
}
[data-theme="light"] .ma-beats-icon {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .ma-beats-icon.exclusive {
    border-color: var(--gold);
    box-shadow: 0 0 6px rgba(139, 105, 20, 0.3);
}
[data-theme="light"] .ma-beats-icon.pop-win {
    border-color: rgba(41, 128, 185, 0.5);
}
[data-theme="light"] .ma-beats-icon.eco-win {
    border-color: rgba(211, 132, 0, 0.5);
}
[data-theme="light"] .ma-beats-icon.loss {
    border-color: rgba(192, 57, 43, 0.5);
}
[data-theme="light"] .ma-gap-icon {
    background: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .ma-gap-icon.gap-loss {
    border-color: #c0392b;
}
[data-theme="light"] .ma-gap-icon.gap-pop {
    border-color: #2980b9;
}
[data-theme="light"] .ma-gap-icon.gap-eco {
    border-color: #d38400;
}
[data-theme="light"] .ma-top-units {
    background: rgba(139, 105, 20, 0.04);
    border-color: rgba(139, 105, 20, 0.2);
}
[data-theme="light"] .ma-top-units-header {
    background: rgba(139, 105, 20, 0.08);
    border-bottom-color: rgba(139, 105, 20, 0.12);
}
[data-theme="light"] .ma-gold-combo-card {
    background: rgba(218, 165, 32, 0.06);
    border-color: rgba(218, 165, 32, 0.2);
}
[data-theme="light"] .ma-ease-upside {
    color: #3a7a3a;
    background: rgba(58, 122, 58, 0.06);
    border-left-color: rgba(58, 122, 58, 0.3);
}
[data-theme="light"] .ma-ease-downside {
    color: #a84832;
    background: rgba(168, 72, 50, 0.06);
    border-left-color: rgba(168, 72, 50, 0.3);
}
[data-theme="light"] .ma-ease-neutral {
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.02);
    border-left-color: rgba(0, 0, 0, 0.1);
}

/* --- Responsive: 768px — single column sections --- */
@media (max-width: 768px) {
    .ma-sections {
        grid-template-columns: 1fr;
    }
    .ma-picker {
        gap: 12px;
    }
    .ma-slot {
        width: 110px;
        min-height: 86px;
        padding: 10px;
    }
}

/* --- Responsive: 600px — compact civ grid --- */
@media (max-width: 600px) {
    .ma-top-units-body {
        flex-direction: column;
        gap: 10px;
    }
    .ma-civ-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 4px;
    }
    .ma-civ-emblem {
        width: 32px;
        height: 32px;
    }
    .ma-civ-card-name {
        font-size: 0.62rem;
    }
    .ma-row {
        flex-direction: column;
        gap: 4px;
    }
    .ma-slot {
        width: 90px;
        min-height: 76px;
    }
    .ma-vs {
        font-size: 1rem;
    }
}
