@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
    --primary-bg: #0f1117;
    --container-bg: #181a20;
    --card-bg: #1e2128;
    --card-bg-hover: #252830;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --text: #e8ecf1;
    --text-muted: #8b95a5;
    --border: #2a2d35;
    --success: #22c55e;
    --gold: #fbbf24;
    --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    --transition: 0.2s ease;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: var(--primary-bg);
    margin: 0;
    padding: 0;
    color: var(--text);
    min-height: 100vh;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left i {
    font-size: 1.5em;
    color: var(--accent);
}

.header h1 {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.3px;
}

.room-count-badge {
    background: var(--accent-glow);
    color: var(--accent);
    font-size: 0.75em;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    transition: all var(--transition);
}

.refresh-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.refresh-btn.spinning i {
    animation: spin 0.6s ease;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Search */
.search-bar {
    position: relative;
    margin-bottom: 28px;
}

.search-bar i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9em;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.95em;
    font-family: 'Montserrat', sans-serif;
    background: var(--card-bg);
    color: var(--text);
    outline: none;
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Stats summary */
.stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
}

.stat-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 24px;
    flex: 1;
    text-align: center;
}

.stat-value {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-value.accent {
    color: var(--accent);
}

.stat-value.gold {
    color: var(--gold);
}

.stat-label {
    font-size: 0.75em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* Room grid */
.rooms {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.room-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.room-card:hover {
    background: var(--card-bg-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.room-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.room-title {
    font-size: 0.85em;
    color: var(--text);
    font-weight: 600;
    word-break: break-all;
    overflow-wrap: anywhere;
    line-height: 1.4;
    flex: 1;
}

.room-title i {
    color: var(--accent);
    margin-right: 6px;
}

.peer-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-glow);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.peer-badge i {
    font-size: 0.85em;
}

.room-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.peer-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
    color: var(--text-muted);
}

.peer-status .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
    transition: box-shadow 0.3s ease;
}

.join-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
    font-family: 'Montserrat', sans-serif;
}

.join-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

/* Empty state */
.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
    font-size: 1em;
    grid-column: 1 / -1;
}

.empty i {
    display: block;
    font-size: 2.5em;
    margin-bottom: 16px;
    opacity: 0.4;
}

/* Responsive */
@media (max-width: 900px) {
    .container {
        padding: 20px 16px;
    }
    .stats-bar {
        gap: 10px;
    }
    .stat-item {
        padding: 12px 16px;
    }
    .stat-value {
        font-size: 1.4em;
    }
}

@media (max-width: 600px) {
    .header {
        flex-wrap: wrap;
        gap: 12px;
    }
    .stats-bar {
        flex-direction: column;
    }
    .rooms {
        grid-template-columns: 1fr;
    }
    .header h1 {
        font-size: 1.2em;
    }
}
