/* 
  Theme: Black & Green (Cinematic 3D Interface - Immersive Upgrade)
  Fonts: Inter (UI), JetBrains Mono (Code)
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Colors */
  --bg-black: #020202;
  --primary-green: #00ff88;
  --primary-green-dim: rgba(0, 255, 136, 0.15);
  --glass-bg: rgba(5, 10, 5, 0.85);
  --glass-border: rgba(0, 255, 136, 0.3);
  /* Volumetric Shadow + Neon Glow */
  --panel-shadow:
    1px 1px 0 #000,
    2px 2px 0 #000,
    3px 3px 0 #000,
    4px 4px 0 #000,
    5px 5px 0 #000,
    0 0 20px rgba(0, 255, 136, 0.2),
    0 0 40px rgba(0, 255, 136, 0.1);
  --text-white: #ececec;
  --text-gray: #9ca3af;
  --border-color: #2a2a2a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-black);
  color: var(--text-white);
  height: 100vh;
  overflow: hidden;
  margin: 0;
}

/* --- Immersive 3D Layout --- */
.scene {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 2000px;
  /* Deepened Perspective */
  overflow: hidden;
  /* Dynamic Spotlight + Deep Space Background */
  background:
    radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(0, 255, 136, 0.06) 0%, transparent 40%),
    radial-gradient(circle at center, #0a0f0a 0%, #000 90%);
  position: relative;
}

/* Subtle animated background grid */
.scene::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background-image:
    linear-gradient(rgba(0, 255, 136, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 136, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  transform: perspective(500px) rotateX(60deg);
  animation: bgScroll 20s linear infinite;
  z-index: -1;
  pointer-events: none;
}

@keyframes bgScroll {
  from {
    transform: perspective(500px) rotateX(60deg) translateY(0);
  }

  to {
    transform: perspective(500px) rotateX(60deg) translateY(50px);
  }
}

.stage {
  display: flex;
  width: 90vw;
  height: 85vh;
  transform-style: preserve-3d;
  transition: transform 0.1s ease-out;
  gap: 24px;
}

/* --- Panel Common Styles --- */
.panel {
  background-color: var(--glass-bg);
  backdrop-filter: blur(24px);
  border: none;
  /* Square bottom corners for strict uniformity */
  border-radius: 0;
  /* Removed base box-shadow to let pseudo-element handle the glow, focusing on volume here */
  box-shadow:
    1px 1px 0 #000,
    2px 2px 0 #000,
    3px 3px 0 #000,
    4px 4px 0 #000,
    5px 5px 0 #000;
  display: flex;
  flex-direction: column;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  animation: float 6s ease-in-out infinite;
  position: relative;
}

/* Infinite Border Effect */
.panel::before {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  /* Inherit rounded/square corners */
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.1), transparent 40%, transparent 60%, rgba(0, 255, 136, 0.1));
  box-shadow:
    0 0 15px rgba(0, 255, 136, 0.3),
    0 0 30px rgba(0, 255, 136, 0.1),
    inset 0 0 20px rgba(0, 255, 136, 0.1);
  animation: breathingBorder 4s ease-in-out infinite alternate;
  transform: translateZ(-1px);
  /* Push slightly back */
}

/* Holographic Sheen (Scanline) */
.panel::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(120deg, transparent 40%, rgba(255, 255, 255, 0.05) 50%, transparent 60%);
  background-size: 200% 100%;
  background-position: 100% 0;
  animation: holographicScan 6s linear infinite;
  pointer-events: none;
  border-radius: inherit;
  /* Inherit rounded/square corners */
  mix-blend-mode: overlay;
  z-index: 2;
  /* On top of content or just below text? */
}

@keyframes holographicScan {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

@keyframes breathingBorder {
  0% {
    opacity: 0.6;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3), inset 0 0 10px rgba(0, 255, 136, 0.1);
  }

  100% {
    opacity: 1;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.6), 0 0 60px rgba(0, 255, 136, 0.2), inset 0 0 25px rgba(0, 255, 136, 0.2);
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

.panel:hover {
  z-index: 50;
}

.panel:hover::before {
  opacity: 1;
  box-shadow:
    0 0 40px rgba(0, 255, 136, 0.8),
    0 0 80px rgba(0, 255, 136, 0.4),
    inset 0 0 40px rgba(0, 255, 136, 0.3);
  transition: all 0.3s ease;
}

/* --- Left Panel (Sidebar) --- */
.left-panel {
  width: 260px;
  flex-shrink: 0;
  animation: floatLeft 7s ease-in-out infinite;
  z-index: 10;
}

@keyframes floatLeft {

  0%,
  100% {
    transform: rotateY(15deg) translateZ(-40px) translateY(0);
  }

  50% {
    transform: rotateY(15deg) translateZ(-40px) translateY(-12px);
  }
}

.panel-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 600;
  color: var(--text-gray);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  transform: translateZ(30px);
  /* Pop out */
  transform-style: preserve-3d;
}

.logo-small {
  background: var(--primary-green);
  color: #000;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
  box-shadow: 0 0 10px var(--primary-green);
}

.sidebar-content-wrapper {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: visible;
  /* Needed for 3D visibility */
  transform-style: preserve-3d;
}

/* --- Center Panel (Chat) --- */
.center-panel {
  flex: 1;
  animation: floatCenter 8s ease-in-out infinite;
  z-index: 20;
  background: radial-gradient(circle at top, rgba(16, 32, 20, 0.9) 0%, rgba(5, 10, 5, 0.95) 60%);
  border: none;
  /* BORDER REMOVED */
  position: relative;
  /* Context for avatar */
}

/* --- Holographic Avatar --- */
.hologram-avatar {
  position: absolute;
  top: 50%;
  left: 20px;
  width: 100px;
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transform: translateZ(50px) translateY(-50%);
  transform-style: preserve-3d;
  pointer-events: none;
}

.avatar-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary-green);
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
  z-index: 2;
  background: #000;
  transition: all 0.3s ease;
}

/* Speaking State */
.hologram-avatar.speaking .avatar-image {
  border-color: #fff;
  box-shadow: 0 0 25px var(--primary-green), 0 0 50px var(--primary-green);
  transform: scale(1.05);
}

.avatar-waves {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid transparent;
  opacity: 0;
  z-index: 0;
}

.hologram-avatar.speaking .avatar-waves {
  animation: wave 1.5s infinite;
  border-color: var(--primary-green);
}

@keyframes floatCenter {

  0%,
  100% {
    transform: translateZ(60px) translateY(0);
  }

  50% {
    transform: translateZ(60px) translateY(-15px);
  }
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulseCore {
  0% {
    transform: scale(1);
  }

  100% {
    transform: scale(1.2);
  }
}

@keyframes wave {
  0% {
    width: 100%;
    height: 100%;
    opacity: 0.8;
  }

  100% {
    width: 200%;
    height: 200%;
    opacity: 0;
  }
}

.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-black);
  z-index: 10;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.5rem 140px 1.5rem;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  transform-style: preserve-3d;
}

.chat-container::-webkit-scrollbar {
  width: 6px;
}

.chat-container::-webkit-scrollbar-thumb {
  background-color: #333;
  border-radius: 3px;
}

.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  opacity: 1;
  transition: opacity 0.5s ease;
  transform: translateZ(30px);
  /* Pop out */
  transform-style: preserve-3d;
}

.welcome-screen.hidden {
  display: none;
  opacity: 0;
}

.logo-wrapper {
  width: 80px;
  height: 80px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--primary-green);
  box-shadow: 0 0 40px rgba(0, 255, 136, 0.2), inset 0 0 20px rgba(0, 255, 136, 0.1);
  animation: pulse 3s infinite ease-in-out;
  transform: translateZ(20px);
}

.logo-icon {
  font-weight: 800;
  font-size: 2rem;
  color: var(--primary-green);
  text-shadow: 0 0 20px var(--primary-green);
}

/* Messages */
.message {
  display: flex;
  padding: 1.5rem 1rem;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  animation: slideUpFade 0.4s ease-out;
  transform: translateZ(25px);
  /* Pop out messages */
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(20px) translateZ(25px);
  }

  to {
    opacity: 1;
    transform: translateY(0) translateZ(25px);
  }
}

.messageui-content {
  line-height: 1.7;
  font-size: 1.05rem;
  letter-spacing: 0.3px;
}

.message.user .message-content {
  color: var(--text-white);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.message.ai .message-content {
  color: #e0e0e0;
}

/* Input Area */
.input-area {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.98) 20%, transparent);
  padding: 0 2rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  transform-style: preserve-3d;
  pointer-events: none;
  /* Allow events through gradient area */
}

.input-container {
  width: 100%;
  pointer-events: auto;
  background: rgba(10, 20, 15, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 1.2rem;
  padding: 0.85rem 1rem 0.85rem 1.25rem;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform: translateZ(50px);
  /* Significant pop out */
}

.input-container:focus-within {
  border-color: var(--primary-green);
  box-shadow: 0 0 30px rgba(0, 255, 136, 0.2);
  transform: translateZ(55px) translateY(-2px);
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-white);
  font-family: inherit;
  font-size: 1.05rem;
  resize: none;
  max-height: 200px;
  padding: 6px 0;
  outline: none;
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

#send-btn {
  background-color: var(--primary-green);
  color: #000;
  border: none;
  border-radius: 0.8rem;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 0 15px var(--primary-green-dim);
  transform: translateZ(10px);
}

#send-btn:disabled {
  background-color: #1a1a1a;
  color: #444;
  cursor: default;
  box-shadow: none;
}

#send-btn:not(:disabled):hover {
  transform: translateZ(15px) scale(1.05);
  box-shadow: 0 0 25px var(--primary-green);
}

.disclaimer {
  font-size: 0.7rem;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.7;
  transform: translateZ(10px);
}

/* --- Right Panel (Status) --- */
.right-panel {
  width: 260px;
  flex-shrink: 0;
  animation: floatRight 6.5s ease-in-out infinite;
  z-index: 10;
}

@keyframes floatRight {

  0%,
  100% {
    transform: rotateY(-15deg) translateZ(-40px) translateY(0);
  }

  50% {
    transform: rotateY(-15deg) translateZ(-40px) translateY(-10px);
  }
}

.status-indicator {
  width: 8px;
  height: 8px;
  background-color: var(--primary-green);
  border-radius: 50%;
  box-shadow: 0 0 15px var(--primary-green);
  margin-left: auto;
  animation: pulse 2s infinite;
  transform: translateZ(5px);
}

.status-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  transform-style: preserve-3d;
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transform: translateZ(20px);
  /* Pop out */
  background: rgba(0, 0, 0, 0.2);
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-item .label {
  font-size: 0.7rem;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.status-item .value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  color: var(--primary-green);
  text-align: right;
  text-shadow: 0 0 10px var(--primary-green-dim);
}

.bar-container {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.bar {
  height: 100%;
  background-color: var(--primary-green);
  box-shadow: 0 0 10px var(--primary-green);
  position: relative;
  overflow: hidden;
}

/* Animated shimmer on bars */
.bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: translateX(-100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.status-log {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: #888;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transform: translateZ(10px);
}

.log-title {
  color: var(--text-white);
  margin-bottom: 0.25rem;
  font-weight: 500;
  letter-spacing: 1px;
}

.log-entry .time {
  color: var(--primary-green);
  margin-right: 0.75rem;
  opacity: 0.8;
}

/* Sidebar Components (Reused) */
.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background-color: rgba(0, 255, 136, 0.08);
  /* Slight Green Tint */
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 0.75rem;
  color: var(--primary-green);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transform: translateZ(20px);
}

.new-chat-btn:hover {
  background-color: var(--primary-green);
  color: #000;
  box-shadow: 0 0 20px var(--primary-green);
  transform: translateZ(25px);
}

.history-label {
  font-size: 0.7rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
  transform: translateZ(10px);
}

.history-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-white);
  border-radius: 0.6rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  font-size: 0.9rem;
  overflow: hidden;
  white-space: nowrap;
  transform: translateZ(15px);
}

.history-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateZ(20px);
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1.25rem;
  margin-top: auto;
  transform: translateZ(10px);
  transform-style: preserve-3d;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s;
  transform: translateZ(10px);
}

.user-profile:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.avatar {
  width: 36px;
  height: 36px;
  background-color: var(--primary-green);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 0 10px var(--primary-green-dim);
}

.username {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.plan {
  font-size: 0.7rem;
  color: var(--primary-green);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Overlay */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 15;
}

.overlay.active {
  display: block;
}


/* --- Mobile Responsiveness --- */
@media (max-width: 1024px) {
  .scene {
    perspective: none;
    height: auto;
    overflow-y: auto;
    align-items: flex-start;
    display: block;
    background: #020202;
  }

  .scene::before {
    display: none;
    /* remove grid for performance on mobile */
  }

  .stage {
    width: 100%;
    height: 100%;
    flex-direction: column;
    transform: none !important;
    gap: 0;
  }

  .panel {
    transform: none !important;
    animation: none !important;
    /* Disable floating on mobile */
    border-radius: 0;
    border: none;
    backdrop-filter: none;
    box-shadow: none;
    background-color: transparent;
  }

  /* Reset all internal z-translations for mobile to prevent stacking issues */
  .panel-header,
  .sidebar-content-wrapper,
  .mobile-header,
  .chat-container,
  .welcome-screen,
  .logo-wrapper,
  .message,
  .input-container,
  #send-btn,
  .disclaimer,
  .status-indicator,
  .status-content,
  .status-item,
  .status-log,
  .new-chat-btn,
  .history-label,
  .history-item,
  .sidebar-footer,
  .user-profile {
    transform: none !important;
  }

  .left-panel,
  .right-panel {
    display: none;
  }

  /* Re-enable Sidebar logic for mobile */
  .left-panel.sidebar.active {
    display: flex;
    position: fixed;
    width: 280px;
    height: 100%;
    z-index: 100;
    border-right: 1px solid var(--border-color);
    background-color: #050505;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    top: 0;
    left: 0;
    animation: slideInLeft 0.3s ease-out forwards;
    transform: none !important;
    /* Ensure it's flat on top */
  }

  @keyframes slideInLeft {
    from {
      transform: translateX(-100%);
    }

    to {
      transform: translateX(0);
    }
  }

  .mobile-header {
    display: flex;
    position: sticky;
    top: 0;
  }

  .center-panel {
    height: 100vh;
    /* Full viewport height on mobile */
    z-index: 1;
    border: none;
    box-shadow: none;
  }
}