/*
 * Norse Industries / CSV Ecosystem - Core UI Components & Structures
 * Version: 1.0.0
 * Pure CSS Layouts & Components powered by Theme Variables
 */

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

:root {
  /* --- Default Theme Variables (LevelUp Training Tutor) --- */
  --bg-color: #0b0f19;           /* Deep Slate Blue */
  --bg-color-secondary: #131a2a; /* Card & Panel Background */
  --bg-color-tertiary: #1b253b;  /* Input & Active Highlight Background */
  
  --text-primary: #f0f4f8;       /* Crisp Off-White */
  --text-secondary: #94a3b8;     /* Muted Slate Gray */
  --text-tertiary: #64748b;      /* Dark Slate Gray */
  
  --accent-cyan: #00f2fe;        /* Vibrating Cyan Accent */
  --accent-cyan-glow: rgba(0, 242, 254, 0.2);
  --accent-cyan-bright: #38bdf8;
  
  --accent-magenta: #fe00a1;     /* Vibrating Magenta Accent */
  --accent-magenta-glow: rgba(254, 0, 161, 0.2);
  --accent-magenta-bright: #ff49db;

  --accent-blue: #0088fe;        /* Deep Electric Blue */
  --accent-blue-glow: rgba(0, 136, 254, 0.2);
  
  --accent-success: #10b981;     /* Success Green */
  --accent-success-glow: rgba(16, 185, 129, 0.2);
  
  --accent-gold: #f59e0b;        /* Alert Gold */
  --accent-gold-glow: rgba(245, 158, 11, 0.2);
  
  --accent-danger: #ef4444;      /* Danger Red */
  --accent-danger-glow: rgba(239, 68, 68, 0.2);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.15);
  --border-cyan-glow: rgba(0, 242, 254, 0.3);
  --border-magenta-glow: rgba(254, 0, 161, 0.3);
  
  /* --- Typography --- */
  --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
  --font-headers: 'Inter', system-ui, -apple-system, sans-serif;
  --letter-spacing-headers: -0.02em;
  
  /* --- Runic / Brand Accents --- */
  --brand-rune-indicator: '';
  --brand-button-primary-rune: '';
  --brand-button-secondary-rune: '';

  /* --- Border Radii --- */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  
  /* --- Transitions --- */
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.3s ease-in-out;

  /* --- Brand Identity Assets --- */
  --brand-logo: url("./nix_logo.svg");
  --brand-logo-width: 80px;
  --brand-logo-height: 80px;
}

/* Base Resets & Typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary), system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

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

::-webkit-scrollbar-track {
  background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-color-tertiary);
  border-radius: 9999px;
}

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

/* Premium Styled Typography Headers */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-headers), sans-serif;
  font-weight: 700;
  letter-spacing: var(--letter-spacing-headers, -0.02em);
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

h1 {
  font-size: 2.25rem;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-cyan-bright) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
  display: inline-block;
}

/* Runic Brand Element Support */
h1::after {
  content: var(--brand-rune-indicator, '');
  position: absolute;
  right: -1.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  color: var(--accent-magenta);
  -webkit-text-fill-color: initial;
  opacity: 0.6;
}

h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: all var(--transition-fast);
}

a:hover {
  color: var(--accent-cyan-bright);
  text-shadow: 0 0 10px var(--accent-cyan-glow);
}

/* Structural App Frame */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* Sidebar & Navigation Rail */
.sidebar, .nav-rail {
  width: 280px;
  background: var(--bg-color-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  padding: 1.5rem;
  overflow-y: auto;
  flex-shrink: 0;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

.content-pane {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

/* Glassmorphic Cards & Panels */
.glass-panel, .glass-card {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  transition: border-color var(--transition-normal), 
              box-shadow var(--transition-normal), 
              transform var(--transition-normal);
}

.glass-panel:hover, .glass-card:hover {
  border-color: var(--border-highlight);
  box-shadow: 0 12px 35px -8px rgba(0, 0, 0, 0.6);
}

.glass-card-cyan {
  border-left: 3px solid var(--accent-cyan);
}

.glass-card-magenta {
  border-left: 3px solid var(--accent-magenta);
}

/* Action Controls (Buttons) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  font-family: var(--font-primary), sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  gap: 0.5rem;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

/* Primary Cyan Action style */
.btn-primary, .btn-cyan {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
  color: #060b13;
  box-shadow: 0 4px 14px var(--accent-cyan-glow);
  position: relative;
  overflow: hidden;
}

.btn-primary::before, .btn-cyan::before {
  content: var(--brand-button-primary-rune, '');
  position: absolute;
  right: -5px;
  bottom: -15px;
  font-size: 3rem;
  opacity: 0.1;
  pointer-events: none;
}

.btn-primary:hover, .btn-cyan:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 6px 18px var(--border-cyan-glow);
}

/* Secondary Gold/Magenta Action style */
.btn-secondary, .btn-magenta {
  background: linear-gradient(135deg, var(--accent-magenta) 0%, #b45309 100%);
  color: #060b13;
  box-shadow: 0 4px 14px var(--accent-magenta-glow);
  position: relative;
  overflow: hidden;
}

.btn-secondary::before, .btn-magenta::before {
  content: var(--brand-button-secondary-rune, '');
  position: absolute;
  right: -5px;
  bottom: -15px;
  font-size: 3rem;
  opacity: 0.1;
  pointer-events: none;
}

.btn-secondary:hover, .btn-magenta:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 6px 18px var(--border-magenta-glow);
}

/* Muted Outline style */
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--border-highlight);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--accent-danger);
  color: var(--accent-danger);
}

.btn-danger:hover {
  background: var(--accent-danger);
  color: var(--text-primary);
  box-shadow: 0 4px 12px var(--accent-danger-glow);
}

/* Tab button controllers */
.btn-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-tab.active {
  color: var(--accent-cyan);
  border-bottom: 2px solid var(--accent-cyan);
}

/* Form Inputs & Select Controls */
.input-field, .form-input {
  width: 100%;
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.875rem;
  color: var(--text-primary) !important;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.input-field option, .form-input option, select option {
  background-color: var(--bg-color-secondary) !important;
  color: var(--text-primary) !important;
}

.input-field:focus, .form-input:focus {
  outline: none;
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 0 2px var(--accent-cyan-glow) !important;
  background: rgba(30, 41, 59, 0.6);
}

.input-field::placeholder, .form-input::placeholder {
  color: var(--text-tertiary);
}

/* Highly Custom Selector Controls */
.lu-select, select.lu-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230ea5e9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.lu-select:hover, select.lu-select:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.lu-select:focus, select.lu-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan-glow);
  background-color: rgba(15, 23, 42, 0.85);
}

/* Custom styled modern checkbox */
.lu-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-highlight);
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.6);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lu-checkbox:checked {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.lu-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid #080c14;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.lu-checkbox:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 5px var(--accent-cyan-glow);
}

/* Navigation Links inside Navigation rail */
.nav-item, .lu-sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  justify-content: flex-start;
  text-decoration: none;
  font-family: var(--font-primary), sans-serif;
}

.nav-item:hover, .lu-sidebar-nav-btn:hover {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active, .lu-sidebar-nav-btn.active {
  background: rgba(6, 182, 212, 0.12);
  color: #ffffff;
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-left: 3px solid var(--accent-cyan);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.1);
  font-weight: 600;
}

/* Layout Helpers */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* Priority status indicators */
.priority-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.priority-high {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.priority-med {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.priority-low {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Evidence validation relation badges */
.badge-rel {
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
}

.badge-supports {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-refutes {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-context {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* Document directory folder nodes */
.folder-item {
  display: flex;
  align-items: center;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.folder-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.folder-item.active {
  background: rgba(6, 182, 212, 0.08);
  color: var(--accent-cyan);
  border-left: 2px solid var(--accent-cyan);
}

/* AI Instructors & Mentors Personas */
.persona-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.4);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.persona-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
}

.persona-card.active {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px var(--accent-cyan-glow);
  background: rgba(6, 182, 212, 0.03);
}

/* Chat view panel stream */
.chat-container {
  display: flex;
  height: calc(100vh - 12rem);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.2);
}

.chat-history {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  overflow-y: auto;
  gap: 1.25rem;
}

.chat-bubble {
  max-width: 80%;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.6;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--bg-color-tertiary);
  color: var(--text-primary);
  border-bottom-right-radius: var(--radius-sm);
  border: 1px solid var(--border-highlight);
}

.chat-bubble.ai {
  align-self: flex-start;
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* Policy lists and settings tables */
.policy-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.policy-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 600;
}

.policy-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

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

/* Search autocomplete results panel */
.lu-search-results-panel {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  max-height: 250px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
}

.lu-search-result-item {
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: all var(--transition-fast);
}

.lu-search-result-item:hover {
  background: rgba(6, 182, 212, 0.08);
  color: var(--accent-cyan-bright);
}

.lu-search-result-item.active {
  background: rgba(6, 182, 212, 0.15);
  border-left: 3px solid var(--accent-cyan);
}

/* Micro-animations and timing */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin-anim {
  animation: spin 1s linear infinite;
}

.animate-spin-slow {
  animation: spin 8s linear infinite;
}

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

.animate-fade-in {
  animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes pulse-light {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
}

.env-pulse-dot {
  animation: pulse-light 2s infinite ease-in-out;
}

/* Markdown Rendering Engine Overrides */
.markdown-body {
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.625;
  color: var(--text-primary);
}

.markdown-body p {
  margin-bottom: 1.2rem;
}

.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3, 
.markdown-body h4 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.markdown-body h1 {
  font-size: 1.85rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}

.markdown-body h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.3rem;
}

.markdown-body h3 {
  font-size: 1.25rem;
}

.markdown-body ul, 
.markdown-body ol {
  padding-left: 2rem;
  margin-bottom: 1.2rem;
}

.markdown-body li {
  margin-bottom: 0.4rem;
}

.markdown-body blockquote {
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  background: rgba(19, 26, 42, 0.3);
  border-left: 0.25rem solid var(--accent-cyan);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 1.2rem;
}

.markdown-body code {
  padding: 0.2rem 0.4rem;
  margin: 0;
  font-size: 0.875rem;
  background-color: var(--bg-color-tertiary);
  border-radius: 4px;
  font-family: 'Courier New', Courier, monospace;
  border: 1px solid var(--border-color);
  color: var(--accent-magenta);
}

.markdown-body pre {
  padding: 1.2rem;
  overflow: auto;
  font-size: 0.9rem;
  line-height: 1.45;
  background-color: var(--bg-color-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.2rem;
}

.markdown-body pre code {
  background-color: transparent;
  padding: 0;
  border: none;
  color: inherit;
  font-family: inherit;
}

/* Premium Table Styling for Markdown Content */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.2rem;
  margin-bottom: 1.2rem;
  font-size: 0.92rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
}

.markdown-body th {
  background: var(--bg-color-secondary);
  color: var(--accent-cyan);
  font-weight: 600;
  padding: 0.85rem 1.25rem;
  border-bottom: 2px solid var(--border-highlight);
  text-align: left;
}

.markdown-body td {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(19, 26, 42, 0.4);
  color: var(--text-primary);
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.markdown-body tr:hover td {
  background: rgba(0, 242, 254, 0.04);
}

/* Impersonation Banner */
.impersonation-banner {
  background: linear-gradient(90deg, var(--accent-gold) 0%, #d97706 100%);
  color: #000000;
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  z-index: 9999;
}
