/* ============================================================
   VozActiva - Premium Dark UI with Glassmorphism
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ──────────────────────────────────────────── */
:root {
  --color-bg: #0d0a1a;
  --color-surface: rgba(255, 255, 255, 0.04);
  --color-surface-hover: rgba(255, 255, 255, 0.08);
  --color-border: rgba(255, 255, 255, 0.1);
  --color-border-active: rgba(168, 85, 247, 0.6);
  --color-purple: #a855f7;
  --color-cyan: #06b6d4;
  --color-green: #22c55e;
  --color-red: #ef4444;
  --color-amber: #f59e0b;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-text-faint: #475569;
  --gradient-main: linear-gradient(135deg, var(--color-purple), var(--color-cyan));
  --gradient-glow: linear-gradient(135deg, rgba(168,85,247,0.15), rgba(6,182,212,0.15));
  --shadow-glow: 0 0 40px rgba(168, 85, 247, 0.25);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ── Animated Background ─────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(168, 85, 247, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.10) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(168, 85, 247, 0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── App Container ───────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 100px;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 32px 0 24px;
}

.app-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--gradient-main);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
  animation: logoPulse 4s ease-in-out infinite;
}

.app-logo img {
  width: 36px;
  height: 36px;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(168,85,247,0.3); }
  50% { box-shadow: 0 0 40px rgba(168,85,247,0.6), 0 0 80px rgba(6,182,212,0.2); }
}

.app-header-text h1 {
  font-size: 1.4rem;
  font-weight: 800;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.app-header-text p {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: var(--transition);
}

.card:hover {
  background: var(--color-surface-hover);
  border-color: rgba(255,255,255,0.15);
}

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--gradient-main);
  border-radius: 2px;
}

/* ── Mic Button ─────────────────────────────────────────── */
.mic-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
}

.mic-btn-wrapper {
  position: relative;
  margin-bottom: 20px;
}

.mic-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--gradient-main);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: var(--transition);
  box-shadow: 0 0 0 0 rgba(168,85,247,0.4);
}

.mic-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(168,85,247,0.5);
}

.mic-btn:active {
  transform: scale(0.97);
}

.mic-btn svg {
  width: 48px;
  height: 48px;
  fill: white;
  transition: var(--transition);
}

/* ── Listening state ─────────────────────────────────────── */
.mic-btn.listening {
  animation: micPulse 1.5s ease-in-out infinite;
}

.mic-btn.listening::before,
.mic-btn.listening::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(168,85,247,0.5);
  animation: ripple 2s ease-out infinite;
}

.mic-btn.listening::before {
  width: 140px;
  height: 140px;
  animation-delay: 0s;
}

.mic-btn.listening::after {
  width: 180px;
  height: 180px;
  animation-delay: 0.5s;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(168,85,247,0.4); }
  50% { box-shadow: 0 0 50px rgba(168,85,247,0.8), 0 0 80px rgba(6,182,212,0.3); }
}

@keyframes ripple {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.mic-btn.detected {
  background: linear-gradient(135deg, var(--color-green), #16a34a);
  animation: detectedPulse 0.5s ease-in-out 3;
}

@keyframes detectedPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.mic-btn.error {
  background: linear-gradient(135deg, var(--color-red), #dc2626);
}

/* ── Status Badge ────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  transition: var(--transition);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-faint);
  transition: var(--transition);
}

.status-badge.idle .status-dot { background: var(--color-text-faint); }
.status-badge.listening .status-dot {
  background: var(--color-cyan);
  animation: dotBlink 1s ease-in-out infinite;
  box-shadow: 0 0 8px var(--color-cyan);
}
.status-badge.detected .status-dot {
  background: var(--color-green);
  box-shadow: 0 0 8px var(--color-green);
}
.status-badge.error .status-dot { background: var(--color-red); }

@keyframes dotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-badge.listening {
  border-color: rgba(6,182,212,0.4);
  background: rgba(6,182,212,0.08);
}
.status-badge.detected {
  border-color: rgba(34,197,94,0.4);
  background: rgba(34,197,94,0.08);
}
.status-badge.error {
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.08);
}

/* ── Canvas Visualizer ──────────────────────────────────── */
.visualizer-container {
  width: 100%;
  height: 80px;
  position: relative;
  margin-top: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--color-border);
}

#visualizer {
  width: 100%;
  height: 100%;
}

/* ── Activation Word Config ────────────────────────────── */
.word-display {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(168,85,247,0.08);
  border: 1px solid rgba(168,85,247,0.25);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.word-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.word-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex: 1;
}

.word-badge {
  font-size: 0.65rem;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(168,85,247,0.2);
  border: 1px solid rgba(168,85,247,0.4);
  color: var(--color-purple);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Form Inputs ─────────────────────────────────────────── */
.input-group {
  display: flex;
  gap: 10px;
}

.text-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  padding: 12px 16px;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

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

.text-input:focus {
  border-color: var(--color-border-active);
  background: rgba(168,85,247,0.08);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.15);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-xs);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 4px 16px rgba(168,85,247,0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(168,85,247,0.5);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
  border-color: rgba(255,255,255,0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--color-purple);
  border: 1px solid rgba(168,85,247,0.35);
}

.btn-ghost:hover {
  background: rgba(168,85,247,0.1);
  border-color: rgba(168,85,247,0.6);
}

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--color-red);
  border: 1px solid rgba(239,68,68,0.3);
}

.btn-danger:hover {
  background: rgba(239,68,68,0.25);
}

/* ── Notice / Alert ──────────────────────────────────────── */
.notice {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.5;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.notice-info {
  background: rgba(6,182,212,0.08);
  border: 1px solid rgba(6,182,212,0.25);
  color: #7dd3fc;
}

.notice-warn {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  color: #fcd34d;
}

.notice-success {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.25);
  color: #86efac;
}

.notice-error {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
}

.notice-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── History List ────────────────────────────────────────── */
.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  transition: var(--transition);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

.history-item:hover {
  background: var(--color-surface-hover);
}

.history-time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-faint);
  white-space: nowrap;
}

.history-word {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--color-cyan);
  flex: 1;
}

.history-chip {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.3);
  color: var(--color-green);
  font-weight: 600;
}

/* ── Permissions Section ─────────────────────────────────── */
.perm-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.perm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  transition: var(--transition);
}

.perm-icon {
  font-size: 1.3rem;
  width: 36px;
  text-align: center;
}

.perm-info {
  flex: 1;
}

.perm-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
}

.perm-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.perm-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
}

.perm-status.granted {
  background: rgba(34,197,94,0.15);
  color: var(--color-green);
  border: 1px solid rgba(34,197,94,0.3);
}

.perm-status.denied {
  background: rgba(239,68,68,0.15);
  color: var(--color-red);
  border: 1px solid rgba(239,68,68,0.3);
}

.perm-status.prompt, .perm-status.unknown {
  background: rgba(245,158,11,0.12);
  color: var(--color-amber);
  border: 1px solid rgba(245,158,11,0.3);
}

/* ── Install Banner ──────────────────────────────────────── */
#install-banner {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(168,85,247,0.15), rgba(6,182,212,0.15));
  border: 1px solid rgba(168,85,247,0.35);
  border-radius: var(--radius);
  margin-bottom: 16px;
  animation: slideIn 0.4s ease-out;
}

#install-banner.visible { display: flex; }

.install-banner-text {
  flex: 1;
}

.install-banner-text strong {
  display: block;
  font-size: 0.9rem;
  color: var(--color-text);
  margin-bottom: 2px;
}

.install-banner-text span {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* ── Toast ──────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  background: rgba(30, 20, 50, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: 100px;
  padding: 12px 24px;
  font-size: 0.875rem;
  color: var(--color-text);
  white-space: nowrap;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  pointer-events: none;
  box-shadow: var(--shadow-card);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Bottom Listening Bar ────────────────────────────────── */
#listening-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(13,10,26,0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--color-border);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

#listening-bar.visible {
  transform: translateY(0);
}

.listening-bar-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-cyan);
  animation: dotBlink 1s ease-in-out infinite;
  box-shadow: 0 0 8px var(--color-cyan);
  flex-shrink: 0;
}

.listening-bar-text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.listening-bar-word {
  font-family: var(--font-mono);
  color: var(--color-cyan);
  font-weight: 600;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 380px) {
  #app { padding: 0 12px 100px; }
  .mic-btn { width: 100px; height: 100px; }
  .mic-btn svg { width: 40px; height: 40px; }
}

/* ── Android Card — Toggle & Steps ──────────────────────── */
.android-action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
}

.android-action-info { flex: 1; }

.android-action-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.android-action-desc {
  font-size: 0.76rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* Toggle switch */
.toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.toggle-track {
  display: block;
  width: 52px;
  height: 28px;
  background: rgba(255,255,255,0.12);
  border: 1px solid var(--color-border);
  border-radius: 100px;
  position: relative;
  transition: var(--transition);
}

.toggle-thumb {
  display: block;
  width: 20px;
  height: 20px;
  background: var(--color-text-faint);
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.toggle-btn.active .toggle-track {
  background: rgba(168,85,247,0.35);
  border-color: rgba(168,85,247,0.6);
  box-shadow: 0 0 12px rgba(168,85,247,0.3);
}

.toggle-btn.active .toggle-thumb {
  transform: translateX(24px);
  background: var(--color-purple);
  box-shadow: 0 0 8px rgba(168,85,247,0.6);
}

/* Steps list */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gradient-main);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  box-shadow: 0 0 8px rgba(168,85,247,0.4);
}

.step-text {
  font-size: 0.83rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  padding-top: 3px;
}

.step-text strong {
  color: var(--color-text);
}

/* ── Detection Flash Overlay ────────────────────────────── */
#detection-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  background: radial-gradient(circle at center,
    rgba(168, 85, 247, 0.35) 0%,
    rgba(6, 182, 212, 0.20) 40%,
    transparent 70%
  );
}

#detection-flash.active {
  animation: screenFlash 0.8s ease-out forwards;
}

@keyframes screenFlash {
  0%   { opacity: 0;    transform: scale(0.85); }
  15%  { opacity: 1;    transform: scale(1.02); }
  40%  { opacity: 0.7;  transform: scale(1); }
  100% { opacity: 0;    transform: scale(1); }
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(168,85,247,0.3); border-radius: 2px; }

/* ── Selection ──────────────────────────────────────────── */
::selection {
  background: rgba(168,85,247,0.35);
  color: white;
}
