/* Connection Status Indicators - Mobile Optimized Styles */

.connection-status-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: #6b7280;
    transition: all 0.2s ease;
    cursor: help;
}

.connection-status-indicator:hover {
    color: #374151;
}

.dark .connection-status-indicator {
    color: #9ca3af;
}

.dark .connection-status-indicator:hover {
    color: #d1d5db;
}

/* Topbar layout improvements */
.detached-topbar {
    min-height: 60px;
}

/* Better spacing for topbar elements */
.detached-topbar > div:first-child {
    min-width: 0; /* Allow flex shrinking */
}

.detached-topbar > div:last-child {
    flex-shrink: 0; /* Prevent right section from shrinking */
}

/* Mobile-specific container adjustments */
.connection-indicators-container {
    flex-shrink: 0;
    min-width: fit-content;
    margin-left: 0.5rem; /* Add some space after menu button */
}

@media (max-width: 640px) {
    .connection-indicators-container {
        margin-left: 0.75rem; /* More space on mobile */
    }
}

/* Better visual hierarchy - but exclude buttons */
.detached-topbar .flex.items-center:first-child {
    color: #374151;
}

/* Override for buttons inside first container to maintain their own colors */
.detached-topbar .flex.items-center:first-child button {
    color: inherit; /* Let button maintain its own text-black/dark:text-white classes */
}

.dark .detached-topbar .flex.items-center:first-child {
    color: #d1d5db;
}

/* Override for buttons in dark mode */
.dark .detached-topbar .flex.items-center:first-child button {
    color: inherit; /* Let button maintain its own dark mode classes */
}

/* Specific overrides for topbar buttons to maintain proper colors */
.detached-topbar button.text-black {
    color: #000 !important;
}

.detached-topbar button.text-black.dark\:text-white\/80 {
    color: #000 !important;
}

[data-mode=dark] .detached-topbar button.text-black.dark\:text-white\/80 {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Ensure buttons in last container (settings, profile) also maintain colors */
.detached-topbar .flex.items-center:last-child button.text-black {
    color: #000 !important;
}

[data-mode=dark] .detached-topbar .flex.items-center:last-child button.text-black {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Connection dots */
.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.connection-dot.connected {
    background-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: pulse-green 2s infinite;
}

.connection-dot.connecting {
    background-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
    animation: pulse-yellow 1s infinite;
}

.connection-dot.disconnected {
    background-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    animation: pulse-red 1s infinite;
}

.connection-dot.unknown {
    background-color: #6b7280;
    box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.2);
    animation: pulse-gray 1.5s infinite;
}

/* Connection status text */
.connection-status-text {
    font-weight: 500;
    white-space: nowrap;
    font-size: 0.75rem;
    user-select: none;
}

/* Topbar mobile optimizations */
@media (max-width: 640px) {
    /* Topbar gap adjustments for mobile */
    .detached-topbar .flex.items-center:last-child {
        gap: 0.7rem !important; /* Reduce gap between topbar items on mobile */
    }
    
    /* Hide text on mobile, keep only dots */
    .connection-status-indicator .connection-status-text {
        display: none;
    }
    
    /* Make dots slightly larger on mobile for better visibility and touch targets */
    .connection-dot {
        width: 12px;
        height: 12px;
    }
    
    /* Reduce gap between indicators on mobile */
    .connection-status-indicator {
        gap: 0.8rem;
    }
    
    /* Add touch-friendly padding */
    .connection-status-indicator {
        padding: 0.375rem 0.25rem;
        margin: -0.375rem -0.25rem;
        border-radius: 0.375rem;
        min-width: 20px;
        justify-content: center;
    }
    
    /* Enhanced touch states on mobile */
    .connection-status-indicator:active {
        background-color: rgba(0, 0, 0, 0.08);
        transform: scale(1.1);
    }
    
    .dark .connection-status-indicator:active {
        background-color: rgba(255, 255, 255, 0.08);
    }
    
    /* Mobile-specific container spacing */
    .connection-indicators-container {
        gap: 0.25rem !important;
        margin-right: 0.25rem;
    }
    
    /* Ensure topbar icons don't get too cramped */
    .detached-topbar .w-5.h-5 {
        flex-shrink: 0;
    }
}

/* Small mobile screens (phones in portrait) */
@media (max-width: 480px) {
    .connection-status-indicator {
        padding: 0.25rem;
        margin: -0.25rem;
        min-width: 16px;
    }
    
    .connection-dot {
        width: 10px;
        height: 10px;
    }
    
    /* Further reduce topbar spacing on very small screens */
    .detached-topbar .flex.items-center:last-child {
        gap: 0.7rem !important;
    }
    
    .connection-indicators-container {
        gap: 0.7rem !important;
    }
}

/* Tablet optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
    .connection-status-text {
        font-size: 0.7rem;
    }
    
    .connection-dot {
        width: 9px;
        height: 9px;
    }
    
    /* Slightly reduce text on tablets to save space */
    .connection-status-text {
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Desktop optimizations */
@media (min-width: 1025px) {
    .connection-status-text {
        font-size: 0.75rem;
    }
    
    .connection-dot {
        width: 8px;
        height: 8px;
    }
    
    /* Full text on desktop */
    .connection-status-text {
        max-width: none;
    }
}

/* Landscape phone optimization */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .connection-status-indicator {
        padding: 0.25rem 0.125rem;
    }
    
    .connection-dot {
        width: 8px;
        height: 8px;
    }
}

/* Pulse animations */
@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.4);
    }
}

@keyframes pulse-yellow {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.4);
    }
}

@keyframes pulse-red {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.4);
    }
}

@keyframes pulse-gray {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.2);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.3);
    }
}

/* Tooltip enhancements for mobile */
@media (max-width: 640px) {
    .connection-status-indicator[title]:hover::after,
    .connection-status-indicator[title]:focus::after {
        content: attr(title);
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background-color: rgba(0, 0, 0, 0.9);
        color: white;
        padding: 0.5rem 0.75rem;
        border-radius: 0.375rem;
        font-size: 0.75rem;
        white-space: nowrap;
        z-index: 50;
        pointer-events: none;
        max-width: 90vw;
        text-align: center;
        line-height: 1.2;
    }
    
    .dark .connection-status-indicator[title]:hover::after,
    .dark .connection-status-indicator[title]:focus::after {
        background-color: rgba(255, 255, 255, 0.9);
        color: black;
    }
}

/* Accessibility improvements */
.connection-status-indicator:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.connection-status-indicator:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .connection-dot.connected {
        background-color: #059669;
        border: 1px solid #000;
    }
    
    .connection-dot.connecting {
        background-color: #d97706;
        border: 1px solid #000;
    }
    
    .connection-dot.disconnected {
        background-color: #dc2626;
        border: 1px solid #000;
    }
    
    .connection-dot.unknown {
        background-color: #4b5563;
        border: 1px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .connection-dot {
        animation: none;
    }
    
    .connection-status-indicator {
        transition: none;
    }
}