/* ===========================================================
   Telldus Live Extended – Frontend styles v2.5.3
   =========================================================== */

/* === Dashboard === */
.tlive-ex {
  margin: 1.25rem 0;
}

.tlive-dashboard-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 1.1rem;
  color: var(--tlive-text, #111827);
}

/* === Grid === */
.tlive-ex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  width: 100%;
}

/* ===========================================================
   KORT – Grund
   =========================================================== */
.tlive-card {
  position: relative;
  background: var(--tlive-card, #ffffff);
  color: var(--tlive-text, #111827);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  text-align: center;

  transition:
    transform .18s ease,
    box-shadow .18s ease,
    background .25s ease,
    opacity .25s ease;
}

.tlive-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,.14);
}

/* ===========================================================
   Kort – Ikon & text
   =========================================================== */
.tlive-card-icon {
  font-size: 2.0rem;
  margin-bottom: .25rem;
  transition: filter .25s ease, text-shadow .25s ease;
}

.tlive-card-title {
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.tlive-card-state {
  font-weight: 600;
  margin-bottom: .5rem;
  opacity: .9;
  min-height: 1.4em;
}

/* ===========================================================
   DEVICE CARD (Lampor)
   =========================================================== */
.tlive-card-device {
  --glow: 0;
  border-left: 5px solid #b5b7ba;
  background: #f7f7f7; /* fallback */
  background: color-mix(in srgb, var(--tlive-card, #fff) 85%, #9ca3af 15%);
}

/* När tänd */
.tlive-card-device.is-on {
  border-left-color: #f59e0b;
  background: #fff9e6; /* fallback */
  background: color-mix(in srgb, #ffffff 75%, #fde68a 25%);
  box-shadow:
    0 2px 10px rgba(0,0,0,.07),
    0 0 calc(var(--glow)*1px) rgba(245,158,11,.45) inset;
}

.tlive-card-device.is-on .tlive-card-icon {
  filter: drop-shadow(0 0 calc(var(--glow)*1px) rgba(245,158,11,.75));
  text-shadow: 0 0 calc(var(--glow)*1px) rgba(245,158,11,.95);
}

/* När släckt */
.tlive-card-device.is-off {
  border-left-color: #d1d5db;
  background: #f3f4f6;
  opacity: 0.92;
}

/* ===========================================================
   ACTION KNAPPAR
   =========================================================== */
.tlive-actions {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin-top: .1rem;
}

.tlive-btn {
  border: 0;
  padding: .45rem .75rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: .9rem;
  transition: background .25s ease, filter .25s ease;
}

.tlive-btn.tlive-on {
  background: #fde68a;
}
.tlive-btn.tlive-off {
  background: #e5e7eb;
}

.tlive-card-device.is-on .tlive-btn.tlive-on {
  filter: brightness(1.08);
}
.tlive-card-device.is-off .tlive-btn.tlive-off {
  filter: brightness(.90);
}

/* ===========================================================
   DIMMER
   =========================================================== */
.tlive-dimmer {
  margin-top: .4rem;
  width: 100%;
  height: 6px;

  appearance: none;
  background: #dadce1;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: background .25s ease;
}

.tlive-dimmer::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #facc15;
  border: 2px solid #f59e0b;
  cursor: pointer;
}

.tlive-dimmer::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #facc15;
  border: 2px solid #f59e0b;
  cursor: pointer;
}

/* ===========================================================
   SENSORER
   =========================================================== */
.tlive-card-sensor {
  border-left: 5px solid #60a5fa;
  background: #f1f7ff; /* fallback */
  background: color-mix(in srgb, #eff6ff 80%, var(--tlive-card, #fff) 20%);
}

.tlive-card-value {
  font-size: 1.8rem;
  font-weight: 800;
}

.tlive-card-unit {
  opacity: .65;
  font-size: 1rem;
  font-weight: 600;
}

/* ===========================================================
   MEDDELANDEN
   =========================================================== */
.tlive-ex-msg {
  padding: .6rem .9rem;
  border-radius: 8px;
  margin: .5rem 0;
  background: #f2f2f2;
  background: color-mix(in srgb, var(--tlive-card, #fff) 70%, #e5e7eb 30%);
}

.tlive-ex-error {
  background: #f8d4d1;
  background: color-mix(in srgb, #fde2e1 80%, var(--tlive-card, #fff) 20%);
  color: #6b0f0f;
}

/* ===========================================================
   GLOW DOT (hörnindikator)
   =========================================================== */
.tlive-glow-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  opacity: .15;
  box-shadow: 0 0 calc(var(--glow)*1px) rgba(245,158,11,.9);
  transition: opacity .3s ease, transform .3s ease;
}

.tlive-card-device.is-on .tlive-glow-dot {
  opacity: .85;
  animation: tlive-pulse 2.1s ease-in-out infinite;
}

@keyframes tlive-pulse {
  0% { transform: scale(.90); }
  50% { transform: scale(1.17); }
  100% { transform: scale(.90); }
}

/* ===========================================================
   DARK MODE
   =========================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --tlive-card: #0b1220;
    --tlive-text: #e5e7eb;
  }

  .tlive-card {
    box-shadow: 0 2px 14px rgba(0,0,0,.55);
  }

  .tlive-card-device {
    background: #1a2333;
    background: color-mix(in srgb, #0b1220 85%, #9ca3af 15%);
  }

  .tlive-card-device.is-on {
    background: #2b2a1d;
    background: color-mix(in srgb, #0b1220 60%, #fde68a 40%);
  }
}
