/* ── Search Page ─────────────────────────────────────────────────────────── */

.search-page {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 15px 40px;
}

.search-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 20px;
}

/* ── Filter Panel ─────────────────────────────────────────────────────────── */

.filter-panel {
    background: rgba(0, 0, 0, 0.7);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.filter-row--actions {
    align-items: center;
    gap: 12px;
}

.filter-text-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-text-group label {
    font-size: 0.72rem;
    color: #aaaaaa;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-text-group input,
.filter-text-group select {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(0, 0, 0, 0.35);
    border-radius: 6px;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 0.88rem;
    padding: 6px 10px;
    min-width: 160px;
    outline: none;
    transition: border-color 0.2s;
}

.filter-text-group input:focus,
.filter-text-group select:focus {
    border-color: #ff8c00;
}

.filter-text-group--small input,
.filter-text-group--small select {
    min-width: 110px;
}

.filter-text-group select option {
    background: #1c1c1c;
}

/* ── Checkboxes ───────────────────────────────────────────────────────────── */

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 2px;
    color: #ccc;
    font-size: 0.88rem;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.filter-checkbox input[type=checkbox] {
    accent-color: #ff8c00;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* ── Action buttons ───────────────────────────────────────────────────────── */

.btn-apply,
.btn-reset {
    padding: 7px 22px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    border: none;
}

.btn-apply {
    background: #ff8c00;
    color: #000;
}

.btn-apply:hover {
    background: #ffaa33;
    transform: translateY(-1px);
}

.btn-reset {
    background: rgba(255,255,255,0.1);
    color: #ccc;
    border: 1px solid rgba(255,255,255,0.2);
}

.btn-reset:hover {
    background: rgba(255,255,255,0.18);
}

/* ── Multi-select dropdowns ──────────────────────────────────────────────── */

.multiselect-wrap {
    position: relative;
}

.ms-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(0, 0, 0, 0.35);
    border-radius: 6px;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 0.88rem;
    padding: 6px 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s, background 0.2s;
    min-width: 120px;
    justify-content: space-between;
}

.ms-btn:hover,
.multiselect-wrap.ms-open .ms-btn {
    border-color: #ff8c00;
    background: rgba(255,140,0,0.1);
}

.ms-label {
    font-size: 0.72rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 1px;
}

.ms-count {
    background: rgba(255,140,0,0.15);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 0.78rem;
    color: #ccc;
}

.ms-count--active {
    background: rgba(255,140,0,0.5);
    color: #fff;
}

.ms-arrow {
    font-size: 0.65rem;
    color: #888;
    transition: transform 0.2s;
}

.multiselect-wrap.ms-open .ms-arrow {
    transform: rotate(180deg);
}

.ms-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 200;
    background: #000000;
    border: 1px solid rgba(255,140,0,0.4);
    border-radius: 8px;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    overflow: hidden;
}

.ms-dropdown--wide {
    min-width: 280px;
}

.multiselect-wrap.ms-open .ms-dropdown {
    display: block;
}

.ms-search {
    width: 100%;
    box-sizing: border-box;
    background: rgba(255,255,255,0.07);
    border: none;
    border-bottom: 1px solid rgba(255,140,0,0.25);
    color: #e0e0e0;
    font-family: inherit;
    font-size: 0.88rem;
    padding: 8px 12px;
    outline: none;
}

.ms-search:focus {
    background: rgba(255,140,0,0.08);
}

.ms-options {
    padding: 4px 0;
}

.ms-options--scroll {
    max-height: 220px;
    overflow-y: auto;
}

.ms-options--scroll::-webkit-scrollbar { width: 6px; }
.ms-options--scroll::-webkit-scrollbar-track { background: transparent; }
.ms-options--scroll::-webkit-scrollbar-thumb { background: rgba(255,140,0,0.4); border-radius: 3px; }

.ms-option {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    font-size: 0.95rem;
    color: #cccccc;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ms-option:hover {
    background: rgba(255,140,0,0.12);
    color: #fff;
}

.ms-option input[type=checkbox] {
    accent-color: #ff8c00;
    flex-shrink: 0;
    cursor: pointer;
}

.ms-envlogo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
    vertical-align: middle;
}

.ms-flag {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
    vertical-align: middle;
}

/* ── Tags filter group (multiselect + ? button) ─────────────────────────── */

.tags-filter-group {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.tag-info-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(255, 140, 0, 0.4);
    background: transparent;
    color: #ff8c00;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
    margin-bottom: 2px;
}

.tag-info-btn:hover {
    background: rgba(255, 140, 0, 0.15);
}

/* ── Tag Info Modal ──────────────────────────────────────────────────────── */

.tag-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.tag-modal-overlay.tag-modal--open {
    display: flex;
}

.tag-modal {
    background: #000000;
    border: 1px solid rgba(255, 140, 0, 0.4);
    /* border-top: 3px solid #ff8c00; */
    border-radius: 12px;
    width: min(680px, 92vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.tag-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tag-modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.tag-modal-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
}

.tag-modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.tag-modal-body {
    overflow-y: auto;
    padding: 12px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tag-modal-body::-webkit-scrollbar { width: 6px; }
.tag-modal-body::-webkit-scrollbar-track { background: transparent; }
.tag-modal-body::-webkit-scrollbar-thumb { background: rgba(255,140,0,0.4); border-radius: 3px; }

.tag-info-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.tag-info-row:last-child {
    border-bottom: none;
}

.tag-desc {
    color: #ccc;
    font-size: 0.88rem;
    line-height: 1.4;
}

.tag-desc--empty {
    color: #555;
    font-style: italic;
}

/* ── Results Header ──────────────────────────────────────────────────────── */

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.results-count {
    font-size: 0.95rem;
    color: #aaa;
}

.results-actions {
    display: flex;
    gap: 8px;
}

.btn-export {
    padding: 6px 16px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(9, 222, 59, 0.4);
    background: rgba(32, 207, 23, 0.1);
    color: #0fa519;
    transition: background 0.2s, transform 0.1s;
}

.btn-export:hover {
    background: rgba(255,140,0,0.25);
    transform: translateY(-1px);
}

.btn-export:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Records Table ───────────────────────────────────────────────────────── */

.results-wrap {
    margin-bottom: 16px;
}

.table-scroll {
    overflow-x: auto;
    background: rgb(0, 0, 0, 0.7);
    border-radius: 10px;
    border: 1px solid rgba(255,140,0,0.2);
}

.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: rgba(255,140,0,0.4); border-radius: 3px; }

.records-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.87rem;
    white-space: nowrap;
}

.records-table thead th {
    background: rgba(255,140,0,0.12);
    color: #ff8c00;
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255,140,0,0.3);
    white-space: nowrap;
}

.records-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.15s;
}

.records-table tbody tr:hover {
    background: rgba(255,140,0,0.06);
}

.records-table tbody td {
    padding: 7px 12px;
    color: #ddd;
    vertical-align: middle;
}

.col-id {
    color: #666 !important;
    font-size: 0.8rem;
    min-width: 55px;
}

.col-flag {
    width: 32px;
    text-align: center;
}

.col-env {
    width: 36px;
    text-align: center;
}

.col-game {
    white-space: nowrap;
}

.col-tags {
    min-width: 80px;
}

.col-info {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #999 !important;
    font-size: 0.82rem;
}

.rec-flag {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    vertical-align: middle;
}

.rec-envlogo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    vertical-align: middle;
}

.rec-tag {
    display: inline-block;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 6px;
    white-space: nowrap;
    margin: 1px 1px;
}

.rec-player-link,
.rec-map-link {
    color: #e0e0e0;
    text-decoration: none;
    transition: color 0.2s;
}

.rec-player-link:hover,
.rec-map-link:hover {
    color: #ff8c00;
    text-decoration: underline;
}

.uncertain {
    color: #ff6b6b;
}

/* ── Game badges ─────────────────────────────────────────────────────────── */

.game-badge {
    display: inline-block;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    letter-spacing: 0.03em;
    background: rgba(128,128,128,0.25);
    color: #ccc;
}

.game-badge--tmnf { background: rgba(76,175,80,0.25);  color: #4caf50; }
.game-badge--tm2  { background: rgba(33,150,243,0.25); color: #42a5f5; }
.game-badge--tmt  { background: rgba(255,152,0,0.25);  color: #ffa726; }
.game-badge--tmuf { background: rgba(156,39,176,0.25); color: #ce93d8; }
.game-badge--eswc { background: rgba(233,30,99,0.25);  color: #f06292; }
.game-badge--tms  { background: rgba(0,188,212,0.25);  color: #4dd0e1; }
.game-badge--tmo  { background: rgba(121,85,72,0.25);  color: #bcaaa4; }

/* ── Pagination ──────────────────────────────────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 10px 0 20px;
}

.pg-btn {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #ccc;
    font-family: inherit;
    font-size: 0.85rem;
    padding: 5px 11px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    min-width: 34px;
    text-align: center;
}

.pg-btn:hover:not([disabled]) {
    background: rgba(255,140,0,0.15);
    border-color: #ff8c00;
    color: #fff;
}

.pg-btn--active {
    background: #ff8c00 !important;
    border-color: #ff8c00 !important;
    color: #000 !important;
    font-weight: 700;
}

.pg-btn[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
}

.pg-ellipsis {
    color: #ffffff;
    padding: 5px 4px;
    font-size: 0.85rem;
}

.pg-info {
    color: #666;
    font-size: 0.82rem;
    margin-left: 8px;
    white-space: nowrap;
}

/* ── States ──────────────────────────────────────────────────────────────── */

.loading,
.no-results,
.error {
    text-align: center;
    padding: 50px 20px;
    color: #888;
    font-size: 0.95rem;
}

.error { color: #ff6b6b; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .filter-panel { padding: 14px; }

    .filter-row { flex-direction: column; gap: 8px; }

    .filter-text-group input,
    .filter-text-group select,
    .ms-btn { min-width: unset; width: 100%; }

    .multiselect-wrap { width: 100%; }

    .ms-dropdown { min-width: 100%; }

    .filter-row--actions { flex-direction: row; flex-wrap: wrap; }

    .results-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .search-title { font-size: 1.4rem; }

    .records-table { font-size: 0.8rem; }

    .records-table thead th,
    .records-table tbody td { padding: 6px 8px; }
}
