@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --bg-main: #E8E6F5; /* Soft lavender background matching image */
  --bg-panel: #FFFFFF;
  --bg-panel-hover: #F8F9FB;
  --bg-nav: #222228; /* Dark sidebar/dock */
  --bg-nav-active: rgba(255, 255, 255, 0.1);
  --bg-input: #F4F5F7;
  
  --primary: #7255EA; /* Vibrant soft purple */
  --primary-glow: rgba(114, 85, 234, 0.25);
  
  --accent-orange: #F36C4F; /* Notification/Warning */
  --accent-emerald: #10B981;
  
  --text-main: #2D2D35; /* Dark slate */
  --text-muted: #8F8F9A;
  --text-inverse: #FFFFFF;

  --border-subtle: #F0F0F5;
  
  --font-sans: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  
  --radius-sm: 16px;
  --radius-md: 24px;
  --radius-lg: 32px;
  --radius-full: 9999px;
  
  --shadow-panel: 0 10px 40px rgba(0, 0, 0, 0.05);
  --shadow-dock: 0 12px 32px rgba(0, 0, 0, 0.15);
  --dock-height: 76px;
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding: 16px 16px calc(var(--dock-height) + 32px) 16px;
  overflow-x: hidden;
  background-image: radial-gradient(circle at 50% 0%, rgba(255,255,255,0.4) 0%, transparent 60%);
}

/* Main Application Layout (Floating Panel) */
.app-viewport {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

.app-panel {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  min-height: calc(100vh - 32px - var(--dock-height));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header inside the White Panel */
.top-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  z-index: 10;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-logo {
  width: 42px;
  height: 42px;
  background: var(--bg-nav);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Status Pills */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
}

.status-pill.offline {
  background: rgba(243, 108, 79, 0.1);
  color: var(--accent-orange);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Hide theme toggle since we are using specific theme */
.theme-toggle-btn {
  display: none;
}

/* Content Area */
.main-content {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.3s ease-out forwards;
}

.tab-panel.active {
  display: block;
}

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

/* Soft Cards inside the Panel */
.glass-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  transition: all 0.2s ease;
}

.glass-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-title svg {
  color: var(--primary);
}

.badge-tag {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
  background: var(--bg-input);
  color: var(--text-muted);
}

.badge-tag.blue { background: rgba(114, 85, 234, 0.1); color: var(--primary); }
.badge-tag.gold { background: rgba(243, 108, 79, 0.1); color: var(--accent-orange); }
.badge-tag.green { background: rgba(16, 185, 129, 0.1); color: var(--accent-emerald); }
.badge-tag.purple { background: rgba(114, 85, 234, 0.1); color: var(--primary); }

/* Buttons & Inputs (Pill Shaped) */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-select, .form-input, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 14px 18px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
  outline: none;
  appearance: none;
}

.form-textarea {
  border-radius: var(--radius-md);
  resize: vertical;
  min-height: 80px;
}

.form-select:focus, .form-input:focus, .form-textarea:focus {
  background: var(--bg-panel);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-full);
  padding: 16px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary:hover {
  background: #6449d4;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--primary-glow);
}

.btn-secondary {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-main);
  border: none;
  border-radius: var(--radius-full);
  padding: 14px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-secondary:hover {
  background: #E5E6EB;
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

/* Chat Layout Style for AI Output */
.ai-output-box {
  background: var(--bg-panel);
  border: none;
  padding: 0;
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-output-box > div {
  background: var(--bg-input);
  padding: 16px 20px;
  border-radius: 20px;
  border-bottom-left-radius: 4px;
  color: var(--text-main);
  font-size: 0.95rem;
  line-height: 1.6;
}

.ai-output-box h4 {
  color: var(--primary);
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 1rem;
}

.ai-output-box ul, .ai-output-box ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

/* Hero Banner Hub */
.hero-banner {
  background: var(--bg-nav);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
  color: var(--text-inverse);
}

.hero-tag {
  background: rgba(255,255,255,0.15);
  color: #FFF;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.hero-title {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 8px;
}

.hero-desc {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 20px;
}

.quick-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-box {
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}

.stat-label {
  font-size: 0.7rem;
  color: #8F8F9A;
  text-transform: uppercase;
  margin-top: 4px;
}

/* Hub Grid Actions */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.mode-btn-card {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.mode-btn-card:hover {
  background: var(--bg-panel);
  border-color: var(--primary);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.mode-icon {
  width: 48px;
  height: 48px;
  background: var(--bg-panel);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.mode-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.mode-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Floating Bottom Dock Navigation */
.bottom-dock {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 568px;
  height: var(--dock-height);
  background: var(--bg-nav);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 12px;
  box-shadow: var(--shadow-dock);
  z-index: 100;
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  position: relative;
  flex: 1;
}

.dock-item svg {
  width: 24px;
  height: 24px;
  transition: transform 0.2s ease;
}

.dock-item span {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0;
  position: absolute;
  bottom: -4px;
  transition: all 0.2s;
}

.dock-item.active {
  color: var(--text-inverse);
  background: var(--bg-nav-active);
  transform: translateY(-4px);
  border-radius: var(--radius-lg);
}

.dock-item.active svg {
  transform: translateY(-8px);
}

.dock-item.active span {
  opacity: 1;
  bottom: 6px;
}

/* Telemetry Dashboard */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.telemetry-card {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.telemetry-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.telemetry-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
}

.telemetry-trend {
  font-size: 0.75rem;
  color: var(--accent-emerald);
  margin-top: 4px;
  font-weight: 600;
}

/* Quiz UI */
.quiz-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quiz-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 12px;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--primary);
  width: 20%;
  transition: width 0.3s ease;
}

.question-card {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  text-align: left;
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s ease;
}

.option-btn:hover {
  background: var(--bg-panel);
  border-color: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.option-btn.correct {
  background: rgba(16, 185, 129, 0.1) !important;
  border-color: var(--accent-emerald) !important;
  color: var(--accent-emerald) !important;
}
.option-btn.wrong {
  background: rgba(243, 108, 79, 0.1) !important;
  border-color: var(--accent-orange) !important;
  color: var(--accent-orange) !important;
}

.option-letter {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* Toasts */
.toast-msg {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--primary);
  color: #FFF;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px var(--primary-glow);
}
.toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================
   PENA V2: Chat UI specific styles
   ========================================= */

body.chat-mode {
  background: var(--bg-main);
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-viewport {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(114, 85, 234, 0.1);
  z-index: 10;
}

.chat-header .header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1.1rem;
}

.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chat-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-row.user-row {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.5;
  box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.user-bubble {
  background: var(--primary);
  color: #FFF;
  border-bottom-right-radius: 4px;
}

.ai-bubble {
  background: #FFFFFF;
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

/* Smart Native App Interactive Widget */
.widget-bubble {
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(114, 85, 234, 0.15);
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.widget-header {
  padding: 12px 16px;
  background: rgba(114, 85, 234, 0.08);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(114, 85, 234, 0.1);
}

.widget-body {
  padding: 16px;
  background: #FFF;
}

.chat-input-area {
  padding: 12px 16px;
  background: #FFFFFF;
  border-top: 1px solid rgba(114, 85, 234, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border-radius: 24px;
  padding: 8px;
}

.chat-input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 8px 4px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--text-main);
  resize: none;
  max-height: 120px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.action-btn {
  background: rgba(114, 85, 234, 0.1);
  color: var(--primary);
}

.send-btn {
  background: var(--primary);
  color: #FFF;
}

.quick-actions-drawer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.quick-actions-drawer::-webkit-scrollbar {
  display: none;
}

.qa-btn {
  white-space: nowrap;
  background: rgba(114, 85, 234, 0.1);
  color: var(--primary);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

