*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #1a1a2e;
  --surface: #2d2d44;
  --border:  #3a3a58;
  --muted:   #5a5a88;
  --text:    #c0c0e0;
  --on:      #00e676;
  --off:     #ff1744;
  --accent:  #6060aa;
}

html { height: 100%; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
}

/* ── Login ─────────────────────────────────────── */

.login-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 320px;
}

/* ── Remote ─────────────────────────────────────── */

.remote-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 24px;
}

.app-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px 0 20px;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
}

.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 0 36px;
}

/* ── Shared ─────────────────────────────────────── */

.brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
}

.divider {
  width: 60%;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
}

.text-input {
  width: 100%;
  background: #13131f;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
}
.text-input:focus { border-color: var(--accent); }

/* ── LED + Status ───────────────────────────────── */

.indicator-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2a2a40;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
  transition: background 0.3s, box-shadow 0.3s;
}
.led.on  { background: var(--on);  box-shadow: 0 0 8px var(--on),  0 0 20px rgba(0,230,118,0.33); }
.led.off { background: var(--off); box-shadow: 0 0 8px var(--off), 0 0 20px rgba(255,23,68,0.33); }

.status-text {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
.status-text.on  { color: var(--on);  }
.status-text.off { color: var(--off); }

/* ── Timer ──────────────────────────────────────── */

.timer {
  font-size: clamp(28px, 9vw, 42px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 3px;
  color: var(--border);
  min-height: 1.2em;
  text-align: center;
  transition: color 0.3s;
}
.timer.active { color: var(--on); }

/* ── Spinner ────────────────────────────────────── */

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinner {
  width: clamp(60px, 15vw, 80px);
  height: clamp(60px, 15vw, 80px);
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.spinner.hidden {
  display: none;
}

/* ── Toggle Button ──────────────────────────────── */

.btn-toggle {
  width: clamp(150px, 48vw, 210px);
  height: clamp(150px, 48vw, 210px);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: clamp(20px, 6vw, 26px);
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
  user-select: none;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.5s, scale 0.5s;
  /* default / off state: shows "ON" action */
  background: linear-gradient(145deg, #00e676, #00b248);
  color: #003d1a;
  box-shadow: 0 8px 40px rgba(0,230,118,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
  opacity: 0;
  scale: 0.3;
  pointer-events: none;
}
.btn-toggle.visible {
  opacity: 1;
  scale: 1;
  pointer-events: auto;
}
.btn-toggle:active:not(:disabled) { transform: scale(0.93); }
.btn-toggle:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* state-on: relay is on, button action is "OFF" */
.btn-toggle.state-on {
  background: linear-gradient(145deg, #ff5252, #c62828);
  color: #3d0000;
  box-shadow: 0 8px 40px rgba(255,82,82,0.45), inset 0 1px 0 rgba(255,255,255,0.2);
}

/* ── Duration row ───────────────────────────────── */

.duration-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.duration-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Message ────────────────────────────────────── */

.message {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
  letter-spacing: 0.5px;
  transition: color 0.3s;
}
.message.error   { color: #ff5252; }
.message.success { color: var(--on); }

/* ── Buttons ────────────────────────────────────── */

.btn-primary {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(145deg, #6060aa, #4040aa);
  color: #c0c0ff;
  box-shadow: 0 6px 20px rgba(96,96,170,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn-primary:active   { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 6px 20px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.btn-logout:hover { color: #ff5252; border-color: #ff5252; }

/* ── Login error ────────────────────────────────── */

.login-error {
  font-size: 11px;
  color: #ff5252;
  min-height: 16px;
  letter-spacing: 0.5px;
  text-align: center;
}
