/**
 * latency.css
 * Adds latency badges, server realm badge, ping notes, room option
 * toggles, and the ElectroGun duel pulse animation.
 * Loaded after style.css so it only augments the existing theme.
 */

/* ---------- Server Realm Badge (lobby header) ---------- */
.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.server-realm-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(26, 71, 42, 0.95), rgba(13, 40, 24, 0.95));
    border: 2px solid var(--gold);
    color: var(--gold);
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35), 0 0 12px rgba(255, 215, 0, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
}

.server-realm-badge strong {
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.8px;
}

@media (max-width: 768px) {
    .header-center { display: none; }
}

/* ---------- Online Players list header ---------- */
.users-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px 6px 10px;
    margin-bottom: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px dashed rgba(0, 0, 0, 0.15);
}

.users-list-header span:last-child {
    text-align: right;
    min-width: 58px;
}

/* ---------- Player row: name + latency badge ---------- */
.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-item .user-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Latency Badge ---------- */
.user-latency {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    padding: 3px 10px;
    border-radius: 999px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    line-height: 1;
    border: 1.5px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}

.user-latency:hover {
    transform: translateY(-1px);
}

.user-latency.lat-good {
    background: linear-gradient(180deg, #d4f7d8, #9ee3a6);
    color: #145a1f;
    border-color: #4caf50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.user-latency.lat-ok {
    background: linear-gradient(180deg, #fff0bf, #ffd968);
    color: #7a5200;
    border-color: #e6a700;
    box-shadow: 0 0 8px rgba(230, 167, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.user-latency.lat-bad {
    background: linear-gradient(180deg, #ffd2d2, #ff9d9d);
    color: #7a0000;
    border-color: #e53935;
    box-shadow: 0 0 8px rgba(229, 57, 53, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.user-latency.lat-unknown {
    background: linear-gradient(180deg, #f0f0f0, #dfdfdf);
    color: #888;
    border-color: #bbb;
    font-style: italic;
    opacity: 0.85;
}

/* ---------- Room modal player list ---------- */
.room-players li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.room-players li .user-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-players li .user-latency {
    min-width: 54px;
    padding: 2px 9px;
    font-size: 0.72rem;
}

/* ---------- Recommended ping notes ---------- */
.game-option-ping {
    margin-top: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.game-option-ping.ping-any {
    color: #1e7a32;
}

.game-option-ping.ping-strict {
    color: #a05a00;
}

.room-ping-note {
    display: block;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed rgba(0, 0, 0, 0.15);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.3;
}

.room-ping-note.ping-any {
    color: #1e7a32;
}

.room-ping-note.ping-strict {
    color: #a05a00;
}

/* ---------- Room options panel (Arrows toggle etc.) ---------- */
.room-options {
    margin: 14px 0 4px 0;
    padding: 12px 14px;
    background: linear-gradient(180deg, #fbfaf2 0%, #f2efdd 100%);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
}

.room-options h4 {
    margin: 0 0 10px 0;
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.room-options .host-only-note {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    color: #a05a00;
    background: rgba(255, 215, 0, 0.18);
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.option-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.option-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.option-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-switch {
    position: relative;
    width: 46px;
    height: 24px;
    background: #c3c3c3;
    border-radius: 12px;
    transition: background 0.2s ease;
    flex-shrink: 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease;
}

.option-toggle input[type="checkbox"]:checked + .toggle-switch {
    background: linear-gradient(180deg, #34d058, #1f9d3d);
}

.option-toggle input[type="checkbox"]:checked + .toggle-switch::after {
    transform: translateX(22px);
}

.option-toggle input[type="checkbox"]:disabled + .toggle-switch {
    opacity: 0.55;
    cursor: not-allowed;
}

.option-toggle input[type="checkbox"]:disabled ~ .option-label {
    opacity: 0.75;
}

.option-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.25;
}

.option-label strong {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--primary-color);
    letter-spacing: 0.3px;
}

.option-label small {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* ---------- ElectroGun duel pulse ---------- */
@keyframes pulse {
    from { opacity: 0.7; transform: scale(1); }
    to   { opacity: 1;   transform: scale(1.03); }
}