/**
 * RLM (Root Language Models) AI SaaS Platform
 * Design System: Skeuomorphic Glassmorphism ("Glass-Morphic Cyber-Tactile")
 * Deep Obsidian (#0B0F17) + Cyan (#00F0FF) + Crimson (#FF3344)
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&family=Syne:wght@600;700;800&display=swap');

:root {
  --bg-obsidian-deep: #070A0F;
  --bg-obsidian-surface: #0B0F17;
  --bg-obsidian-panel: #111722;
  --bg-obsidian-elevated: #161F2E;
  --bg-obsidian-input: #080C14;

  --border-glass-subtle: rgba(255, 255, 255, 0.08);
  --border-glass-highlight: rgba(255, 255, 255, 0.16);
  --border-glass-bevel: rgba(255, 255, 255, 0.22);

  /* Engine Accent: RLM Dex (Coding) */
  --dex-cyan: #00F0FF;
  --dex-cyan-glow: rgba(0, 240, 255, 0.45);
  --dex-cyan-surface: rgba(0, 240, 255, 0.08);

  /* Engine Accent: RLM Max (Offensive Security) */
  --max-crimson: #FF3344;
  --max-crimson-glow: rgba(255, 51, 68, 0.45);
  --max-crimson-surface: rgba(255, 51, 68, 0.08);

  /* Active Engine Dynamic CSS Variables */
  --active-accent: var(--dex-cyan);
  --active-glow: var(--dex-cyan-glow);
  --active-surface: var(--dex-cyan-surface);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Syne', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

body[data-engine="rlm-max"] {
  --active-accent: var(--max-crimson);
  --active-glow: var(--max-crimson-glow);
  --active-surface: var(--max-crimson-surface);
}

/* Base Body styling */
body {
  font-family: var(--font-sans);
  background-color: var(--bg-obsidian-deep);
  color: #E2E8F0;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(0, 240, 255, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(255, 51, 68, 0.04) 0%, transparent 45%),
    linear-gradient(180deg, #070A0F 0%, #0B0F17 100%);
  background-attachment: fixed;
}

body.overflow-hidden {
  overflow: hidden !important;
  height: 100vh !important;
  max-height: 100vh !important;
}

html.overflow-hidden {
  overflow: hidden !important;
  height: 100% !important;
}

/* Monospace text */
.font-mono {
  font-family: var(--font-mono);
}

.font-display {
  font-family: var(--font-display);
}

/* ==============================================================================
   Glassmorphic Panels & Surface Layers
   ============================================================================== */
.glass-panel {
  background: rgba(17, 23, 34, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-glass-subtle);
  border-top: 1px solid var(--border-glass-bevel);
  box-shadow: 
    0 8px 32px 0 rgba(0, 0, 0, 0.45),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.12);
}

.glass-panel-elevated {
  background: rgba(22, 31, 46, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 
    0 12px 40px -4px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.15);
}

.glass-dropdown {
  background: rgba(14, 20, 30, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}

/* ==============================================================================
   Tactile Skeuomorphic Controls & Buttons
   ============================================================================== */
.tactile-btn {
  position: relative;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.825rem;
  border-radius: 0.5rem;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Standard Tactile Button (Slate / Metallic) */
.tactile-btn-default {
  background: linear-gradient(180deg, #1C2637 0%, #111926 100%);
  color: #CBD5E1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 
    0 4px 6px -1px rgba(0, 0, 0, 0.4),
    0 2px 4px -2px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}

.tactile-btn-default:hover {
  background: linear-gradient(180deg, #223046 0%, #152030 100%);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.2);
}

.tactile-btn-default:active {
  transform: translateY(1px);
  box-shadow: 
    0 1px 2px rgba(0, 0, 0, 0.6),
    inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Primary Dex Accent Button (Cyan Glowing) */
.tactile-btn-cyan {
  background: linear-gradient(180deg, #00F0FF 0%, #0099AA 100%);
  color: #041017;
  border: 1px solid #33F4FF;
  border-top: 1px solid #70FAFF;
  box-shadow: 
    0 4px 14px 0 rgba(0, 240, 255, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

.tactile-btn-cyan:hover {
  background: linear-gradient(180deg, #33F4FF 0%, #00B3C7 100%);
  box-shadow: 
    0 6px 20px 0 rgba(0, 240, 255, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.tactile-btn-cyan:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(0, 240, 255, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Primary Max Accent Button (Crimson Glowing) */
.tactile-btn-crimson {
  background: linear-gradient(180deg, #FF3344 0%, #B81B28 100%);
  color: #FFFFFF;
  border: 1px solid #FF5C6A;
  border-top: 1px solid #FFA0A9;
  box-shadow: 
    0 4px 14px 0 rgba(255, 51, 68, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4);
}

.tactile-btn-crimson:hover {
  background: linear-gradient(180deg, #FF4D5D 0%, #CF2231 100%);
  box-shadow: 
    0 6px 20px 0 rgba(255, 51, 68, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.tactile-btn-crimson:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(255, 51, 68, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Inset Tactile Inputs */
.tactile-input {
  background: #080C14;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.5rem;
  color: #F1F5F9;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.7),
    inset 0 1px 1px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

.tactile-input:focus {
  outline: none;
  border-color: var(--active-accent);
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.7),
    0 0 0 1px var(--active-accent),
    0 0 12px var(--active-glow);
}

/* ==============================================================================
   Tactile Dual Metallic Engine Switch (Dex <-> Max)
   ============================================================================== */
.engine-switcher-container {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(180deg, #070B12 0%, #111722 100%);
  padding: 4px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 
    inset 0 2px 6px rgba(0, 0, 0, 0.8),
    0 2px 4px rgba(0, 0, 0, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
  cursor: pointer;
  user-select: none;
}

.engine-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #64748B;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 2;
}

.engine-option.active-dex {
  color: #00F0FF;
  background: linear-gradient(180deg, #162B3D 0%, #0C1B28 100%);
  border: 1px solid rgba(0, 240, 255, 0.4);
  box-shadow: 
    0 2px 8px rgba(0, 240, 255, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.engine-option.active-max {
  color: #FF3344;
  background: linear-gradient(180deg, #38161B 0%, #240C0F 100%);
  border: 1px solid rgba(255, 51, 68, 0.4);
  box-shadow: 
    0 2px 8px rgba(255, 51, 68, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ==============================================================================
   Tactical Status LEDs & Halo Pulsers
   ============================================================================== */
.tactical-led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
}

.tactical-led-dex {
  background-color: var(--dex-cyan);
  box-shadow: 
    0 0 6px var(--dex-cyan),
    0 0 12px var(--dex-cyan-glow);
}

.tactical-led-dex.pulse {
  animation: led-pulse-dex 2s infinite ease-in-out;
}

@keyframes led-pulse-dex {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 6px var(--dex-cyan), 0 0 12px var(--dex-cyan-glow);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 10px var(--dex-cyan), 0 0 20px var(--dex-cyan);
  }
}

.tactical-led-max {
  background-color: var(--max-crimson);
  box-shadow: 
    0 0 6px var(--max-crimson),
    0 0 12px var(--max-crimson-glow);
}

.tactical-led-max.pulse {
  animation: led-pulse-max 2s infinite ease-in-out;
}

@keyframes led-pulse-max {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 6px var(--max-crimson), 0 0 12px var(--max-crimson-glow);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 10px var(--max-crimson), 0 0 20px var(--max-crimson);
  }
}

.tactical-led-green {
  background-color: #10B981;
  box-shadow: 0 0 6px #10B981, 0 0 12px rgba(16, 185, 129, 0.5);
}

/* ==============================================================================
   Tactile Quota Meter / Gauge
   ============================================================================== */
.quota-track {
  background: #06090F;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  height: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

.quota-bar {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease-out;
  background: linear-gradient(90deg, #00F0FF 0%, #3B82F6 100%);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.quota-bar.warning {
  background: linear-gradient(90deg, #F59E0B 0%, #EF4444 100%);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* ==============================================================================
   Chat Messages & Markdown Styling
   ============================================================================== */
.chat-bubble-user {
  background: linear-gradient(135deg, rgba(22, 33, 50, 0.85) 0%, rgba(14, 22, 34, 0.85) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.chat-bubble-assistant {
  background: rgba(14, 20, 30, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

/* Markdown Code Containers */
.code-block-wrapper {
  margin: 0.875rem 0;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #06090E;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 
    0 6px 20px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #141C28 0%, #0E1520 100%);
  padding: 0.4rem 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 0.725rem;
  color: #94A3B8;
}

.copy-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 8px;
  background: #1A2433;
  color: #CBD5E1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.copy-btn:hover {
  background: #25344A;
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.3);
}

.copy-btn.copied {
  background: #064E3B;
  color: #34D399;
  border-color: #059669;
}

pre.code-content {
  padding: 1rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  line-height: 1.6;
  color: #E2E8F0;
  overflow-x: auto;
}

code.inline-code {
  font-family: var(--font-mono);
  font-size: 0.825em;
  padding: 0.15rem 0.35rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: #38BDF8;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #06090E;
}

::-webkit-scrollbar-thumb {
  background: #1E293B;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Glass table */
.glass-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.glass-table th {
  background: rgba(14, 20, 30, 0.85);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94A3B8;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
}

.glass-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.875rem;
}

.glass-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Unrestricted VIP badge */
.badge-unrestricted {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.2) 0%, rgba(202, 138, 4, 0.1) 100%);
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #FACC15;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ==============================================================================
   Cyber-Tactile Scrollbars (Only Chat & Session Lists Scroll)
   ============================================================================== */
#chat-messages-container,
#sessions-list-container {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

#chat-messages-container::-webkit-scrollbar,
#sessions-list-container::-webkit-scrollbar {
  width: 6px;
}

#chat-messages-container::-webkit-scrollbar-track,
#sessions-list-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 9999px;
}

#chat-messages-container::-webkit-scrollbar-thumb,
#sessions-list-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#chat-messages-container::-webkit-scrollbar-thumb:hover,
#sessions-list-container::-webkit-scrollbar-thumb:hover {
  background: var(--active-accent);
  box-shadow: 0 0 8px var(--active-glow);
}

/* Active session item highlight in sidebar */
.session-item.active-session {
  background: rgba(0, 240, 255, 0.12) !important;
  border-color: rgba(0, 240, 255, 0.45) !important;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.15) !important;
}

body[data-engine="rlm-max"] .session-item.active-session {
  background: rgba(255, 51, 68, 0.12) !important;
  border-color: rgba(255, 51, 68, 0.45) !important;
  box-shadow: 0 0 15px rgba(255, 51, 68, 0.15) !important;
}

/* Prompt Input Textarea: Fixed & Scrollbar Suppressed */
#chat-prompt-input {
  overflow-y: hidden;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  min-height: 46px;
  line-height: 1.5;
}

#chat-prompt-input::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge, Opera */
  width: 0;
  height: 0;
}

/* Real-Time Streaming Indicator & Cursor */
.streaming-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 3px;
  background-color: var(--active-accent, #00F0FF);
  box-shadow: 0 0 8px var(--active-glow, rgba(0, 240, 255, 0.8));
  vertical-align: middle;
  animation: cursor-blink 0.8s infinite;
}

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