/* DARLI Voice Interface — Sci-Fi Theme */
:root {
  --bg: #0a0a12;
  --bg2: #12121f;
  --accent: #00e5ff;
  --accent2: #7c4dff;
  --accent-glow: rgba(0, 229, 255, 0.3);
  --text: #e0e0e0;
  --text-dim: #6a6a7a;
  --success: #00e676;
  --warning: #ffab40;
  --error: #ff5252;
  --card-bg: rgba(18, 18, 31, 0.85);
  --border: rgba(0, 229, 255, 0.15);
  --radius: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

/* ── Login Screen ─────────────────────── */
#login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 1000;
}

.login-box {
  text-align: center;
  padding: 2.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  width: 320px;
}

.login-box h1 {
  font-size: 1.8rem;
  font-weight: 300;
  letter-spacing: 6px;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.login-box p {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.pin-input {
  width: 100%;
  padding: 14px 20px;
  font-size: 1.5rem;
  letter-spacing: 12px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-family: var(--mono);
  outline: none;
  -webkit-text-security: disc;
}

.pin-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.login-error {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 1rem;
  min-height: 1.2rem;
}

/* ── Main Layout ──────────────────────── */
#app {
  display: none;
  height: 100%;
  flex-direction: column;
}

#app.active {
  display: flex;
}

/* ── Status Bar (top) ─────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-family: var(--mono);
  flex-shrink: 0;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--error);
  transition: background 0.3s;
}

.status-dot.connected { background: var(--success); }
.status-dot.thinking { background: var(--warning); animation: pulse-dot 1s infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-text { color: var(--text-dim); }
.status-mode {
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.1);
  color: var(--accent);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── Main Content ─────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* ── Orb ──────────────────────────────── */
.orb-container {
  position: relative;
  width: 200px;
  height: 200px;
  flex-shrink: 0;
}

.orb {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%,
    rgba(0, 229, 255, 0.4),
    rgba(124, 77, 255, 0.3) 50%,
    rgba(10, 10, 18, 0.9));
  box-shadow:
    0 0 60px var(--accent-glow),
    0 0 120px rgba(124, 77, 255, 0.15),
    inset 0 0 40px rgba(0, 229, 255, 0.1);
  transition: all 0.5s ease;
  animation: orb-breathe 4s ease-in-out infinite;
}

.orb.thinking {
  animation: orb-think 1.5s ease-in-out infinite;
  box-shadow:
    0 0 80px rgba(255, 171, 64, 0.4),
    0 0 140px rgba(255, 171, 64, 0.15),
    inset 0 0 50px rgba(255, 171, 64, 0.1);
}

.orb.speaking {
  animation: orb-speak 0.8s ease-in-out infinite;
  box-shadow:
    0 0 80px rgba(0, 230, 118, 0.4),
    0 0 140px rgba(0, 230, 118, 0.15),
    inset 0 0 50px rgba(0, 230, 118, 0.1);
}

.orb.listening {
  animation: orb-listen 1s ease-in-out infinite;
  box-shadow:
    0 0 80px rgba(0, 229, 255, 0.5),
    0 0 140px rgba(0, 229, 255, 0.2),
    inset 0 0 50px rgba(0, 229, 255, 0.15);
}

.orb.error {
  box-shadow:
    0 0 80px rgba(255, 82, 82, 0.4),
    0 0 140px rgba(255, 82, 82, 0.15);
}

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@keyframes orb-think {
  0%, 100% { transform: scale(1); filter: hue-rotate(0deg); }
  50% { transform: scale(1.06); filter: hue-rotate(30deg); }
}

@keyframes orb-speak {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes orb-listen {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Orb rings */
.orb-ring {
  position: absolute;
  inset: -15px;
  border-radius: 50%;
  border: 1px solid rgba(0, 229, 255, 0.1);
  animation: ring-rotate 20s linear infinite;
}

.orb-ring:nth-child(2) {
  inset: -30px;
  border-color: rgba(124, 77, 255, 0.08);
  animation-duration: 30s;
  animation-direction: reverse;
}

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

/* ── Presence State ───────────────────── */
.presence-label {
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: color 0.3s;
  min-height: 1.3rem;
}

.presence-label.active { color: var(--accent); }

/* ── Transcript ───────────────────────── */
.transcript-area {
  width: 100%;
  max-width: 600px;
  padding: 0 20px;
  margin-top: 20px;
  max-height: 150px;
  overflow-y: auto;
  flex-shrink: 0;
}

.transcript-bubble {
  padding: 10px 16px;
  margin-bottom: 8px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.5;
  animation: fade-in 0.3s ease;
}

.transcript-bubble.user {
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.15);
  margin-left: 40px;
  text-align: right;
}

.transcript-bubble.assistant {
  background: rgba(124, 77, 255, 0.08);
  border: 1px solid rgba(124, 77, 255, 0.15);
  margin-right: 40px;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Action Cards ─────────────────────── */
.action-cards {
  width: 100%;
  max-width: 600px;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
  flex-shrink: 0;
}

.action-card {
  padding: 8px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: card-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes card-pop {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ── Controls (bottom) ────────────────── */
.controls {
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 600px;
}

/* Talk Button */
.talk-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: rgba(0, 229, 255, 0.08);
  color: var(--accent);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.talk-btn:active,
.talk-btn.active {
  background: rgba(0, 229, 255, 0.2);
  box-shadow: 0 0 30px var(--accent-glow);
  transform: scale(1.08);
}

.talk-btn.listening {
  border-color: var(--success);
  color: var(--success);
  background: rgba(0, 230, 118, 0.15);
  animation: btn-pulse 1s infinite;
}

@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(0, 230, 118, 0.2); }
  50% { box-shadow: 0 0 40px rgba(0, 230, 118, 0.4); }
}

/* Stop Button */
.stop-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--error);
  background: rgba(255, 82, 82, 0.08);
  color: var(--error);
  font-size: 0.9rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.stop-btn.visible { display: flex; }

/* Text Input */
.text-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 600px;
}

.text-input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent);
}

.text-input::placeholder {
  color: var(--text-dim);
}

.send-btn {
  padding: 10px 16px;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── Mic Level ────────────────────────── */
.mic-level {
  width: 40px;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.mic-level-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s;
  border-radius: 2px;
}

/* ── Scrollbar ────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Mobile ───────────────────────────── */
@media (max-width: 600px) {
  .orb-container { width: 150px; height: 150px; }
  .orb-ring:first-child { inset: -10px; }
  .orb-ring:nth-child(2) { inset: -20px; }
  .transcript-area { max-height: 100px; }
  .talk-btn { width: 56px; height: 56px; font-size: 1.3rem; }
}

/* ── Desktop Side Panel ───────────────── */
@media (min-width: 900px) {
  .main-content {
    flex-direction: row;
  }

  .orb-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .side-panel {
    width: 320px;
    height: 100%;
    border-left: 1px solid var(--border);
    background: var(--bg2);
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow-y: auto;
  }

  .side-panel .transcript-area {
    max-height: none;
    flex: 1;
    padding: 0;
  }
}

@media (max-width: 899px) {
  .side-panel { display: none; }
}
