/* RubyControle — Glassmorphism premium */
:root {
  --bg-0: #050507;
  --bg-1: #0c0c10;
  --surface-1: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border-1: rgba(255, 255, 255, 0.09);
  --border-2: rgba(255, 255, 255, 0.14);
  --text-1: #ffffff;
  --text-2: rgba(255, 255, 255, 0.7);
  --text-3: rgba(255, 255, 255, 0.42);
  --red: #E50914;
  --red-light: #FF3A4C;
  --green: #28D67C;
  --orange: #FFB200;
  --radius: 18px;
  --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px rgba(229, 9, 20, 0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  background: var(--bg-0);
  color: var(--text-1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ═════════ Screens ═════════ */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  padding: 20px;
  animation: fadeIn .35s ease;
}
.screen.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ═════════ Orbs decorativos (tela de conexão) ═════════ */
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); z-index: 0; pointer-events: none;
  animation: orb-float 11s ease-in-out infinite;
}
.orb-a {
  width: 260px; height: 260px;
  background: radial-gradient(circle, var(--red) 0%, transparent 70%);
  top: -40px; left: -40px; opacity: .45;
}
.orb-b {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #8a00ff 0%, transparent 70%);
  bottom: -60px; right: -80px; opacity: .35;
  animation-delay: -5s;
}
@keyframes orb-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -30px) scale(1.08); }
}

/* ═════════ Tela de conexão ═════════ */
.connect-wrap {
  position: relative; z-index: 1;
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  max-width: 420px; margin: 0 auto; width: 100%;
}
.brand { text-align: center; margin-bottom: 36px; }
.brand h1 {
  font-size: 40px; font-weight: 900; letter-spacing: -1.5px;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-light) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}
.brand .tagline { color: var(--text-3); font-size: 13px; font-weight: 600; letter-spacing: .5px; }
.brand-mark {
  display: inline-flex; gap: 5px; margin-bottom: 18px;
}
.brand-mark .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-light));
  box-shadow: 0 0 12px var(--red);
  animation: dot-pulse 1.5s ease-in-out infinite;
}
.brand-mark .dot:nth-child(2) { animation-delay: .2s; }
.brand-mark .dot:nth-child(3) { animation-delay: .4s; }
@keyframes dot-pulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; transform: scale(1.2); } }

.card {
  background: var(--surface-1);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--border-1);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 24px;
  width: 100%;
}

.form-card { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field span { font-size: 12px; font-weight: 700; color: var(--text-3); letter-spacing: .5px; text-transform: uppercase; }
.field input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border-1);
  border-radius: 12px;
  color: var(--text-1);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  transition: border-color .15s ease, background .15s ease;
}
.field input:focus { outline: none; border-color: var(--red); background: rgba(255,255,255,.06); }
.field input::placeholder { color: var(--text-3); font-weight: 500; }

.btn-primary {
  position: relative;
  padding: 15px 20px;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-light) 100%);
  border: none; border-radius: 12px;
  color: white; font-size: 15px; font-weight: 800; letter-spacing: .3px;
  cursor: pointer; overflow: hidden;
  transition: transform .1s ease, box-shadow .2s ease;
  display: flex; align-items: center; justify-content: center;
  min-height: 52px;
}
.btn-primary.small { padding: 11px 20px; min-height: 44px; font-size: 13px; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary .spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: white; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.help { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 4px; line-height: 1.55; }
.help b { color: var(--text-1); font-weight: 700; }

/* ═════════ Tela remote: top bar ═════════ */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: var(--surface-1);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-1);
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  color: var(--text-1);
}
.status-led {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: led-pulse 2s ease-in-out infinite;
}
.status-pill.off .status-led { background: var(--text-3); box-shadow: none; animation: none; }
.status-pill.connecting .status-led { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
@keyframes led-pulse { 0%,100%{ opacity: 1; } 50% { opacity: .5; } }

.icon-btn {
  width: 42px; height: 42px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: 12px;
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  transition: background .15s ease;
}
.icon-btn:active { background: var(--surface-2); }

/* ═════════ Tabs ═════════ */
.tabs {
  display: flex; gap: 4px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 20px;
}
.tab {
  flex: 1; padding: 10px 6px;
  background: transparent; border: none;
  color: var(--text-3); font-weight: 700; font-size: 13px;
  border-radius: 10px;
  cursor: pointer; transition: all .18s ease;
  font-family: inherit;
}
.tab.active {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-light) 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(229,9,20,.35);
}

.tab-panel { display: none; flex: 1; flex-direction: column; }
.tab-panel.active { display: flex; }

/* ═════════ D-Pad ═════════ */
.dpad {
  margin: auto auto 20px;
  display: grid;
  grid-template-columns: repeat(3, 80px);
  grid-template-rows: repeat(3, 80px);
  gap: 8px;
  padding: 20px;
  background: var(--surface-1);
  border-radius: 32px;
  border: 1px solid var(--border-1);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-soft);
}
.dpad-btn {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 18px;
  color: var(--text-1);
  font-size: 22px; font-weight: 900;
  cursor: pointer;
  transition: transform .08s ease, background .12s ease;
  font-family: inherit;
}
.dpad-btn.up    { grid-column: 2; grid-row: 1; }
.dpad-btn.left  { grid-column: 1; grid-row: 2; }
.dpad-btn.ok    { grid-column: 2; grid-row: 2;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-light) 100%);
  font-size: 14px; letter-spacing: .5px;
  box-shadow: 0 6px 18px rgba(229,9,20,.4);
}
.dpad-btn.right { grid-column: 3; grid-row: 2; }
.dpad-btn.down  { grid-column: 2; grid-row: 3; }
.dpad-btn:active { transform: scale(.9); background: var(--surface-1); }
.dpad-btn.ok:active { transform: scale(.93); }

.side-buttons {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 14px;
}
.side-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 8px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: 14px;
  color: var(--text-2);
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  transition: all .15s ease;
  font-family: inherit;
}
.side-btn.wide { width: 100%; padding: 14px; font-size: 14px; }
.side-btn:active { background: var(--surface-2); color: var(--text-1); }

.quick-nav {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.quick-nav button {
  padding: 11px 4px;
  background: transparent;
  border: 1px dashed var(--border-1);
  border-radius: 12px;
  color: var(--text-3);
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s ease;
}
.quick-nav button:active { background: var(--surface-1); color: var(--red-light); border-color: var(--red); border-style: solid; }

/* ═════════ Touchpad ═════════ */
.touchpad {
  flex: 1;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: 24px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
  margin-bottom: 14px;
  overflow: hidden;
}
.touch-hint {
  color: var(--text-3);
  font-size: 13px; font-weight: 600;
  pointer-events: none;
  transition: opacity .3s ease;
}
.touchpad.active .touch-hint { opacity: 0; }
.touch-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ═════════ Keyboard ═════════ */
.kb-wrap { display: flex; flex-direction: column; gap: 14px; flex: 1; }
#kb-input {
  flex: 1;
  padding: 16px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: 16px; font-weight: 500;
  font-family: inherit;
  resize: none;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  min-height: 120px;
}
#kb-input:focus { outline: none; border-color: var(--red); }
.kb-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }

/* ═════════ Voice ═════════ */
.voice-wrap {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
}
.voice-btn {
  width: 150px; height: 150px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 2px solid var(--border-1);
  color: var(--text-1);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s ease;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.voice-btn:active { transform: scale(.95); }
.voice-btn.listening {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-light) 100%);
  border-color: transparent;
  box-shadow: var(--shadow-glow), 0 0 0 0 rgba(229, 9, 20, 0.7);
  animation: voice-pulse 1.4s ease-out infinite;
}
@keyframes voice-pulse {
  0% { box-shadow: var(--shadow-glow), 0 0 0 0 rgba(229,9,20,.7); }
  70% { box-shadow: var(--shadow-glow), 0 0 0 24px rgba(229,9,20,0); }
  100% { box-shadow: var(--shadow-glow), 0 0 0 0 rgba(229,9,20,0); }
}
.voice-status {
  font-size: 14px; font-weight: 700; color: var(--text-2);
}
.voice-transcript {
  min-height: 80px; max-width: 340px; padding: 14px 18px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: 14px;
  color: var(--text-1);
  font-size: 15px; text-align: center;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}

/* ═════════ Toast ═════════ */
.toast {
  position: fixed;
  bottom: calc(26px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: rgba(10, 10, 12, 0.92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 11px 18px;
  color: var(--text-1);
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-soft);
  z-index: 100;
  animation: toast-in .3s ease;
}
.toast.err { border-color: rgba(229, 9, 20, 0.5); color: #ffb4b4; }
.toast.ok  { border-color: rgba(40, 214, 124, 0.4); color: #b6f5d2; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
