/* Bantito — Cosmos nocturno */

:root {
  /* Colors */
  --bg: #0E0620;
  --bg-light: #1A0B3A;
  --surface: rgba(124, 58, 237, 0.08);
  --surface-strong: rgba(124, 58, 237, 0.14);
  --surface-border: rgba(167, 139, 250, 0.22);
  --primary: #7C3AED;
  --primary-soft: #A78BFA;
  --accent: #D946EF;
  --success: #10B981;
  --danger: #EF4444;
  --text: #F5F3FF;
  --text-dim: #C4B5FD;
  --text-muted: rgba(245, 243, 255, 0.55);

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-8: 48px;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-full: 9999px;

  /* Shadows/glows */
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --glow-primary: 0 0 40px rgba(124, 58, 237, 0.45), 0 0 80px rgba(124, 58, 237, 0.18);
  --glow-accent: 0 0 30px rgba(217, 70, 239, 0.4);

  /* Fonts */
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

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

html,
body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(124, 58, 237, 0.18), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(217, 70, 239, 0.12), transparent 60%),
    var(--bg);
}

/* Starfield */
.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.stars::before,
.stars::after {
  content: "";
  position: absolute;
  inset: -50%;
  background-image:
    radial-gradient(1px 1px at 20% 30%, white, transparent 50%),
    radial-gradient(1px 1px at 60% 70%, white, transparent 50%),
    radial-gradient(2px 2px at 80% 10%, rgba(255, 255, 255, 0.85), transparent 50%),
    radial-gradient(1px 1px at 40% 60%, rgba(255, 255, 255, 0.6), transparent 50%),
    radial-gradient(1px 1px at 90% 90%, white, transparent 50%),
    radial-gradient(2px 2px at 10% 80%, rgba(255, 255, 255, 0.55), transparent 50%),
    radial-gradient(1px 1px at 70% 40%, white, transparent 50%),
    radial-gradient(1px 1px at 30% 20%, rgba(255, 255, 255, 0.7), transparent 50%),
    radial-gradient(1.5px 1.5px at 50% 50%, rgba(255, 255, 255, 0.45), transparent 50%),
    radial-gradient(1px 1px at 15% 85%, white, transparent 50%),
    radial-gradient(1px 1px at 85% 45%, rgba(255, 255, 255, 0.8), transparent 50%),
    radial-gradient(1px 1px at 5% 15%, rgba(255, 255, 255, 0.6), transparent 50%);
  background-size: 800px 800px;
  background-repeat: repeat;
  opacity: 0.5;
  animation: twinkle 9s ease-in-out infinite alternate;
}

.stars::after {
  background-size: 1200px 1200px;
  animation-duration: 14s;
  animation-delay: -3s;
  opacity: 0.35;
}

@keyframes twinkle {
  0% {
    opacity: 0.35;
    transform: translate(0, 0);
  }
  100% {
    opacity: 0.85;
    transform: translate(-20px, -15px);
  }
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5);
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
}

header h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-soft), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.01em;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Status badge */
.status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.status.disconnected {
  background: rgba(167, 139, 250, 0.1);
  color: var(--text-dim);
  border: 1px solid rgba(167, 139, 250, 0.2);
}

.status.connected {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.status.error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

/* Hero */
.auth-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5) 0;
}

.hero {
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-5);
  animation: heroIn 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes heroIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.avatar {
  width: 160px;
  height: 160px;
  filter: drop-shadow(0 0 40px rgba(124, 58, 237, 0.55))
    drop-shadow(0 0 90px rgba(217, 70, 239, 0.3));
  animation: float 5s ease-in-out infinite;
}

.hero-video {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 28px;
  background: var(--bg);
  filter: drop-shadow(0 0 50px rgba(124, 58, 237, 0.5))
    drop-shadow(0 0 100px rgba(217, 70, 239, 0.25));
  animation: float 6s ease-in-out infinite;
  display: block;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 20%, var(--primary-soft) 70%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  font-size: 1.0625rem;
  color: var(--text-dim);
  max-width: 460px;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  flex-wrap: wrap;
  justify-content: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.875rem 1.75rem;
  border-radius: var(--r-full);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  text-decoration: none;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--primary-soft);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary,
#connectBtn,
#restartBtn,
#sendBtn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  box-shadow: var(--glow-primary);
}

.btn-primary:hover:not(:disabled),
#connectBtn:hover:not(:disabled),
#restartBtn:hover:not(:disabled),
#sendBtn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--glow-primary), 0 10px 30px rgba(124, 58, 237, 0.35);
  border: none;
}

.icon-btn {
  font-size: 0.8125rem;
  padding: 0.625rem 1.125rem;
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--surface-border);
  box-shadow: none;
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--primary-soft);
  transform: translateY(-1px);
  box-shadow: none;
}

.btn.danger,
#disconnectBtn {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
  box-shadow: none;
}

.btn.danger:hover:not(:disabled),
#disconnectBtn:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
  transform: translateY(-1px);
  box-shadow: none;
}

/* App section */
.app-section {
  flex: 1;
  padding: var(--sp-3) 0;
}

.app-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: var(--sp-6);
  min-height: calc(100vh - 160px);
  align-items: start;
}

.left-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-height: 0;
}

.right-panel {
  height: calc(100vh - 180px);
}

/* Video container */
.video-container {
  background: var(--bg-light);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  position: relative;
  box-shadow: var(--shadow-md);
}

#video-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
  background: linear-gradient(135deg, var(--bg-light), #241048);
  z-index: 1;
  text-align: center;
  padding: var(--sp-4);
}

#video-placeholder.hidden {
  display: none;
}

/* Audio orb */
.audio-orb {
  width: 100%;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.audio-orb::before {
  content: "";
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  background: radial-gradient(circle at 35% 35%, var(--text-dim), rgba(167, 139, 250, 0.25));
  opacity: 0.55;
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(167, 139, 250, 0.25);
}

.audio-orb.listening::before {
  background: radial-gradient(circle at 35% 35%, #6EE7B7, var(--success));
  opacity: 1;
  animation: pulseListening 1.8s ease-in-out infinite;
  box-shadow: 0 0 35px var(--success), 0 0 60px rgba(16, 185, 129, 0.4);
}

.audio-orb.speaking::before {
  background: radial-gradient(circle at 35% 35%, var(--accent), var(--primary));
  opacity: 1;
  animation: pulseSpeaking 0.55s ease-in-out infinite;
  box-shadow: 0 0 40px var(--accent), 0 0 80px rgba(217, 70, 239, 0.45);
}

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

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

/* Controls */
.controls {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* Chat */
.chat-log {
  flex: 1;
  overflow-y: auto;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  scroll-behavior: smooth;
  min-height: 300px;
}

.chat-log::-webkit-scrollbar {
  width: 6px;
}

.chat-log::-webkit-scrollbar-track {
  background: transparent;
}

.chat-log::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.3);
  border-radius: 3px;
}

.chat-log::-webkit-scrollbar-thumb:hover {
  background: rgba(167, 139, 250, 0.5);
}

.message {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  max-width: 82%;
  word-wrap: break-word;
  animation: msgIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  line-height: 1.5;
  font-size: 0.9375rem;
}

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

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.25);
}

.message.gemini {
  align-self: flex-start;
  background: rgba(124, 58, 237, 0.14);
  color: var(--text);
  border: 1px solid var(--surface-border);
  border-bottom-left-radius: 4px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.input-area {
  display: flex;
  gap: var(--sp-2);
}

#textInput {
  flex: 1;
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-full);
  padding: 0.875rem 1.25rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  outline: none;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#textInput:focus {
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

#textInput::placeholder {
  color: var(--text-muted);
}

/* Session end */
.session-end-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  padding: var(--sp-8) var(--sp-4);
  text-align: center;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.session-end-section h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.session-end-section .avatar {
  width: 120px;
  height: 120px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(14, 6, 32, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--sp-5);
  animation: modalIn 0.3s ease-out;
}

.modal.hidden {
  display: none;
}

@keyframes modalIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 960px;
  background: var(--bg-light);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md), var(--glow-primary);
  animation: modalContentIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalContentIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-close {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  background: rgba(14, 6, 32, 0.85);
  border: 1px solid var(--surface-border);
  color: var(--text);
  font-size: 1.375rem;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
}

.modal-close:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.05);
}

.modal-content iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  display: block;
}

.modal-footer {
  padding: var(--sp-5) var(--sp-5) var(--sp-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  background: linear-gradient(180deg, transparent, rgba(124, 58, 237, 0.06));
  border-top: 1px solid var(--surface-border);
}

.modal-hint {
  color: var(--text-dim);
  font-size: 0.9375rem;
  text-align: center;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: var(--sp-4) var(--sp-3);
  }

  header {
    margin-bottom: var(--sp-4);
  }

  header h1 {
    font-size: 1.25rem;
  }

  .app-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .right-panel {
    height: auto;
  }

  .avatar {
    width: 120px;
    height: 120px;
  }

  .hero-video {
    max-width: 100%;
    border-radius: 20px;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-sub {
    font-size: 0.9375rem;
  }

  .hero-actions {
    flex-direction: column;
    width: 100%;
    max-width: 300px;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .controls {
    justify-content: center;
  }

  .controls .btn {
    flex: 1 1 auto;
    min-width: 140px;
  }

  .chat-log {
    min-height: 280px;
    max-height: 400px;
  }

  .session-end-section h2 {
    font-size: 1.5rem;
  }
}
