/* ==================== CSS Variables (ygbuff dark theme) ==================== */
:root {
    --bg-dark: #111827;
    --bg-light: #1f2937;
    --card-bg: #1e293b;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --border-color: rgba(255, 255, 255, 0.1);
    --hover-bg: rgba(59, 130, 246, 0.1);
    --text-highlight: #60a5fa;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ==================== Header ==================== */
.header { text-align: center; margin-bottom: 1.5rem; }
.header h1 { font-size: 1.8rem; font-weight: 700; }
.header h1 i { color: var(--accent-blue); }
.subtitle { color: var(--text-secondary); font-size: 0.9rem; }

/* ==================== Filters ==================== */
.filters-section {
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.filter-row:last-child { margin-bottom: 0; }

.filter-group { display: flex; flex-direction: column; gap: 0.4rem; }
.filter-group label {
    font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.filter-group label i { margin-right: 0.3rem; color: var(--accent-blue); }

.filter-select, .filter-input {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}
.filter-select:focus, .filter-input:focus { outline: none; border-color: var(--accent-blue); }

/* ==================== Hero Filter ==================== */
.hero-filter-wrapper { position: relative; }
.hero-search { width: 100%; }
.hero-suggestions {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-top: none; border-radius: 0 0 8px 8px;
    max-height: 200px; overflow-y: auto; z-index: 100;
}
.hero-suggestion-item {
    padding: 0.4rem 0.75rem; cursor: pointer; font-size: 0.85rem;
    display: flex; align-items: center; gap: 0.5rem; transition: background 0.15s;
}
.hero-suggestion-item:hover { background: var(--hover-bg); }
.hero-suggestion-item img { width: 28px; height: 20px; object-fit: cover; border-radius: 3px; }

.selected-heroes { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; min-height: 28px; }
.hero-chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    background: rgba(59,130,246,0.2); border: 1px solid rgba(59,130,246,0.4);
    border-radius: 20px; padding: 0.15rem 0.5rem;
    font-size: 0.75rem; color: var(--text-highlight); cursor: pointer; transition: background 0.15s;
}
.hero-chip:hover { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.4); color: #ef4444; }
.hero-chip img { width: 22px; height: 16px; object-fit: cover; border-radius: 2px; }
.hero-chip .remove-icon { font-size: 0.7rem; }

/* ==================== Buttons ==================== */
.compute-btn {
    background: var(--accent-blue); color: white; border: none; border-radius: 8px;
    padding: 0.55rem 1.25rem; font-size: 0.9rem; font-weight: 600; cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex; align-items: center; gap: 0.4rem; width: 100%; justify-content: center;
}
.compute-btn:hover { background: #2563eb; }
.compute-btn:active { transform: scale(0.98); }
.compute-btn:disabled { background: #374151; cursor: not-allowed; }
.filter-action-group { justify-content: flex-end; }
.filter-action-group label { visibility: hidden; }

/* ==================== Loading / Status ==================== */
.loading { text-align: center; padding: 2rem; color: var(--text-secondary); display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 1s linear infinite; }
.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 1rem; display: block; }
.error-state {
    background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
    border-radius: 8px; padding: 1rem; color: #ef4444; display: none;
}

/* ==================== Results ==================== */
.results-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.results-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.results-count { font-size: 0.8rem; color: var(--text-muted); }

.combo-list { display: flex; flex-direction: column; gap: 0.5rem; }

.combo-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px; overflow: hidden; transition: border-color 0.2s;
}
.combo-item:hover { border-color: rgba(59,130,246,0.3); }

.combo-main {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.6rem 1rem; cursor: pointer;
}

.combo-rank { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); min-width: 28px; text-align: right; }

.combo-heroes { display: flex; align-items: center; gap: 0.35rem; flex: 1; flex-wrap: wrap; }

/* Image-only chip — no text */
.combo-hero-chip {
    display: inline-flex; align-items: center;
    background: rgba(255,255,255,0.06);
    border-radius: 6px;
    padding: 2px;
    overflow: hidden;
}
.combo-hero-chip img { width: 42px; height: 30px; object-fit: cover; border-radius: 4px; display: block; }
.hero-text-fallback { font-size: 0.7rem; color: var(--text-muted); padding: 0 4px; }

.combo-plus { color: var(--text-muted); font-size: 1rem; font-weight: 700; line-height: 1; }

.combo-stats { display: flex; align-items: center; gap: 1rem; flex-shrink: 0; }
.combo-count { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); }
.combo-count span { color: var(--text-muted); font-weight: normal; font-size: 0.75rem; }

.wr-badge { padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.8rem; font-weight: 700; }
.wr-good  { background: rgba(16,185,129,0.2); color: #10b981; }
.wr-neutral { background: rgba(59,130,246,0.2); color: #60a5fa; }
.wr-bad   { background: rgba(239,68,68,0.2);  color: #ef4444; }

.expand-icon { color: var(--text-muted); font-size: 0.9rem; transition: transform 0.2s; flex-shrink: 0; }
.expand-icon.open { transform: rotate(180deg); }

/* ==================== Expanded samples ==================== */
.combo-samples {
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    background: var(--bg-light);
    display: none;
}
.combo-samples.open { display: block; }

.sample-item {
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 0.75rem 0;
}
.sample-item:last-child { border-bottom: none; padding-bottom: 0; }

.sample-meta {
    display: flex; align-items: center; gap: 0.6rem;
    margin-bottom: 0.6rem;
}
.sample-win  { font-size: 0.82rem; font-weight: 700; color: var(--success-color); flex-shrink: 0; }
.sample-loss { font-size: 0.82rem; font-weight: 700; color: var(--danger-color); flex-shrink: 0; }
.sample-tournament { font-size: 0.78rem; color: var(--text-secondary); }
.sample-date { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }

/* ==================== Draft Card ==================== */
.draft-card {
    display: flex; align-items: flex-start; gap: 0.6rem;
    background: #0f1623;
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
}

.draft-team-panel {
    flex: 1; min-width: 0;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    border: 2px solid transparent;
    background: #151e2d;
    transition: border-color 0.15s;
}

/* Green border for winning team */
.draft-panel-winner {
    border-color: #10b981;
    background: #0d1f18;
}

.draft-team-name {
    font-size: 0.82rem; font-weight: 700; color: var(--text-secondary);
    margin-bottom: 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.draft-winner-name { color: var(--success-color); }

.draft-picks-row {
    display: flex; gap: 7px; flex-wrap: nowrap; margin-bottom: 6px;
}

.draft-bans-row { display: flex; gap: 5px; flex-wrap: nowrap; }

/* ==================== Slot classes (picks + bans with position labels) ==================== */
.d-slot {
    position: relative;
    display: inline-block;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.18);
    background: #111;
    flex-shrink: 0;
}
.d-slot-pick {
    width: 62px; height: 44px;
}
.d-slot-ban {
    width: 46px; height: 34px;
}
.d-slot img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.d-slot-ban img {
    filter: grayscale(20%); opacity: 0.92;
}
.d-num {
    position: absolute;
    left: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    padding: 1px 4px;
    border-top-right-radius: 4px;
    font-size: 10px; font-weight: 700;
    z-index: 2;
    line-height: 1.3;
}

.draft-vs {
    font-size: 0.72rem; font-weight: 800; color: var(--text-muted);
    padding-top: 1.8rem; flex-shrink: 0; align-self: flex-start;
}

/* ==================== Mobile ==================== */
@media (max-width: 768px) {
    .app-container { padding: 0.5rem; }
    .filters-section { padding: 0.6rem; margin-bottom: 0.75rem; }
    .header { margin-bottom: 0.75rem; }
    .header h1 { font-size: 1.2rem; }
    .subtitle { font-size: 0.75rem; }

    /* Pack 9 filters into two rows (5 + 4) */
    .filter-row {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0.3rem;
        margin-bottom: 0.4rem;
    }
    .filter-group { gap: 0.15rem; min-width: 0; }
    .filter-group label {
        font-size: 0.58rem;
        letter-spacing: 0.2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .filter-group label i { display: none; }
    .filter-select, .filter-input {
        padding: 0.3rem 0.35rem;
        font-size: 0.72rem;
        border-radius: 6px;
        -webkit-appearance: none;
        appearance: none;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    input.filter-input[type="date"] {
        font-size: 0.65rem;
        padding: 0.3rem 0.25rem;
    }

    /* Second filter row: hero filter full-width, compute below */
    .filter-row + .filter-row {
        grid-template-columns: 1fr;
    }
    .filter-row + .filter-row .filter-group[style*="grid-column"] {
        grid-column: 1 / -1 !important;
    }
    .filter-row + .filter-row .filter-group label {
        font-size: 0.7rem;
        white-space: normal;
    }
    .filter-action-group label { display: none; }
    .compute-btn { padding: 0.45rem 1rem; font-size: 0.85rem; }

    /* Combo cards: single compact row */
    .combo-main { flex-wrap: nowrap; gap: 0.4rem; padding: 0.45rem 0.6rem; }
    .combo-stats { width: auto; gap: 0.4rem; flex-shrink: 0; }
    .combo-heroes { gap: 0.25rem; flex-wrap: nowrap; min-width: 0; }
    .combo-hero-chip img { width: 30px; height: 22px; }
    .combo-count { font-size: 0.7rem; }
    .combo-count span { font-size: 0.62rem; }
    .wr-badge { padding: 0.1rem 0.35rem; font-size: 0.68rem; }
    .combo-rank { font-size: 0.62rem; min-width: 18px; }
    .combo-plus { font-size: 0.8rem; }
    .expand-icon { font-size: 0.75rem; }

    .results-title { font-size: 0.85rem; }
    .results-count { font-size: 0.7rem; }

    .draft-card { flex-direction: column; }
    .draft-vs { padding-top: 0; align-self: center; }
    .d-slot-pick { width: 46px; height: 33px; }
    .d-slot-ban { width: 34px; height: 25px; }
}
