/**
 * ETAPA 4: WebSocket Connection Status UI
 * Status bar with connection indicator
 */

/* ============================================================
   Connection Status Bar - Main Container
   ============================================================ */

.cf-ws-status-bar {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    height: 40px;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border-top: 1px solid #444;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 12px;
    color: #ccc;
    z-index: 999;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

/* Adjust main content when status bar is visible */
.cf-discord-layout {
    margin-bottom: 40px;
    transition: margin-bottom 0.3s ease;
}

/* ============================================================
   Status Indicator - Icon and Text
   ============================================================ */

.cf-ws-status-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
}

.cf-ws-status-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    animation: cf-pulse-connected 2s ease-in-out infinite;
}

/* ============================================================
   Status States - Icon Colors
   ============================================================ */

/* Connected State */
.cf-ws-status-icon.connected {
    background-color: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
    animation: cf-pulse-connected 2s ease-in-out infinite;
}

/* Reconnecting State */
.cf-ws-status-icon.reconnecting {
    background-color: #facc15;
    box-shadow: 0 0 8px rgba(250, 204, 21, 0.6);
    animation: cf-pulse-warning 1s ease-in-out infinite;
}

/* Offline/Disconnected State */
.cf-ws-status-icon.offline {
    background-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    animation: cf-pulse-error 0.8s ease-in-out infinite;
}

/* Polling State */
.cf-ws-status-icon.polling {
    background-color: #3b82f6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
    animation: cf-pulse-polling 1.5s ease-in-out infinite;
}

/* ============================================================
   Animations
   ============================================================ */

@keyframes cf-pulse-connected {
    0% {
        opacity: 1;
        box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 12px rgba(74, 222, 128, 0.8);
    }
    100% {
        opacity: 1;
        box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
    }
}

@keyframes cf-pulse-warning {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes cf-pulse-error {
    0% {
        opacity: 1;
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    }
    50% {
        opacity: 0.5;
        box-shadow: 0 0 4px rgba(239, 68, 68, 0.3);
    }
    100% {
        opacity: 1;
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    }
}

@keyframes cf-pulse-polling {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        opacity: 1;
    }
}

/* ============================================================
   Status Text
   ============================================================ */

.cf-ws-status-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cf-ws-status-main {
    font-weight: 600;
    color: #fff;
    font-size: 12px;
}

.cf-ws-status-sub {
    font-size: 11px;
    color: #888;
    font-weight: 400;
}

/* State-specific text colors */
.cf-ws-status-bar.connected .cf-ws-status-main {
    color: #4ade80;
}

.cf-ws-status-bar.reconnecting .cf-ws-status-main {
    color: #facc15;
}

.cf-ws-status-bar.offline .cf-ws-status-main {
    color: #ef4444;
}

.cf-ws-status-bar.polling .cf-ws-status-main {
    color: #3b82f6;
}

/* ============================================================
   Status Details - Right Side
   ============================================================ */

.cf-ws-status-right {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 11px;
    color: #888;
}

.cf-ws-status-detail {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cf-ws-status-detail-label {
    font-weight: 500;
    color: #aaa;
}

.cf-ws-status-detail-value {
    color: #ccc;
    font-family: 'Courier New', monospace;
}

/* ============================================================
   Toggle Tooltip - Hover Details
   ============================================================ */

.cf-ws-status-bar:hover {
    background: linear-gradient(135deg, #232323 0%, #353535 100%);
    border-top-color: #555;
}

.cf-ws-tooltip {
    position: absolute;
    bottom: 45px;
    right: 20px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 11px;
    color: #ccc;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: -1;
}

.cf-ws-status-bar:hover .cf-ws-tooltip {
    opacity: 1;
    z-index: 1000;
    pointer-events: auto;
}

/* ============================================================
   Responsive Design
   ============================================================ */

/* Tablet */
@media (max-width: 768px) {
    .cf-ws-status-bar {
        height: 36px;
        padding: 0 12px;
        font-size: 11px;
    }

    .cf-discord-layout {
        margin-bottom: 36px;
    }

    .cf-ws-status-right {
        font-size: 10px;
        gap: 10px;
    }

    .cf-ws-status-detail {
        padding: 2px 6px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .cf-ws-status-bar {
        height: 32px;
        padding: 0 10px;
        font-size: 10px;
    }

    .cf-discord-layout {
        margin-bottom: 32px;
    }

    .cf-ws-status-left {
        min-width: auto;
        gap: 6px;
    }

    .cf-ws-status-right {
        display: none; /* Hide details on mobile */
    }

    .cf-ws-status-icon {
        width: 10px;
        height: 10px;
    }

    .cf-ws-status-text {
        gap: 0;
    }

    .cf-ws-status-main {
        font-size: 11px;
    }

    .cf-ws-status-sub {
        font-size: 9px;
        display: none; /* Hide subtitle on mobile */
    }
}

/* ============================================================
   Dark Mode (Already Dark by Default)
   ============================================================ */

@media (prefers-color-scheme: dark) {
    .cf-ws-status-bar {
        background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    }
}

/* ============================================================
   Light Mode Support
   ============================================================ */

@media (prefers-color-scheme: light) {
    .cf-ws-status-bar {
        background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
        border-top-color: #ddd;
        color: #333;
    }

    .cf-ws-status-text {
        color: #333;
    }

    .cf-ws-status-detail {
        background: rgba(0, 0, 0, 0.05);
        border-color: rgba(0, 0, 0, 0.1);
    }

    .cf-ws-status-detail-label {
        color: #555;
    }

    .cf-ws-status-detail-value {
        color: #333;
    }

    .cf-ws-tooltip {
        background: #f5f5f5;
        border-color: #ddd;
        color: #333;
    }

    .cf-ws-status-bar:hover {
        background: linear-gradient(135deg, #fafafa 0%, #f0f0f0 100%);
        border-top-color: #ccc;
    }
}

/* ============================================================
   Accessibility
   ============================================================ */

.cf-ws-status-bar {
    /* Ensure sufficient contrast */
    color: #ccc;
}

@media (prefers-contrast: more) {
    .cf-ws-status-bar {
        border-top-width: 2px;
    }

    .cf-ws-status-icon {
        width: 14px;
        height: 14px;
    }
}

/* ============================================================
   Print Styles
   ============================================================ */

@media print {
    .cf-ws-status-bar {
        display: none;
    }

    .cf-discord-layout {
        margin-bottom: 0;
    }
}
