/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg: #050508;
  --text-main: rgba(255, 255, 255, 0.85);
  --text-muted: rgba(255, 255, 255, 0.35);
  
  --coral: #e07a5f;
  --coral-light: #f2a68d;
  --coral-dim: rgba(224, 122, 95, 0.15);
  
  --white: #ffffff;
  --bubble-jarvis: rgba(255, 255, 255, 0.08);
  --bubble-user: #e07a5f;
  
  --nav-bg: rgba(20, 20, 25, 0.9);
  --nav-icon: #6b7280;
  --nav-icon-active: #e07a5f;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}

/* ── Header / Top Bar ─────────────────────────────────────────────────────── */
#top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 40px 20px 10px; /* Padding for iOS notch / status bar */
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 50;
  background: transparent;
}

.top-left h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 2px;
}

.top-left .subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#connection-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}

#connection-label {
  font-size: 13px;
  color: var(--text-muted);
}

#connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444; /* red by default */
}

#connection-badge.connected #connection-dot {
  background: #10b981; /* green */
}

.icon-btn {
  background: rgba(0,0,0,0.04);
  border: none;
  border-radius: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  cursor: pointer;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ── Main Layout ──────────────────────────────────────────────────────────── */
#app {
  position: fixed;
  inset: 0;
  padding-top: 100px;
  padding-bottom: 160px;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

/* ── Orb Container ────────────────────────────────────────────────────────── */
#orb-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  pointer-events: none;
}

#orb-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100vw !important;
  height: 100vh !important;
  z-index: -1;
}

/* ── Chat Area ────────────────────────────────────────────────────────────── */
#chat-area {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  height: 200px;
}

#status-text {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  opacity: 0.7;
}

.speech-bubble {
  padding: 14px 20px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.4;
  max-width: 85%;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.speech-bubble:not(:empty) { opacity: 1; }

.user-bubble {
  background: var(--bubble-user);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.jarvis-bubble {
  background: var(--bubble-jarvis);
  color: var(--text-main);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* ── Bottom Controls ──────────────────────────────────────────────────────── */
#controls-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 50;
  background: linear-gradient(to top, var(--bg) 80%, transparent);
}

.main-buttons {
  display: flex;
  align-items: center;
  gap: 16px;
}

#stop-jarvis-btn {
  background: rgba(224, 122, 95, 0.15);
  color: var(--coral);
  border: none;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
}

#mic-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(224, 122, 95, 0.3);
  background: rgba(5, 5, 8, 0.5);
  color: var(--coral);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#mic-btn:active {
  transform: scale(0.95);
}

body.state-listening #mic-btn {
  background: var(--coral);
  color: var(--white);
  box-shadow: 0 0 0 6px var(--coral-dim), 0 8px 24px rgba(224, 122, 95, 0.4);
  animation: pulse-mic 1.5s infinite;
}

@keyframes pulse-mic {
  0% { box-shadow: 0 0 0 0 rgba(224, 122, 95, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(224, 122, 95, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 122, 95, 0); }
}

.mic-icon, .stop-icon {
  width: 24px;
  height: 24px;
}

/* ── Bottom Nav ───────────────────────────────────────────────────────────── */
#bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 12px 24px;
  border-radius: 30px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.05);
  margin-bottom: 10px;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--nav-icon);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ── AI Model Modal Buttons ─────────────────────────────────────────── */
.ai-model-btn {
  background: rgba(30, 30, 40, 0.8);
  color: #fff;
  border: 1px solid #444;
  padding: 15px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  text-transform: capitalize;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-model-btn.active {
  background: rgba(224, 122, 95, 0.2);
  border-color: var(--coral);
  color: var(--coral);
}

.ai-model-btn:active {
  transform: scale(0.95);
}

.nav-btn svg {
  width: 22px;
  height: 22px;
}

.nav-btn.active {
  color: var(--nav-icon-active);
  background: var(--coral-dim);
  border-radius: 12px;
}
