:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #141414;
  --bg-tertiary: #1a1a1a;
  --bg-card: #1c1c1e;
  
  --neon-cyan: #00f0ff;
  --neon-purple: #a855f7;
  --neon-pink: #ec4899;
  --neon-green: #22c55e;
  --neon-orange: #f97316;
  
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  --border-color: #27272a;
  --border-hover: #3f3f46;
  
  --glow-cyan: 0 0 20px rgba(0, 240, 255, 0.3);
  --glow-purple: 0 0 20px rgba(168, 85, 247, 0.3);
  --glow-pink: 0 0 20px rgba(236, 72, 153, 0.3);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #000;
  box-shadow: var(--glow-cyan);
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.help-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.help-link:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
}

.help-icon {
  width: 18px;
  height: 18px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

/* Status */
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

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

.status.connected {
  border-color: var(--neon-green);
  background: rgba(34, 197, 94, 0.1);
}

.status.connected .status-dot {
  background: var(--neon-green);
  box-shadow: 0 0 10px var(--neon-green);
  animation: pulse 2s infinite;
}

.status.connected .status-text {
  color: var(--neon-green);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Main Content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Auth Screen */
.auth-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(0, 240, 255, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(168, 85, 247, 0.05) 0%, transparent 50%);
}

.auth-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  overflow: hidden;
}

.auth-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, var(--neon-cyan), transparent 30%);
  animation: rotate 4s linear infinite;
  opacity: 0.1;
}

@keyframes rotate {
  100% { transform: rotate(360deg); }
}

.auth-card::before {
  content: '';
  position: absolute;
  inset: 1px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  z-index: 1;
}

.auth-card > * {
  position: relative;
  z-index: 2;
}

.auth-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary), var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.feature {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.feature:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.feature-icon {
  font-size: 1.25rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
  color: #000;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-cyan);
}

.btn-glow {
  position: relative;
}

.btn-glow::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink));
  border-radius: calc(var(--radius-md) + 2px);
  z-index: -1;
  opacity: 0.5;
  filter: blur(8px);
  transition: opacity 0.2s ease;
}

.btn-glow:hover::before {
  opacity: 0.8;
}

.btn-arrow {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.btn:hover .btn-arrow {
  transform: translateX(4px);
}

.btn-send {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--neon-cyan);
  color: #000;
  border-radius: 50%;
  flex-shrink: 0;
}

.btn-send:hover {
  box-shadow: var(--glow-cyan);
  transform: scale(1.05);
}

.btn-send svg {
  width: 20px;
  height: 20px;
}

/* Session End */
.session-end-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.end-card {
  text-align: center;
}

.end-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--neon-green), #16a34a);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 24px;
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.4);
}

.end-card h2 {
  margin-bottom: 24px;
  color: var(--text-primary);
}

/* App Section - Chat Layout */
.app-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.chat-layout {
  display: flex;
  flex-direction: row;
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--neon-cyan);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-new-chat svg {
  width: 16px;
  height: 16px;
}

.btn-new-chat:hover {
  background: rgba(0, 240, 255, 0.1);
  border-color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sessions-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.session-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.session-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
}

.session-item.active {
  background: rgba(0, 240, 255, 0.08);
  border-color: var(--neon-cyan);
}

.session-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.session-item.active .session-item-title {
  color: var(--neon-cyan);
}

.session-item-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.session-item-summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat Container */
.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-width: 0;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.welcome-message {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.05), rgba(168, 85, 247, 0.05));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.welcome-icon {
  font-size: 2rem;
}

/* Messages */
.message {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  line-height: 1.6;
  animation: messageIn 0.3s ease;
}

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

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
  color: #000;
  border-bottom-right-radius: 4px;
}

.message.gemini {
  align-self: flex-start;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

/* Input Section */
.input-section {
  padding: 16px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-textarea {
  width: 100%;
  padding: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: all 0.2s ease;
  min-height: 80px;
}

.chat-textarea::placeholder {
  color: var(--text-muted);
}

.chat-textarea:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

/* Input Actions Row */
.input-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.input-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.send-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.input-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Controls Bar */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-btn svg {
  width: 20px;
  height: 20px;
}

.control-btn:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

.control-btn.active {
  background: rgba(0, 240, 255, 0.1);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
}

.control-btn.danger:hover {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  box-shadow: var(--glow-pink);
}

.controls-divider {
  width: 1px;
  height: 32px;
  background: var(--border-color);
  margin: 0 4px;
}

/* Live Badge */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(239, 68, 68, 0.9);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  letter-spacing: 1px;
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.live-badge.hidden {
  display: none;
}

/* Video Modal */
.video-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-modal.hidden {
  display: none;
}

.video-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
}

.video-modal-content {
  position: relative;
  width: 90%;
  max-width: 800px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  z-index: 1001;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.video-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.video-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.video-modal-close:hover {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
}

.video-modal-close svg {
  width: 20px;
  height: 20px;
}

.video-modal-body {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
}

.video-modal-body video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

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

/* Loading animation */
.loading-dots {
  display: flex;
  gap: 4px;
  padding: 20px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--neon-cyan);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) {
  /* Header - Compact */
  .header {
    padding: 12px 16px;
  }

  .logo h1 {
    font-size: 1.25rem;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .help-link span:last-child {
    display: none;
  }

  .help-link {
    padding: 8px;
  }

  .status {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .status-text {
    display: none;
  }

  /* Auth Screen */
  .auth-screen {
    padding: 20px 16px;
  }

  .auth-card {
    padding: 32px 20px;
  }

  .auth-title {
    font-size: 1.5rem;
  }

  .features {
    grid-template-columns: 1fr;
  }

  .feature {
    padding: 12px;
  }

  /* App Section */
  .app-section {
    padding: 12px;
  }

  .chat-layout {
    max-width: 100%;
    flex-direction: column;
  }

  .sidebar {
    display: none;
  }

  /* Chat */
  .chat-log {
    padding: 12px;
    gap: 12px;
  }

  .welcome-message {
    padding: 16px;
    gap: 12px;
  }

  .welcome-icon {
    font-size: 1.5rem;
  }

  /* Messages */
  .message {
    max-width: 90%;
    padding: 12px 14px;
    font-size: 0.9375rem;
  }

  /* Input Section */
  .input-section {
    padding: 12px;
  }

  .chat-textarea {
    padding: 12px;
    min-height: 60px;
    font-size: 16px;
  }

  .input-actions-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .input-controls {
    justify-content: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .input-controls::-webkit-scrollbar {
    display: none;
  }

  .send-wrapper {
    justify-content: space-between;
    flex-direction: row-reverse;
  }

  .input-hint {
    font-size: 0.6875rem;
  }

  /* Controls */
  .control-btn {
    padding: 8px 12px;
    min-width: 60px;
    flex-shrink: 0;
  }

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

  .control-btn span {
    font-size: 0.625rem;
  }

  .controls-divider {
    height: 28px;
  }

  /* Video Modal */
  .video-modal-content {
    width: 95%;
    margin: 16px;
  }

  .video-modal-header {
    padding: 12px 16px;
  }

  .video-modal-body {
    aspect-ratio: 4/3;
  }

  /* Session End */
  .session-end-section {
    padding: 20px;
  }

  .end-icon {
    width: 56px;
    height: 56px;
    font-size: 1.75rem;
  }

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

  /* Scrollbar - Thinner */
  ::-webkit-scrollbar {
    width: 4px;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .control-btn {
    padding: 6px 10px;
    min-width: 52px;
  }

  .control-btn svg {
    width: 16px;
    height: 16px;
  }

  .auth-card {
    padding: 24px 16px;
  }

  .auth-title {
    font-size: 1.25rem;
  }

  .feature {
    font-size: 0.8125rem;
  }
}

/* Touch device optimizations */
@media (pointer: coarse) {
  .control-btn,
  .btn {
    min-height: 44px;
  }

  .chat-textarea {
    min-height: 44px;
  }

  .video-modal-close {
    min-width: 44px;
    min-height: 44px;
  }
}

/* iOS safe area support */
@supports (padding: max(0px)) {
  .header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .app-section {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
