/* ============================================================
   BATTLE MODE STYLES
   ============================================================ */

/* Overlay */
#battle-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: #0d0d1a;
    z-index: 9998;
    display: flex; flex-direction: column;
    overflow: hidden;
}

/* Panel */
.btl-panel {
    display: flex; flex-direction: column;
    height: 100%; width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* Header */
.btl-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px;
    background: #1a1a2e;
    border-bottom: 2px solid #7c3aed;
    flex-shrink: 0;
}
.btl-title {
    font-size: 1.1rem; font-weight: 700; color: #e0e0e0;
    font-family: sans-serif;
}
.btl-close {
    background: #222240; border: 1px solid #333360; color: #aaa;
    font-size: 0.78rem; font-weight: 600;
    cursor: pointer; padding: 6px 14px; border-radius: 6px;
    font-family: sans-serif; transition: all 0.15s;
}
.btl-close:hover { background: #f8717133; border-color: #f87171; color: #f87171; }

/* Tabs */
.btl-tabs {
    display: flex; background: #151528; flex-shrink: 0;
    border-bottom: 1px solid #2a2a4a;
}
.btl-tab {
    flex: 1; padding: 10px 8px; border: none; background: none;
    color: #888; font-size: 0.82rem; font-weight: 600;
    cursor: pointer; font-family: sans-serif;
    transition: color 0.15s, border-color 0.15s;
    border-bottom: 2px solid transparent;
}
.btl-tab.active {
    color: #a78bfa;
    border-bottom-color: #7c3aed;
}
.btl-tab:hover:not(.active) { color: #bbb; }

/* Body */
.btl-body {
    flex: 1; overflow-y: auto; padding: 12px;
    -webkit-overflow-scrolling: touch;
}

/* ---- OVERVIEW TAB ---- */
.btl-armies {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 600px) {
    .btl-armies { grid-template-columns: 1fr; }
}

.btl-army {
    background: #1a1a2e;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #2a2a4a;
}
.btl-army-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 4px;
}
.btl-army-header.mine .btl-faction { color: #a78bfa; }
.btl-army-header.opp .btl-faction { color: #f87171; }
.btl-faction { font-weight: 700; font-size: 0.95rem; }
.btl-pts { font-size: 0.85rem; color: #888; font-weight: 600; }
.btl-army-det { font-size: 0.78rem; color: #666; margin-bottom: 6px; }
.btl-army-stats { font-size: 0.75rem; color: #555; margin-bottom: 8px; }

.btl-unit-list {
    max-height: 200px; overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}
.btl-unit {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 0; font-size: 0.8rem; color: #ccc;
    border-bottom: 1px solid #1f1f35;
}
.btl-unit:last-child { border-bottom: none; }
.btl-enh { color: #a78bfa; font-size: 0.72rem; }
.btl-unit-pts { color: #888; font-size: 0.75rem; margin-left: auto; padding-left: 8px; flex-shrink: 0; }

/* Import UI */
.btl-import-methods {
    display: flex; gap: 8px; margin: 12px 0;
}
.btl-import-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: #222240; border: 1px solid #333360; border-radius: 8px;
    padding: 12px 8px; cursor: pointer; color: #ccc;
    font-size: 0.75rem; font-family: sans-serif;
    transition: background 0.15s, border-color 0.15s;
}
.btl-import-btn:hover {
    background: #2a2a50; border-color: #7c3aed;
}
.btl-import-icon { font-size: 1.3rem; }

.btl-import-form {
    display: flex; flex-direction: column; gap: 8px; margin-top: 8px;
}
.btl-input, .btl-textarea, .btl-select {
    background: #111125; border: 1px solid #333360; border-radius: 6px;
    padding: 8px 10px; color: #ddd; font-size: 0.82rem;
    font-family: sans-serif; outline: none; width: 100%;
    box-sizing: border-box;
}
.btl-input:focus, .btl-textarea:focus, .btl-select:focus {
    border-color: #7c3aed;
}
.btl-textarea { resize: vertical; min-height: 80px; }
.btl-select { appearance: auto; }

.btl-import-row {
    display: flex; gap: 8px; align-items: stretch;
}
.btl-import-row .btl-select { flex: 1; }

/* Photo upload */
.btl-file-input { display: none; }
.btl-photo-label {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: #1a1a35; border: 2px dashed #333360; border-radius: 8px;
    padding: 20px; cursor: pointer; color: #888; font-size: 0.8rem;
    text-align: center; transition: border-color 0.15s;
}
.btl-photo-label:hover { border-color: #7c3aed; }

/* Buttons */
.btl-btn {
    background: #7c3aed; border: none; color: #fff; padding: 8px 16px;
    border-radius: 6px; cursor: pointer; font-size: 0.82rem; font-weight: 600;
    font-family: sans-serif; transition: background 0.15s;
}
.btl-btn:hover { background: #6d28d9; }
.btl-btn:active { background: #5b21b6; }

.btl-btn-clear {
    background: none; border: 1px solid #444; color: #888;
    padding: 5px 12px; border-radius: 5px; cursor: pointer;
    font-size: 0.75rem; margin-top: 8px; font-family: sans-serif;
}
.btl-btn-clear:hover { border-color: #f87171; color: #f87171; }

.btl-btn-ai {
    width: 100%; margin-top: 12px; padding: 10px;
    font-size: 0.88rem;
}

/* Loading + Error */
.btl-loading {
    text-align: center; color: #a78bfa; padding: 16px;
    font-size: 0.85rem; font-family: sans-serif;
}
.btl-loading::after {
    content: ''; display: inline-block; width: 14px; height: 14px;
    border: 2px solid #7c3aed; border-top-color: transparent;
    border-radius: 50%; animation: btl-spin 0.8s linear infinite;
    margin-left: 8px; vertical-align: middle;
}
@keyframes btl-spin { to { transform: rotate(360deg); } }

.btl-error {
    text-align: center; color: #f87171; padding: 12px;
    font-size: 0.82rem; font-family: sans-serif;
}

/* ---- MATCHUP ANALYSIS ---- */
.btl-matchup {
    margin-top: 12px; padding: 12px;
    background: #1a1a2e; border-radius: 8px; border: 1px solid #2a2a4a;
}
.btl-matchup-title {
    font-size: 0.9rem; font-weight: 700; color: #e0e0e0;
    margin-bottom: 10px; font-family: sans-serif;
}
.btl-matchup-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
@media (max-width: 500px) {
    .btl-matchup-grid { grid-template-columns: repeat(2, 1fr); }
}

.btl-stat-card {
    background: #151528; border-radius: 6px; padding: 10px;
    text-align: center; border: 1px solid #222245;
}
.btl-stat-label {
    font-size: 0.7rem; color: #666; text-transform: uppercase;
    font-weight: 600; margin-bottom: 4px; font-family: sans-serif;
}
.btl-stat-vs {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 1rem; font-weight: 700; font-family: sans-serif;
}
.btl-stat-mine { color: #a78bfa; }
.btl-stat-opp { color: #f87171; }
.btl-stat-sep { color: #444; font-size: 0.75rem; font-weight: 400; }
.btl-stat-note {
    font-size: 0.7rem; margin-top: 2px; color: #666;
    font-family: sans-serif;
}
.btl-stat-note.advantage { color: #4ade80; }
.btl-stat-note.disadvantage { color: #f87171; }

/* AI Analysis */
.btl-ai-text {
    margin-top: 10px; padding: 10px;
    background: #111125; border-radius: 6px;
    color: #ccc; font-size: 0.82rem; line-height: 1.5;
    font-family: sans-serif;
}
.btl-ai-text h4 {
    color: #a78bfa; margin: 0 0 8px; font-size: 0.88rem;
}
.btl-ai-text ul {
    margin: 0; padding-left: 18px;
}
.btl-ai-text li {
    margin-bottom: 6px;
}

/* ---- UNITS TAB ---- */
.btl-units-section { padding-bottom: 16px; }
.btl-section-title {
    font-size: 0.88rem; font-weight: 700; color: #e0e0e0;
    padding: 8px 0 6px; font-family: sans-serif;
    border-bottom: 1px solid #2a2a4a; margin-bottom: 8px;
}
.btl-section-title.mine { color: #a78bfa; border-color: #7c3aed33; }
.btl-section-title.opp { color: #f87171; border-color: #f8717133; margin-top: 16px; }

.btl-units-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

.btl-unit-card {
    background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 6px;
    padding: 10px; cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
}
.btl-unit-card:hover {
    border-color: #7c3aed; transform: translateY(-1px);
}
.btl-unit-card.mine { border-left: 3px solid #7c3aed44; }
.btl-unit-card.opp { border-left: 3px solid #f8717144; }

.btl-uc-name {
    font-size: 0.82rem; font-weight: 700; color: #e0e0e0;
    margin-bottom: 4px; font-family: sans-serif;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btl-uc-stats {
    display: flex; gap: 6px; font-size: 0.72rem; color: #888;
    margin-bottom: 4px; font-family: sans-serif;
}
.btl-uc-stats span {
    background: #111125; padding: 1px 4px; border-radius: 3px;
}
.btl-uc-meta {
    display: flex; justify-content: space-between;
    font-size: 0.7rem; color: #555; font-family: sans-serif;
}

.btl-empty {
    text-align: center; color: #555; padding: 24px;
    font-size: 0.85rem; font-family: sans-serif;
}

/* ---- STRATAGEMS TAB ---- */
.btl-strats-section { padding-bottom: 16px; }
.btl-strats-tip {
    text-align: center; color: #888; padding: 20px 12px;
    font-size: 0.85rem; font-family: sans-serif;
}
.btl-strats-tip p { margin: 0 0 12px; }
.btl-strats-tip strong { color: #a78bfa; }

.btl-strat-card {
    background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 6px;
    padding: 10px; margin-bottom: 8px;
}
.btl-strat-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 4px;
}
.btl-strat-name {
    font-weight: 700; font-size: 0.85rem; color: #e0e0e0;
    font-family: sans-serif;
}
.btl-strat-cp {
    color: #a78bfa; font-weight: 700; font-size: 0.82rem;
    font-family: sans-serif;
}
.btl-strat-phase {
    font-size: 0.72rem; color: #666; margin-bottom: 4px;
    font-family: sans-serif;
}
.btl-strat-desc {
    font-size: 0.78rem; color: #999; line-height: 1.4;
    font-family: sans-serif;
}

/* ---- RULES TAB ---- */
.btl-rules-section { padding-bottom: 16px; }
.btl-rules-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px; margin-bottom: 8px;
}
.btl-rule-card {
    background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 8px;
    padding: 14px 10px; text-align: center; cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
}
.btl-rule-card:hover {
    border-color: #7c3aed; transform: translateY(-1px);
}
.btl-rule-icon { font-size: 1.5rem; margin-bottom: 4px; }
.btl-rule-name {
    font-size: 0.78rem; font-weight: 600; color: #ccc;
    font-family: sans-serif;
}

/* Round tracker */
.btl-round-tracker {
    display: flex; gap: 6px;
}
.btl-round {
    flex: 1; padding: 8px 4px; background: #1a1a2e;
    border: 1px solid #2a2a4a; border-radius: 6px;
    color: #888; font-size: 0.75rem; font-weight: 600;
    cursor: pointer; font-family: sans-serif;
    transition: all 0.15s;
}
.btl-round.done {
    background: #7c3aed33; border-color: #7c3aed;
    color: #a78bfa;
}
.btl-round:hover:not(.done) { border-color: #555; }

/* Score */
.btl-score {
    display: flex; align-items: center; justify-content: center;
    gap: 16px; margin-top: 8px;
}
.btl-score-side { text-align: center; }
.btl-score-label {
    font-size: 0.72rem; color: #666; font-weight: 600;
    text-transform: uppercase; margin-bottom: 4px;
    font-family: sans-serif;
}
.btl-score-controls {
    display: flex; align-items: center; gap: 8px;
}
.btl-score-controls button {
    width: 32px; height: 32px; border-radius: 50%;
    background: #222240; border: 1px solid #333360;
    color: #ccc; font-size: 1.1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-family: sans-serif;
    transition: background 0.15s;
}
.btl-score-controls button:hover { background: #2a2a50; }
.btl-score-controls span {
    font-size: 1.5rem; font-weight: 700; color: #e0e0e0;
    min-width: 40px; text-align: center;
    font-family: sans-serif;
}
.btl-score-sep {
    font-size: 1.5rem; font-weight: 700; color: #444;
    font-family: sans-serif;
}

/* Scrollbar styling for battle panel */
.btl-body::-webkit-scrollbar { width: 4px; }
.btl-body::-webkit-scrollbar-track { background: transparent; }
.btl-body::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
.btl-unit-list::-webkit-scrollbar { width: 3px; }
.btl-unit-list::-webkit-scrollbar-track { background: transparent; }
.btl-unit-list::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 2px; }

/* Quota note */
.btl-quota-note {
    text-align: right; font-size: 0.7rem; color: #555;
    margin-top: 6px; font-family: sans-serif;
}
