/**
 * Device Connection Indicator CSS
 * Visual indicators for device connection status in widgets
 * Version: 1.0.0
 */

/* Connection LED Indicator */
.widget-connection-led {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
    pointer-events: none;
}

/* Pulse animation for disconnected state */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* Widget visual state when device is disconnected */
.grid-stack-item-content.device-disconnected {
    border: 2px solid #ef4444 !important;
    opacity: 0.85;
    position: relative;
}

/* Add a subtle overlay to disconnected widgets */
.grid-stack-item-content.device-disconnected::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
    border-radius: inherit;
}

/* Disconnected badge (optional - shown on hover) */
.grid-stack-item-content.device-disconnected::after {
    content: 'Mất kết nối thiết bị';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1001;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.grid-stack-item-content.device-disconnected:hover::after {
    opacity: 1;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .grid-stack-item-content.device-disconnected {
        border-color: #f87171 !important;
    }

    .grid-stack-item-content.device-disconnected::before {
        background: linear-gradient(135deg, rgba(248, 113, 113, 0.08) 0%, transparent 50%);
    }

    .grid-stack-item-content.device-disconnected::after {
        background: rgba(248, 113, 113, 0.95);
    }
}

/* Connection status tooltip enhancement */
.widget-connection-led[title]:hover {
    transform: scale(1.2);
    cursor: help;
}

/* Different LED sizes for different widget sizes */
.grid-stack-item[gs-w="1"] .widget-connection-led,
.grid-stack-item[gs-w="2"] .widget-connection-led {
    width: 10px;
    height: 10px;
    top: 6px;
    right: 6px;
}

.grid-stack-item[gs-w="5"] .widget-connection-led,
.grid-stack-item[gs-w="6"] .widget-connection-led,
.grid-stack-item[gs-w="7"] .widget-connection-led,
.grid-stack-item[gs-w="8"] .widget-connection-led {
    width: 14px;
    height: 14px;
    top: 10px;
    right: 10px;
}
