/* ==========================================================
   GLOBAL SEISMIC 3D - FUTURISTIC SCI-FI HUD STYLING
   ========================================================== */

:root {
  --bg-deep: #050811;
  --bg-surface: rgba(11, 18, 38, 0.75);
  --bg-surface-hover: rgba(20, 32, 66, 0.85);
  --bg-card: rgba(16, 26, 56, 0.65);
  --border-glass: rgba(80, 140, 255, 0.2);
  --border-glass-bright: rgba(0, 240, 255, 0.45);
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --neon-cyan: #00f0ff;
  --neon-blue: #3b82f6;
  --neon-indigo: #6366f1;
  
  --mag-minor: #10b981;    /* < 3.0 */
  --mag-light: #facc15;    /* 3.0 ~ 4.4 */
  --mag-moderate: #f97316; /* 4.5 ~ 5.9 */
  --mag-severe: #ef4444;   /* 6.0+ */
  
  --shadow-glow: 0 0 25px rgba(0, 240, 255, 0.25);
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.5);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-body);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* 3D Globe WebGL Container */
#globe-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

/* Subtle Sci-Fi Grid Overlay */
.hud-overlay-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  background-image: 
    radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(5, 8, 17, 0.6) 100%),
    linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 60px 60px, 60px 60px;
}

/* ==========================================================
   HEADER HUD
   ========================================================== */

.hud-header {
  position: absolute;
  top: 16px;
  left: 20px;
  right: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

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

.brand-logo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid var(--border-glass-bright);
  color: var(--neon-cyan);
}

.pulsing-beacon {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid var(--neon-cyan);
  opacity: 0.8;
  animation: beacon-pulse 2s infinite ease-out;
}

@keyframes beacon-pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  background: linear-gradient(135deg, #ffffff, var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Metric Stats Cards in Header */
.hud-metrics {
  display: flex;
  align-items: center;
  gap: 12px;
}

.metric-card {
  display: flex;
  flex-direction: column;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  min-width: 90px;
}

.metric-card.highlight {
  border-color: rgba(249, 115, 22, 0.4);
  background: rgba(249, 115, 22, 0.1);
}

.metric-card.highlight .metric-value {
  color: var(--mag-moderate);
}

.metric-card.warning {
  border-color: rgba(239, 68, 68, 0.4);
}

.metric-card.warning .metric-value {
  color: var(--mag-severe);
}

.metric-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 20px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mag-minor);
  box-shadow: 0 0 10px var(--mag-minor);
  animation: live-blink 1.5s infinite ease-in-out;
}

@keyframes live-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.live-text {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--mag-minor);
  letter-spacing: 0.8px;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.hud-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.25);
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(0);
}

.hud-btn-icon {
  padding: 8px 10px;
}

/* ==========================================================
   LEFT FLOATING CONTROL PANEL
   ========================================================== */

.hud-controls-panel {
  position: absolute;
  top: 90px;
  left: 20px;
  width: 290px;
  z-index: 10;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

/* Custom Sleek Scrollbar */
.hud-controls-panel::-webkit-scrollbar,
.sidebar-scroll::-webkit-scrollbar {
  width: 5px;
}

.hud-controls-panel::-webkit-scrollbar-thumb,
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(80, 140, 255, 0.3);
  border-radius: 10px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--neon-cyan);
  letter-spacing: 0.8px;
}

/* Button Grids */
.btn-group-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.filter-chip {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.filter-chip:hover {
  background: rgba(0, 240, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(0, 240, 255, 0.3);
}

.filter-chip.active {
  background: rgba(0, 240, 255, 0.18);
  color: #fff;
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
  font-weight: 600;
}

.preset-btn {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.preset-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--neon-blue);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

/* Switch Rows */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: .3s;
}

input:checked + .slider {
  background-color: var(--neon-cyan);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* Legend Styling */
.legend-scale {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.level-minor { background-color: var(--mag-minor); box-shadow: 0 0 6px var(--mag-minor); }
.level-light { background-color: var(--mag-light); box-shadow: 0 0 6px var(--mag-light); }
.level-moderate { background-color: var(--mag-moderate); box-shadow: 0 0 6px var(--mag-moderate); }
.level-severe { background-color: var(--mag-severe); box-shadow: 0 0 8px var(--mag-severe); }

/* ==========================================================
   RIGHT REAL-TIME SIDEBAR
   ========================================================== */

.hud-sidebar {
  position: absolute;
  top: 90px;
  right: 20px;
  width: 360px;
  height: calc(100vh - 120px);
  z-index: 10;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.hud-sidebar.collapsed {
  transform: translateX(390px);
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title-row h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.feed-count-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  background: rgba(0, 240, 255, 0.15);
  color: var(--neon-cyan);
  border-radius: 12px;
  border: 1px solid var(--border-glass-bright);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 12px;
  color: var(--text-dim);
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.sort-selector {
  display: flex;
  gap: 6px;
}

.sort-btn {
  flex: 1;
  padding: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.sort-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.sort-btn.active {
  background: rgba(59, 130, 246, 0.25);
  color: #fff;
  border-color: var(--neon-blue);
}

/* Sidebar Event Cards */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quake-card {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.quake-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--item-color, var(--neon-cyan));
}

.quake-card:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(0, 240, 255, 0.35);
  transform: translateX(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.quake-card.selected {
  border-color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.1);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.25);
}

.quake-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mag-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.88rem;
  padding: 2px 8px;
  border-radius: 4px;
  color: #fff;
}

.quake-time-rel {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.quake-place {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}

.quake-details-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.tsunami-alert-tag {
  color: var(--mag-severe);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Loading & Empty States */
.loading-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
  font-size: 0.85rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 240, 255, 0.15);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================
   DETAIL MODAL / POPUP
   ========================================================== */

.detail-modal {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  width: 90%;
  max-width: 500px;
  z-index: 20;
  background: var(--bg-surface);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--border-glass-bright);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), var(--shadow-glow);
  padding: 20px;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.detail-modal.active {
  transform: translateX(-50%) translateY(0);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #fff;
}

.modal-title-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-mag-badge {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: #fff;
}

.modal-place-name {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

.modal-grid-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.modal-stat-box {
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
}

.modal-stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.modal-stat-val {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-top: 3px;
}

.modal-action-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-action-row a,
.modal-action-row button {
  flex: 1;
  text-align: center;
  text-decoration: none;
}

/* Toast Notifications */
.toast-notification {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 50;
  padding: 10px 20px;
  background: rgba(16, 26, 56, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glass-bright);
  border-radius: 30px;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.toast-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Custom Tooltip Styling for Globe.gl */
.scene-tooltip {
  background: rgba(10, 16, 35, 0.85) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(0, 240, 255, 0.4) !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  color: #fff !important;
  font-family: var(--font-body) !important;
  font-size: 0.8rem !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6) !important;
  pointer-events: none !important;
}

/* ==========================================================
   AI SEISMIC ANALYST CHATBOT STYLING
   ========================================================== */

.hud-btn-ai {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.35)) !important;
  border: 1px solid rgba(168, 85, 247, 0.6) !important;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.3);
  color: #fff !important;
  font-weight: 600 !important;
}

.hud-btn-ai:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.4), rgba(168, 85, 247, 0.55)) !important;
  border-color: #d8b4fe !important;
  box-shadow: 0 0 22px rgba(192, 132, 252, 0.5) !important;
  transform: translateY(-1px);
}

.ai-sparkle {
  animation: sparkle-rotate 3s infinite linear;
  display: inline-block;
}

@keyframes sparkle-rotate {
  0% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.25) rotate(180deg); }
  100% { transform: scale(1) rotate(360deg); }
}

/* Chatbot Floating HUD Panel */
.ai-chat-panel {
  position: absolute;
  top: 90px;
  right: 20px;
  width: 420px;
  height: calc(100vh - 120px);
  z-index: 25;
  background: rgba(11, 18, 38, 0.92);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 25px rgba(168, 85, 247, 0.2);
  display: flex;
  flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  overflow: hidden;
}

.ai-chat-panel.collapsed {
  transform: translateX(450px);
  opacity: 0;
  pointer-events: none;
}

/* Chat Header */
.ai-chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 28, 58, 0.6);
}

.ai-chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-bot-avatar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(168, 85, 247, 0.3));
  border: 1px solid rgba(168, 85, 247, 0.5);
  color: #c084fc;
}

.ai-avatar-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid rgba(192, 132, 252, 0.6);
  animation: beacon-pulse 2.2s infinite ease-out;
}

.ai-chat-title h4 {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  background: linear-gradient(135deg, #ffffff, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.ai-sub-status {
  display: block;
  font-size: 0.68rem;
  color: #a78bfa;
  letter-spacing: 0.3px;
}

.ai-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.1rem;
}

.icon-btn:hover {
  background: rgba(168, 85, 247, 0.2);
  color: #fff;
  border-color: rgba(168, 85, 247, 0.5);
}

/* API Key Settings Drawer */
.ai-key-settings {
  padding: 14px 18px;
  background: rgba(14, 21, 46, 0.95);
  border-bottom: 1px solid rgba(168, 85, 247, 0.25);
  display: none;
  flex-direction: column;
  gap: 10px;
  animation: slide-down 0.25s ease-out;
}

.ai-key-settings.active {
  display: flex;
}

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

.key-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.key-settings-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #e2e8f0;
}

.link-openrouter {
  font-size: 0.72rem;
  color: var(--neon-cyan);
  text-decoration: none;
  transition: opacity 0.2s;
}

.link-openrouter:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.key-help-text {
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.35;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-password-row {
  display: flex;
  gap: 6px;
}

.input-password-row input,
.form-group select,
.custom-model-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.78rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-password-row input:focus,
.form-group select:focus,
.custom-model-input:focus {
  border-color: #a855f7;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

.form-group select option {
  background: #0d1429;
  color: #fff;
}

.icon-btn-sm {
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
}

.key-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.hud-btn-accent {
  background: linear-gradient(135deg, #7c3aed, #9333ea) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 600 !important;
  padding: 7px 14px !important;
}

.hud-btn-accent:hover {
  box-shadow: 0 0 14px rgba(147, 51, 234, 0.5) !important;
}

.hud-btn-ghost {
  background: transparent !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: var(--text-muted) !important;
  padding: 7px 12px !important;
}

.hud-btn-ghost:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

/* Context Banner */
.ai-context-banner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  overflow-x: auto;
}

.context-pill {
  font-size: 0.68rem;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.context-pill.highlight {
  background: rgba(0, 240, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.3);
  color: var(--neon-cyan);
}

/* Messages Area */
.ai-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-messages-container::-webkit-scrollbar {
  width: 5px;
}

.ai-messages-container::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.3);
  border-radius: 10px;
}

.chat-bubble {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  font-size: 0.82rem;
  line-height: 1.5;
  word-break: break-word;
  animation: bubble-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(99, 102, 241, 0.45));
  border: 1px solid rgba(99, 102, 241, 0.45);
  color: #fff;
  padding: 10px 14px;
  border-radius: 14px 14px 2px 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: rgba(18, 27, 56, 0.85);
  border: 1px solid rgba(168, 85, 247, 0.25);
  color: #f1f5f9;
  padding: 12px 16px;
  border-radius: 14px 14px 14px 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.chat-bubble.assistant.welcome {
  border-color: rgba(0, 240, 255, 0.3);
  background: rgba(13, 22, 48, 0.9);
}

.bubble-author {
  font-size: 0.68rem;
  font-weight: 700;
  color: #c084fc;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-bubble p {
  margin-bottom: 6px;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble ul, .chat-bubble ol {
  margin: 6px 0 6px 18px;
}

.chat-bubble li {
  margin-bottom: 4px;
}

.chat-bubble strong {
  color: #38bdf8;
}

.chat-bubble code {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
  color: #f472b6;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c084fc;
  animation: typing-bounce 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 typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Prompt Suggestions */
.ai-suggestions-row {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  overflow-x: auto;
  white-space: nowrap;
}

.ai-suggestions-row::-webkit-scrollbar {
  height: 3px;
}

.ai-chip {
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-chip:hover {
  background: rgba(168, 85, 247, 0.2);
  color: #fff;
  border-color: rgba(168, 85, 247, 0.4);
  transform: translateY(-1px);
}

/* Chat Input Form */
.ai-chat-input-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(14, 21, 46, 0.7);
}

.ai-chat-input-form textarea {
  flex: 1;
  min-height: 36px;
  max-height: 100px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.8rem;
  resize: none;
  outline: none;
  line-height: 1.4;
  transition: border-color 0.2s;
}

.ai-chat-input-form textarea:focus {
  border-color: #a855f7;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
}

.ai-chat-input-form textarea::placeholder {
  color: var(--text-dim);
}

.ai-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #7c3aed, #9333ea);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-send-btn:hover {
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.6);
  transform: scale(1.05);
}

.ai-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ==========================================================
   RESPONSIVE DESIGN (TABLETS & MOBILE)
   ========================================================== */

@media (max-width: 1024px) {
  .hud-metrics {
    display: none;
  }
  
  .hud-controls-panel {
    width: 250px;
  }

  .hud-sidebar {
    width: 320px;
  }

  .ai-chat-panel {
    width: 360px;
  }
}

@media (max-width: 768px) {
  .hud-header {
    top: 8px;
    left: 8px;
    right: 8px;
    padding: 10px 14px;
  }

  .brand-sub {
    display: none;
  }

  .hud-controls-panel {
    top: auto;
    bottom: 12px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 40vh;
    border-radius: var(--radius-md);
  }

  .hud-sidebar {
    top: 70px;
    right: 8px;
    left: 8px;
    width: auto;
    height: 55vh;
  }

  .hud-sidebar.collapsed {
    transform: translateY(120%);
  }

  .ai-chat-panel {
    top: 65px;
    right: 8px;
    left: 8px;
    width: auto;
    height: 70vh;
  }

  .ai-chat-panel.collapsed {
    transform: translateY(120%);
  }

  .detail-modal {
    width: 95%;
    bottom: 12px;
  }
}
