/**
 * Connection Status and Spectator Panel Styles
 * AI Arena Frontend - Dark Mode Theme
 */

/* ============================================
   CONNECTION STATUS INDICATOR
   ============================================ */

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid #334155;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    font-size: 14px;
    transition: all 0.3s ease;
}

.connection-status:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Status Dot */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    transition: all 0.3s ease;
}

/* Connected - Green with pulse */
.status-connected {
    background-color: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Connecting - Yellow with faster pulse */
.status-connecting {
    background-color: #f59e0b;
    animation: pulse-yellow 1s infinite;
}

@keyframes pulse-yellow {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* Reconnecting - Orange with blink */
.status-reconnecting {
    background-color: #f97316;
    animation: blink-orange 0.8s infinite;
}

@keyframes blink-orange {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Disconnected - Red */
.status-disconnected {
    background-color: #ef4444;
}

/* Error - Red with rapid blink */
.status-error {
    background-color: #ef4444;
    animation: blink-red 0.4s infinite;
}

@keyframes blink-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Status Text */
.status-text {
    font-weight: 600;
    font-size: 13px;
    transition: color 0.3s ease;
}

.status-text.status-connected { color: #10b981; }
.status-text.status-connecting { color: #f59e0b; }
.status-text.status-reconnecting { color: #f97316; }
.status-text.status-disconnected { color: #ef4444; }
.status-text.status-error { color: #ef4444; }

/* Connection Details (tooltip-like) */
.connection-details {
    font-size: 11px;
    color: #64748b;
    margin-left: 4px;
}

/* ============================================
   SPECTATOR PANEL
   ============================================ */

.spectator-panel {
    background: #1e293b;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid #334155;
}

.spectator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #334155;
}

.spectator-header h3 {
    margin: 0;
    font-size: 16px;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.spectator-count {
    font-size: 12px;
    color: #64748b;
    background: #0f172a;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

/* Spectator List */
.spectator-list-container {
    max-height: 200px;
    overflow-y: auto;
}

.spectator-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.spectator-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #0f172a;
    border-radius: 8px;
    margin-bottom: 6px;
    border-left: 3px solid #6366f1;
    transition: all 0.2s ease;
}

.spectator-item:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.spectator-item.spectator-current {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.spectator-number {
    width: 24px;
    height: 24px;
    background: #334155;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
}

.spectator-current .spectator-number {
    background: #10b981;
    color: white;
}

.spectator-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #f1f5f9;
}

.spectator-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.spectator-status-indicator.online {
    background: #10b981;
}

.spectator-status-indicator.offline {
    background: #64748b;
}

.spectator-empty {
    text-align: center;
    color: #64748b;
    font-style: italic;
    padding: 20px;
    font-size: 13px;
}

/* Spectator Controls */
.spectator-controls {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #334155;
    text-align: center;
}

.btn-spectator {
    background: #334155;
    color: #f1f5f9;
    border: none;
    transition: all 0.2s ease;
}

.btn-spectator:hover {
    background: #475569;
}

.btn-spectator.active {
    background: #10b981;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.btn-spectator.active:hover {
    background: #059669;
}

/* ============================================
   GAME MODE TOGGLE (Play vs Spectate)
   ============================================ */

.game-mode-selector {
    display: flex;
    gap: 8px;
    background: #0f172a;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #334155;
}

.mode-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: #64748b;
}

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

.mode-btn.active {
    background: #334155;
    color: #f1f5f9;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.mode-btn.play-mode.active {
    color: #6366f1;
}

.mode-btn.spectate-mode.active {
    color: #10b981;
}

/* ============================================
   REAL-TIME INDICATORS
   ============================================ */

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #ef4444;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    animation: live-pulse 1.5s infinite;
}

@keyframes live-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .connection-status {
        top: 5px;
        right: 5px;
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .status-text {
        font-size: 12px;
    }
    
    .connection-details {
        display: none;
    }
    
    .spectator-panel {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .spectator-header h3 {
        font-size: 14px;
    }
    
    .spectator-list-container {
        max-height: 150px;
    }
    
    .spectator-item {
        padding: 8px 10px;
    }
    
    .spectator-name {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .connection-status {
        position: fixed;
        top: auto;
        bottom: 10px;
        right: 10px;
        left: 10px;
        justify-content: center;
    }
    
    .game-mode-selector {
        flex-direction: column;
    }
    
    .mode-btn {
        padding: 12px;
    }
}

/* ============================================
   ANIMATIONS & UTILITIES
   ============================================ */

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none !important;
}

/* Connection state transitions */
.connection-status {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   RECONNECTION UI OVERLAY
   ============================================ */

.reconnection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.reconnection-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.reconnection-content {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: reconnection-slide-in 0.4s ease;
}

@keyframes reconnection-slide-in {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.reconnection-icon {
    margin-bottom: 16px;
}

.spinner {
    display: inline-block;
    width: 48px;
    height: 48px;
    border: 4px solid #334155;
    border-top: 4px solid #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.reconnection-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #f1f5f9;
}

.reconnection-status {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 24px 0;
}

.reconnection-progress {
    margin-bottom: 20px;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #0f172a;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #818cf8);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.countdown {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.reconnection-actions {
    animation: fadeIn 0.3s ease;
}

.reconnection-actions .btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reconnection-actions .btn-primary:hover {
    background: linear-gradient(135deg, #818cf8, #6366f1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.reconnection-actions .btn-primary:active {
    transform: translateY(0);
}

.reconnection-help {
    font-size: 13px;
    color: #64748b;
    margin-top: 12px;
}

/* Reconnection success state */
.reconnection-overlay.success .spinner {
    border-color: #10b981;
    border-top-color: transparent;
    animation: none;
    position: relative;
}

.reconnection-overlay.success .spinner::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #10b981;
    font-weight: bold;
}

.reconnection-overlay.success .reconnection-title {
    color: #10b981;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .reconnection-content {
        padding: 24px;
        margin: 20px;
    }
    
    .reconnection-title {
        font-size: 18px;
    }
    
    .reconnection-status {
        font-size: 13px;
    }
}

/* Scrollbar styling for dark mode */
.spectator-list-container::-webkit-scrollbar,
.connection-status::-webkit-scrollbar {
    width: 6px;
}

.spectator-list-container::-webkit-scrollbar-track,
.connection-status::-webkit-scrollbar-track {
    background: #0f172a;
}

.spectator-list-container::-webkit-scrollbar-thumb,
.connection-status::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

.spectator-list-container::-webkit-scrollbar-thumb:hover,
.connection-status::-webkit-scrollbar-thumb:hover {
    background: #475569;
}
