/* ============================================
   房間介面樣式 - 現代化設計
   ============================================ */

/* 動畫定義 */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@keyframes slideUp {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 房間列表區域 */
.rooms-section {
    margin-top: 28px;
    border-top: 1px solid rgba(99, 102, 241, 0.2);
    padding-top: 28px;
    animation: slideUp 0.5s ease-out;
}

.room-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 房間卡片 */
.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.room-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    transition: left 0.5s ease;
}

.room-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px -5px rgba(99, 102, 241, 0.3);
}

.room-item:hover::before {
    left: 100%;
}

.room-info {
    flex: 1;
    min-width: 0;
}

.room-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.room-details {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* 房間狀態標籤 */
.room-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.room-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.room-status.waiting {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(251, 191, 36, 0.1));
    color: #fbbf24;
}

.room-status.waiting::before {
    background: #fbbf24;
    animation: pulse 1.5s infinite;
}

.room-status.playing {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(52, 211, 153, 0.1));
    color: #34d399;
}

.room-status.playing::before {
    background: #34d399;
}

.room-status.finished {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(248, 113, 113, 0.1));
    color: #f87171;
}

.room-status.finished::before {
    background: #f87171;
}

/* 加入按鈕 */
.join-room-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.join-room-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.4s ease;
}

.join-room-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -5px rgba(99, 102, 241, 0.5);
}

.join-room-btn:hover::before {
    left: 100%;
}

.join-room-btn:disabled {
    background: linear-gradient(135deg, #475569, #334155);
    cursor: not-allowed;
    opacity: 0.7;
}

.join-room-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* 創建房間區域 */
.create-room-section {
    margin-top: 28px;
    padding: 24px;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    border-radius: 16px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
}

.create-room-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), #a855f7, var(--primary-color));
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

.create-room-section h3 {
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.create-room-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: nowrap;
}

.create-room-form input {
    flex: 1;
    min-width: 0;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.3s ease;
}

.create-room-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.create-room-form input::placeholder {
    color: var(--text-secondary);
}

.create-room-form .btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 14px 24px;
}

/* 刷新按鈕 */
.refresh-btn {
    background: transparent;
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.refresh-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.refresh-btn.loading {
    pointer-events: none;
}

.refresh-btn.loading::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 4px;
}

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

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

.section-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* 無房間提示 */
.no-rooms {
    text-align: center;
    padding: 40px 24px;
    color: var(--text-secondary);
    font-size: 14px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.5), rgba(15, 23, 42, 0.6));
    border-radius: 12px;
    border: 1px dashed rgba(99, 102, 241, 0.2);
}

/* 連接狀態指示器 */
.connection-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.connection-indicator.connecting {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.connection-indicator.connected {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.connection-indicator.disconnected {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.connection-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.connection-indicator.connecting::before {
    background: #f59e0b;
    animation: pulse 1s infinite;
}

.connection-indicator.connected::before {
    background: #10b981;
}

.connection-indicator.disconnected::before {
    background: #ef4444;
}

/* 錯誤訊息 Toast */
.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(220, 38, 38, 0.95));
    border-radius: 12px;
    color: white;
    font-weight: 500;
    box-shadow: 0 10px 40px -5px rgba(239, 68, 68, 0.5);
    transform: translateX(calc(100% + 40px));
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    max-width: 300px;
}

.error-toast.show {
    transform: translateX(0);
}

/* 按鈕載入狀態 */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

/* ============================================
   排行榜樣式
   ============================================ */

/* 功能連結區域 */
.function-links-section {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-top: 24px;
}

/* 排行榜容器 */
.leaderboard-container {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 16px;
    min-width: 200px;
    max-width: 280px;
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
}

.leaderboard-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #fbbf24, #f59e0b, #fbbf24);
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

.leaderboard-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.15);
}

.leaderboard-icon {
    font-size: 18px;
}

.leaderboard-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.leaderboard-list::-webkit-scrollbar {
    width: 4px;
}

.leaderboard-list::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 2px;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 2px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.leaderboard-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.leaderboard-item.top-1 {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.1));
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.leaderboard-item.top-2 {
    background: linear-gradient(135deg, rgba(156, 163, 175, 0.15), rgba(107, 114, 128, 0.1));
    border: 1px solid rgba(156, 163, 175, 0.2);
}

.leaderboard-item.top-3 {
    background: linear-gradient(135deg, rgba(180, 83, 9, 0.15), rgba(146, 64, 14, 0.1));
    border: 1px solid rgba(180, 83, 9, 0.2);
}

.leaderboard-rank {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 20px;
}

.leaderboard-item.top-1 .leaderboard-rank {
    color: #fbbf24;
}

.leaderboard-item.top-2 .leaderboard-rank {
    color: #9ca3af;
}

.leaderboard-item.top-3 .leaderboard-rank {
    color: #b45309;
}

.leaderboard-username {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-left: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-glvc {
    font-size: 12px;
    font-weight: 700;
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

.leaderboard-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 16px 0;
}

.leaderboard-loading {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 16px 0;
}

/* 分页控件 */
.leaderboard-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(99, 102, 241, 0.15);
}

.pagination-btn {
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.25);
    border-color: var(--primary-color);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: center;
}