/* Jarvis Web Chat — Modern Cyber Glassmorphism Theme */
/* v1.1.0 */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Inter:wght@300;400;500;600&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg-dark: #070a13;
  --bg-gradient: radial-gradient(circle at 50% 0%, #0f172a 0%, #070a13 70%);
  --surface-glass: rgba(15, 23, 42, 0.75);
  --surface-card: rgba(30, 41, 59, 0.7);
  --surface-hover: rgba(51, 65, 85, 0.6);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(14, 165, 233, 0.3);
  
  --accent-cyan: #0ea5e9;
  --accent-cyan-glow: rgba(14, 165, 233, 0.4);
  --accent-emerald: #10b981;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --shadow-glow: 0 0 25px rgba(14, 165, 233, 0.15);
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px;
  gap: 12px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  box-shadow: var(--shadow-card);
  z-index: 10;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-glow);
}

.brand-info h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

/* Persona Selector */
.persona-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
}
.persona-bar::-webkit-scrollbar {
  display: none;
}

.persona-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-card);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.persona-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border-glow);
}

.persona-btn.active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgba(139, 92, 246, 0.25));
  border-color: var(--accent-cyan);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.3);
}

.persona-btn .avatar {
  font-size: 14px;
}

/* Chat Scroll Area */
.chat-window {
  flex: 1;
  overflow-y: auto;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-card);
  scroll-behavior: smooth;
}

.chat-window::-webkit-scrollbar {
  width: 6px;
}
.chat-window::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}
.chat-window::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Welcome Screen */
.welcome-card {
  margin: auto;
  text-align: center;
  max-width: 540px;
  padding: 30px 20px;
  animation: fadeIn 0.4s ease-out;
}

.welcome-logo {
  font-size: 48px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 20px var(--accent-cyan-glow));
}

.welcome-card h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.welcome-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.chip-btn {
  background: var(--surface-card);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip-btn:hover {
  background: var(--surface-hover);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

/* Messages */
.message-row {
  display: flex;
  gap: 12px;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.message-row.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--surface-card);
  border: 1px solid var(--border-glass);
}

.message-row.user .msg-avatar {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
}

.msg-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.message-row.user .msg-bubble {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.25);
}

.message-row.assistant .msg-bubble {
  background: var(--surface-card);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.persona-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

/* Markdown formatting inside assistant messages */
.msg-bubble p {
  margin-bottom: 8px;
}
.msg-bubble p:last-child {
  margin-bottom: 0;
}
.msg-bubble ul, .msg-bubble ol {
  margin: 6px 0 6px 18px;
}
.msg-bubble li {
  margin-bottom: 4px;
}
.msg-bubble code {
  font-family: 'Fira Code', monospace;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.msg-bubble pre {
  background: #030712;
  border: 1px solid var(--border-glass);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
}
.msg-bubble pre code {
  background: none;
  border: none;
  padding: 0;
}

.msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.8rem;
}
.msg-bubble th, .msg-bubble td {
  border: 1px solid var(--border-glass);
  padding: 6px 10px;
  text-align: left;
}
.msg-bubble th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

/* Loading Dots */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 4px 0;
}
.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Bottom Input Bar */
.input-area {
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-card);
}

.input-area:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 8px 6px;
}
.chat-input::placeholder {
  color: var(--text-muted);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  background: var(--surface-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.icon-btn.send-btn {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #ffffff;
  border: none;
}
.icon-btn.send-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.icon-btn.mic-btn.listening {
  background: var(--accent-rose);
  color: #ffffff;
  animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(244, 63, 94, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

@media (max-width: 640px) {
  .app-container {
    padding: 8px;
    gap: 8px;
  }
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .brand-section {
    justify-content: space-between;
  }
  .msg-bubble {
    max-width: 90%;
  }
}

/* Header Right & Auth Actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions {
  display: flex;
  align-items: center;
}

.auth-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-card);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
}

.auth-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.auth-btn-icon {
  font-size: 13px;
}

.auth-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s, box-shadow 0.3s;
}

.auth-status-dot.healthy {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.auth-status-dot.warning {
  background: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
  animation: pulse 1.5s infinite;
}

/* Auth Modal Overlay & Card */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 19, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-modal-card {
  background: var(--surface-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(14, 165, 233, 0.15);
  max-width: 520px;
  width: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.auth-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 14px;
}

.auth-modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-icon {
  font-size: 1.6rem;
}

.auth-modal-title h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.auth-modal-title p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.auth-service-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-service-card {
  background: var(--surface-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s, background 0.2s;
}

.auth-service-card:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.service-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.service-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.google-avatar {
  background: linear-gradient(135deg, #4285f4, #ea4335, #fbbc05, #34a853);
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.spotify-avatar {
  background: #121212;
  border: 1px solid #1db954;
}

.service-details {
  flex: 1;
  min-width: 0;
}

.service-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.service-title-row h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.service-pill {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.service-pill.connected {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.service-pill.disconnected {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.service-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.service-renew-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid var(--accent-cyan);
  color: #ffffff;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.service-renew-btn:hover {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  box-shadow: 0 0 15px var(--accent-cyan-glow);
  transform: translateY(-1px);
}

.auth-modal-footer {
  border-top: 1px solid var(--border-glass);
  padding-top: 12px;
}

.auth-modal-note {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
}
