/* ── Reset & Base ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #0f0c29;
    color: #e0e0e0;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Top Bar ── */
#topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(15, 12, 41, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo {
    font-size: 1.4em;
    font-weight: 800;
    background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-info {
    font-size: 0.85em;
    color: #999;
}
.toggle-label {
    font-size: 0.8em;
    color: #999;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.toggle-label input { width: 14px; height: 14px; cursor: pointer; }
.row-height-select {
    background: #1e1e2e;
    color: #ccc;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 0.85em;
    cursor: pointer;
}
.row-height-select option {
    background: #1e1e2e;
    color: #ccc;
}

/* ── User Menu Dropdown ── */
.user-menu-wrapper { position: relative; }
.user-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 150;
    margin-top: 4px;
    background: #1a1740;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 4px 0;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.user-menu-dropdown.open { display: block; }
.user-menu-item {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #ccc;
    padding: 8px 16px;
    text-align: left;
    cursor: pointer;
    font-size: 0.85em;
}
.user-menu-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.user-menu-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 2px 0;
}
/* ── Mute Dropdown ── */
.mute-wrapper { position: relative; display: inline-flex; align-items: center; }
.mute-main-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; padding-right: 6px; }
.mute-arrow-btn {
    border-top-left-radius: 0; border-bottom-left-radius: 0;
    border-left: 1px solid rgba(255,255,255,0.1);
    padding: 6px 4px; font-size: 0.7em; min-width: 0;
}
.mute-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 150;
    margin-top: 4px;
    background: #1a1740;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 4px 0;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.mute-dropdown.hidden { display: none; }
.mute-option {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #ccc;
    padding: 8px 16px;
    text-align: left;
    cursor: pointer;
    font-size: 0.85em;
}
.mute-option:hover { background: rgba(255,255,255,0.08); color: #fff; }
.mute-option.active { color: #48dbfb; }

/* ── Date Range Picker ── */
.dr-wrapper {
    position: relative;
}
.dr-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 150;
    margin-top: 4px;
    background: #1a1740;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 10px;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.dr-dropdown.open { display: block; }
.dr-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}
.dr-preset {
    padding: 4px 10px;
    font-size: 0.75em;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.dr-preset:hover { background: rgba(255,255,255,0.06); color: #fff; }
.dr-preset.active {
    background: rgba(102,126,234,0.3);
    border-color: #667eea;
    color: #fff;
}
.dr-custom {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.dr-custom label {
    font-size: 0.7em;
    color: #999;
}
.dr-custom input[type="date"] {
    padding: 5px 8px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-size: 0.8em;
    outline: none;
    color-scheme: dark;
}
.dr-custom input[type="date"]:focus { border-color: #667eea; }
.dr-tz {
    margin-top: 8px;
    text-align: center;
}
.dr-tz select {
    background: #1e1e2e;
    color: #ccc;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.7em;
    cursor: pointer;
    width: 100%;
}
.dr-tz select option {
    background: #1e1e2e;
    color: #ccc;
}

/* ── Text Filter ── */
.text-filter-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    overflow: hidden;
}
.text-filter-wrapper input {
    background: transparent;
    border: none;
    color: #eee;
    padding: 5px 10px;
    font-size: 0.8em;
    width: 140px;
    outline: none;
}
.text-filter-wrapper input::placeholder {
    color: #666;
}
.regex-toggle {
    background: transparent;
    border: none;
    border-left: 1px solid rgba(255,255,255,0.12);
    color: #666;
    font-family: monospace;
    font-size: 0.75em;
    font-weight: 700;
    padding: 5px 8px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.regex-toggle.active {
    color: #feca57;
    background: rgba(254,202,87,0.12);
}
.regex-toggle:hover {
    color: #feca57;
}

/* ── Event Filter Dropdown ── */
.ef-wrapper {
    position: relative;
}
.ef-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 150;
    margin-top: 4px;
    background: #1a1740;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 8px 0;
    min-width: 200px;
    max-height: 320px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.ef-dropdown.open { display: block; }
.ef-category {
    font-size: 0.7em;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 12px 3px;
}
.ef-category:first-child {
    padding-top: 4px;
}
.ef-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 0.8em;
    color: #ccc;
    cursor: pointer;
    white-space: nowrap;
}
.icon-wrap { display: inline-flex; align-items: center; line-height: 1; }
.ef-item:hover { background: rgba(255,255,255,0.06); }
.ef-item input { width: 14px; height: 14px; cursor: pointer; flex-shrink: 0; }
.ef-only {
    margin-left: auto;
    font-size: 0.75em;
    padding: 1px 5px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    background: transparent;
    color: #999;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.ef-item:hover .ef-only { opacity: 1; }
.ef-only.ef-only-active { opacity: 1; color: #ccc; }
.ef-only:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ── Buttons ── */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.btn:hover { opacity: 0.85; }
.btn-sm { padding: 6px 12px; font-size: 0.8em; }
.btn-ghost {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); }
.btn-green { background: linear-gradient(135deg, #20bf55, #01baef); }
.btn-red { background: linear-gradient(135deg, #ff6b6b, #ee5a24); }
.btn-yellow { background: linear-gradient(135deg, #feca57, #ff9f43); color: #1a1a2e; }
.btn-cyan { background: linear-gradient(135deg, #48dbfb, #667eea); }
.btn-tiny {
    padding: 3px 8px;
    font-size: 0.7em;
    border-radius: 4px;
}

/* ── Undo Toast ── */
.undo-toast {
    position: fixed;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9000;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #1e1e2e;
    border: 1px solid rgba(72, 219, 251, 0.3);
    border-radius: 8px;
    padding: 8px 16px;
    color: #ddd;
    font-size: 0.9em;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    animation: slideDown 0.2s ease-out;
}
.undo-toast.hidden { display: none; }
.undo-btn {
    cursor: pointer;
    background: rgba(72, 219, 251, 0.15);
    border: 1px solid rgba(72, 219, 251, 0.3);
    color: #48dbfb;
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 0.85em;
    font-weight: 600;
    transition: background 0.15s;
}
.undo-btn:hover {
    background: rgba(72, 219, 251, 0.3);
}
@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Board ── */
.board {
    padding: 16px 0;
}

/* ── Player Row ── */
.player-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 2px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    min-height: 140px;
}
.player-row:nth-child(even) {
    background: rgba(255,255,255,0.02);
}
.player-events-section, .player-wq-section {
    display: flex;
    flex-direction: row;
    min-height: 60px;
    overflow-x: auto;
}

/* ── Sticky Player Info ── */
.player-info {
    position: sticky;
    left: 0;
    z-index: 10;
    width: 160px;
    min-width: 160px;
    padding: 8px 12px;
    background: inherit;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.player-info {
    position: relative;
}
/* ── Pinned-Only Toggle ── */
.pinned-only-btn { position: relative; }
.pinned-only-btn svg { vertical-align: middle; }
.pinned-only-btn.active {
    color: #feca57;
    border-color: rgba(254, 202, 87, 0.4);
    background: rgba(254, 202, 87, 0.1);
}
.pinned-only-btn.active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 20%;
    width: 60%;
    height: 2px;
    background: #ff6b6b;
    transform: rotate(-45deg);
    pointer-events: none;
}

.pin-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.player-row:hover .pin-btn,
.pin-btn.pinned {
    opacity: 1;
}
.pin-btn.pinned {
    color: #feca57;
}
.pin-btn:hover {
    color: #feca57;
    opacity: 1;
}
.player-avatar {
    font-size: 1.6em;
    margin-bottom: 2px;
}
.player-name {
    font-weight: 700;
    font-size: 0.9em;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.player-identity {
    font-size: 0.7em;
    color: #666;
}

/* ── Section Label ── */
.section-label {
    position: sticky;
    left: 0;
    z-index: 10;
    width: 160px;
    min-width: 160px;
    padding: 4px 12px;
    background: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7em;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.section-label .wq-add-btn {
    cursor: pointer;
    font-size: 1.2em;
    color: #48dbfb;
    background: rgba(72, 219, 251, 0.08);
    border: 1px solid rgba(72, 219, 251, 0.2);
    border-radius: 6px;
    padding: 4px 12px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.section-label .wq-add-btn:hover {
    color: #fff;
    background: rgba(72, 219, 251, 0.18);
}
.section-label .wq-sort-btn {
    cursor: pointer;
    font-size: 0.75em;
    color: #999;
    background: none;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 2px 6px;
    line-height: 1;
    transition: color 0.15s, border-color 0.15s;
}
.section-label .wq-sort-btn:hover {
    color: #48dbfb;
    border-color: rgba(72, 219, 251, 0.3);
}

/* ── Event/WQ Grid ── */
.items-grid {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    padding: 4px;
    gap: 3px;
    overflow-x: auto;
    min-width: 0;
    min-height: 40px;
}
/* Stack vertically in columns of ~5 */
.items-grid.stack-mode {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(5, 1fr);
    grid-auto-columns: max-content;
    justify-content: start;
    min-height: 130px;
}

/* ── Badge (Event & Work Queue Item) ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.72em;
    white-space: nowrap;
    max-width: 220px;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s, box-shadow 0.15s;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
}
.badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 5;
}
.badge.hidden-event {
    opacity: 0.35;
}
.badge-icon { font-size: 1em; flex-shrink: 0; display: inline-flex; align-items: center; line-height: 1; }
.badge-icon svg { display: block; }
.badge-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

/* Work queue badges */
.badge.wq-badge {
    border-left: 2px solid #feca57;
    background: rgba(254, 202, 87, 0.08);
}
.badge.wq-badge.highlighted {
    border-left: 2px solid #c084fc;
    background: rgba(168, 85, 247, 0.15);
    box-shadow: 0 0 6px 2px rgba(168, 85, 247, 0.5), 0 0 14px 4px rgba(168, 85, 247, 0.25), inset 0 0 4px rgba(168, 85, 247, 0.2);
}
.badge.wq-badge.completed {
    opacity: 0.4;
    text-decoration: line-through;
}
.badge-copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 0.8em;
    opacity: 0;
    padding: 0 1px;
    margin-left: auto;
    flex-shrink: 0;
    transition: opacity 0.15s;
    line-height: 1;
    min-width: 1.8em;
    text-align: center;
}
.badge:hover .badge-copy-btn { opacity: 0.5; }
.badge-copy-btn:hover { opacity: 1 !important; }
.badge-copy-btn.copied { opacity: 1 !important; color: #22c55e; }

/* ── Badge Detail Card (inline popup) ── */
.badge-detail {
    position: fixed;
    z-index: 999;
    width: 280px;
    background: #1a1740;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    font-size: 0.85rem;
    white-space: normal;
    cursor: default;
}
.badge-detail .detail-title {
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    color: #fff;
    word-break: break-word;
}
.badge-detail .detail-title svg {
    display: block;
    flex-shrink: 0;
}
.badge-detail .detail-meta {
    font-size: 0.8em;
    color: #999;
    margin-bottom: 6px;
}
.badge-detail .detail-desc {
    font-size: 0.85em;
    color: #aaa;
    margin-bottom: 8px;
    word-break: break-word;
}
.badge-detail .detail-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 0.7em;
    opacity: 0.4;
    padding: 0 2px;
    vertical-align: middle;
    transition: opacity 0.15s;
    display: inline-flex;
    align-items: center;
    min-width: 2em;
    justify-content: center;
}
.copy-btn:hover { opacity: 1; }
.copy-btn.copied { opacity: 1; color: #22c55e; }
.badge-detail a {
    color: #48dbfb;
    text-decoration: none;
    font-size: 0.85em;
}
.badge-detail a:hover { text-decoration: underline; }

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #1a1740;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.modal-header h3 { font-size: 1.1em; }
.btn-close {
    background: none;
    border: none;
    color: #999;
    font-size: 1.4em;
    cursor: pointer;
    line-height: 1;
}
.btn-close:hover { color: #fff; }
.modal-body label {
    display: block;
    font-size: 0.8em;
    color: #aaa;
    margin-bottom: 4px;
    margin-top: 10px;
}
.edit-url-link {
    color: #48dbfb;
    font-size: 0.9em;
    text-decoration: none;
    margin-left: 4px;
}
.edit-url-link:hover { text-decoration: underline; }
.modal-body input, .modal-body select, .modal-body textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: #1e1e2e;
    color: #fff;
    font-size: 0.9em;
    outline: none;
}
.modal-body select option {
    background: #1e1e2e;
    color: #fff;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
    border-color: #667eea;
}
.modal-body textarea { resize: vertical; min-height: 60px; }
.modal-body .form-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Group Name Combo ── */
.gn-combo {
    position: relative;
}
.gn-combo input {
    width: 100%;
}
.gn-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 300;
    margin-top: 2px;
    background: #1e1e2e;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    max-height: 160px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.gn-dropdown.open { display: block; }
.gn-option {
    padding: 8px 12px;
    font-size: 0.85em;
    color: #ccc;
    cursor: pointer;
    transition: background 0.1s;
}
.gn-option:hover { background: rgba(255,255,255,0.08); color: #fff; }
.gn-option.selected { color: #48dbfb; }

/* ── Empty State ── */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #555;
    font-size: 0.9em;
    width: 100%;
    text-align: center;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { height: 6px; width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Animations ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.badge-new {
    animation: greenGlow 2s ease-out forwards;
}

@keyframes greenGlow {
    0% {
        box-shadow: 0 0 8px 3px rgba(40, 167, 69, 0.7);
        border-color: rgba(40, 167, 69, 0.8);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
        border-color: transparent;
    }
}
