/* eWeLink Controller – Frontend Widget */
.ewl-widget {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 50px;
    padding: 10px 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    font-family: inherit;
    margin: 6px 0;
}

.ewl-label {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.ewl-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 500;
    transition: background .2s, color .2s;
    outline: none;
}

.ewl-toggle[data-state="on"] {
    background: #e8f5e9;
    color: #2e7d32;
}
.ewl-toggle[data-state="off"] {
    background: #f5f5f5;
    color: #757575;
}
.ewl-toggle[data-state="unknown"],
.ewl-toggle[data-state="loading"] {
    background: #f5f5f5;
    color: #aaa;
    cursor: default;
}
.ewl-toggle:hover[data-state="on"]  { background: #c8e6c9; }
.ewl-toggle:hover[data-state="off"] { background: #eeeeee; }

/* Status dot */
.ewl-status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    transition: background .3s;
}
.ewl-toggle[data-state="on"]  .ewl-status-dot { background: #4caf50; }
.ewl-toggle[data-state="off"] .ewl-status-dot { background: #bdbdbd; }

/* Loading spinner overlay */
.ewl-toggle.ewl-loading .ewl-status-dot {
    animation: ewl-pulse 1s infinite;
}
@keyframes ewl-pulse {
    0%, 100% { opacity:1; } 50% { opacity:.3; }
}

.ewl-error { color: #c0392b; font-size: 13px; }

/* Extra sensor data (temp, humidity, etc.) */
.ewl-extra-data {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

/* Inline error messages */
.ewl-error-msg {
    display: inline-block;
    margin-left: 10px;
    font-size: 12px;
    color: #c0392b;
    background: #fdecea;
    border-radius: 4px;
    padding: 2px 8px;
}

/* Sensor-only devices – hide pointer cursor */
.ewl-toggle.ewl-no-toggle {
    cursor: default;
    pointer-events: none;
}

/* Curtain device – use blue tones */
.ewl-widget[data-type="curtain"] .ewl-toggle[data-state="on"] {
    background: #e3f2fd;
    color: #1565c0;
}
.ewl-widget[data-type="curtain"] .ewl-toggle[data-state="on"] .ewl-status-dot {
    background: #1e88e5;
}


/* Power meter device (UIID 226 etc.) — amber accent */
.ewl-widget[data-device-type="power_meter"] .ewl-toggle[data-state="on"] {
    background: #fff3e0;
    color: #e65100;
}
.ewl-widget[data-device-type="power_meter"] .ewl-toggle[data-state="on"] .ewl-status-dot {
    background: #ff9800;
}
.ewl-extra-data .ewl-sensor-voltage { color: #1565c0; }
.ewl-extra-data .ewl-sensor-power   { color: #e65100; }
.ewl-extra-data .ewl-sensor-current { color: #2e7d32; }
.ewl-extra-data .ewl-sensor-energy  { color: #6a1b9a; }
