/* ========================================================================
 * app_ui.css - Global UI and Layout System
 * ========================================================================
 *
 * Central stylesheet for all UI primitives, design tokens, and layout.
 * This file defines the visual language of the entire application.
 *
 * CONTENTS:
 *  1. Design Tokens & Base Typography
 *  2. Button System
 *  3. Inputs, Selects & Forms
 *  4. Form Layout & Structure
 *  5. Cards & Sections
 *  6. Tables & Lists
 *  7. Modal Dialogs
 *  8. Layout Primitives (LeftBar, TopMenuBar, SidebarDiv, LogDiv)
 *
 * USAGE PRINCIPLES:
 *  - Use CSS custom properties (variables) for consistency
 *  - Follow BEM-like naming: .component, .component-element, .component--modifier
 *  - Keep page-specific styles in separate files
 *  - Components used in 3+ places belong here
 *
 * CURRENT USAGE ACROSS PAGES:
 *  - layout.html (base template) - All layout primitives, global components
 *  - builder_structures.html - Buttons, forms, SearchableSelect, sections
 *  - data_visualizations.html - All components (most comprehensive usage)
 *  - data_files.html - Tables, buttons, forms
 *  - All pages - Layout primitives (LeftBar, TopMenuBar, ContentDiv, LogDiv)
 *
 * COMPONENT USAGE SUMMARY:
 *  ┌─────────────────────────┬─────────────────────────┬─────────────────────────┐
 *  │ Component                │ Primary Location         │ Instances                │
 *  ├─────────────────────────┼─────────────────────────┼─────────────────────────┤
 *  │ .btn                     │ All pages                │ 100+ (ubiquitous)        │
 *  │ .btn-group               │ builder, data viz        │ 10+ groups               │
 *  │ .form-group              │ All forms                │ 200+ (all forms)         │
 *  │ .inline-group            │ data viz                 │ 50+ (heavy usage)        │
 *  │ .section-header          │ builder, data viz        │ 10+ sections             │
 *  │ .searchable-select-*     │ builder, data viz        │ 6+ instances             │
 *  │ .modal                   │ data viz, confirmations  │ Multiple dialogs         │
 *  │ .data-table              │ file lists, traces       │ Multiple tables          │
 *  │ Layout primitives        │ layout.html (all pages)  │ 1 per page (shell)       │
 *  └─────────────────────────┴─────────────────────────┴─────────────────────────┘
 *
 * ======================================================================== */

/**********************************************
 * 1. DESIGN TOKENS & BASE TYPOGRAPHY
 **********************************************/

/* Design tokens are CSS custom properties (variables) that define the
 * visual foundation of the application. Use these throughout your code
 * instead of hardcoded values for consistency and easy theme changes.
 *
 * USAGE: var(--token-name)
 * EXAMPLE: color: var(--text-primary);
 *          padding: var(--space-md);
 *
 * SPACING SCALE:
 *   --space-xs (4px)  - Tight gaps, inline elements
 *   --space-sm (8px)  - Form field gaps, button groups
 *   --space-md (16px) - Section margins, card padding
 *   --space-lg (24px) - Major section gaps
 *   --space-xl (32px) - Page-level spacing
 *
 * COLORS:
 *   --text-primary   (#333) - Body text, headings
 *   --text-secondary (#666) - Labels, subtitles
 *   --text-muted     (#999) - Hints, disabled text
 *   --bg-white       (#fff) - Card backgrounds
 *   --bg-light       (#f8f9fa) - Hover states, section headers
 *   --border-color   (#ddd) - Standard borders
 *
 * SEMANTIC COLORS:
 *   --color-success (#4caf50) - Success states, confirmations
 *   --color-error   (#f44336) - Errors, destructive actions
 *   --color-warning (#ff9800) - Warnings, cautions
 *   --color-info    (#2196f3) - Info messages, links
 *   --color-primary (#bfdbfe) - Primary UI accent
 *
 * LAYOUT DIMENSIONS:
 *   --leftbarwidth (300px)    - Width of left navigation
 *   --topmenuheight (55px)    - Height of top menu bar
 *   --logdivheight (150px)    - Height of bottom log panel
 *   --sidebardivwidth (350px) - Width of right sidebar
 *
 * CONTROL HEIGHTS:
 *   --control-height (38px)       - Standard inputs, selects, buttons
 *   --control-height-small (28px) - Compact controls
 */

:root {
  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-10: 10px;
  --space-12: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Font weight scale */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Border radius scale */
  --border-radius-sm: 3px;     /* Compact UI, subtle rounding */
  --border-radius: 4px;        /* Standard buttons, inputs, cards */
  --border-radius-lg: 8px;     /* Cards, modals, containers */
  --border-radius-xl: 16px;    /* Hero elements, large features */
  --border-radius-full: 50px;  /* Pills, circles, badges */

  /* Input width constraints */
  --input-width-narrow: 100px;   /* Small numeric inputs (counts, IDs, small numbers) */
  --input-width-medium: 200px;   /* Medium inputs (names, short text, dates) */
  --input-width-wide: 300px;     /* Wide inputs (descriptions, longer text) */
  --input-width-full: 100%;      /* Full-width inputs (textareas, long text) */
  
  /* Border colors */
  --border-color: #ddd;
  --border-color-light: #eee;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;

  /* Z-index scale - Logical stacking system */
  --z-base: 1;              /* Base content layer */
  --z-content: 2;           /* Content layer (ContentDiv) */
  --z-sidebar: 3;           /* Sidebar above content */
  --z-sticky: 10;           /* Sticky headers (table headers) */
  --z-dropdown: 1000;       /* Dropdown menus */
  --z-overlay: 1001;        /* Overlays and backdrops */
  --z-modal-backdrop: 9999; /* Modal backdrop */
  --z-modal: 10000;         /* Modal dialogs */
  --z-popover: 99999;       /* Popovers and tooltips */
  --z-shield-backdrop: 1000000;  /* Shield modal backdrop */
  --z-shield-modal: 1000001;     /* Shield modal (highest) */
  --z-top: 999999;          /* Utility - force to top */

  /* Shadows */
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.12);
  --shadow-dropdown: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);

  /* Backgrounds */
  --bg-light: #f8f9fa;
  --bg-light-hover: #e9ecef;  /* Slightly darker for secondary button hover */
  --bg-white: #ffffff;
  --content-bg: #ffffff;      /* Content area background (SubcontentDiv, SidebarDiv) */
  
  /* FullRMC brand background color (dark blue-gray) */
  --fullrmc-bg: #2c3e50;

  /* Text colors */
  --text-primary: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --text-white: #fff;        /* White text on dark backgrounds */
  --text-warning: #856404;   /* Warning text (dark amber/brown) */

  /* Semantic colors */
  --color-success: #4caf50;
  --color-success-hover: #388e3c;      /* Darker green for hover */
  --bg-success-light: #d4edda;         /* Light green background for success states */
  --text-success: #155724;             /* Dark green text for success states */
  
  --color-error: #f44336;
  --color-error-hover: #d32f2f;        /* Darker red for hover */
  
  --color-danger: #FF5722;   /* Error/danger accent (orange-red) */
  
  --color-warning: #ff9800;
  --color-warning-hover: #f57c00;      /* Brighter orange for hover */
  
  --color-info: #2196f3;
  --color-info-hover: #1976d2;         /* Darker blue for hover */
  
  --color-highlight: #FFC107;          /* Amber - edits, changes, attention (Material Amber 500) */
  --color-highlight-hover: #FFB300;    /* Darker amber for hover (Material Amber 600) */
  
  --color-critical: #c62828;           /* Dark aggressive red (Material Red 800) */
  --color-critical-hover: #b71c1c;     /* Even darker for hover */
  --color-critical-active: #8b0000;    /* Very dark red for active state */
  --color-critical-border: #b71c1c;    /* Border color for emphasis */
  
  /* Semantic light backgrounds (for alerts, notifications, highlights) */
  --bg-error-light: #ffebee;    /* Light red background */
  --bg-warning-light: #fff3cd;  /* Light yellow background */
  --bg-info-light: #e3f2fd;     /* Light blue background - info, debug boxes */
  --bg-highlight-light: #FFF9C4;  /* Light amber background - edits, changes, active states (Material Amber 100) */

  /* Primary accent for UI elements (kept consistent across layout modes)
     Very soft blue; if we keep it this light we may eventually want dark text
     on primary buttons for perfect contrast, but visually it is very calm. */
  /* --color-primary: #bfdbfe; */ /* Original (too light - fails WCAG AA) */
  --color-primary: #2563eb; /* Professional blue (WCAG AA compliant - 5.8:1 contrast with white) */
  --color-primary-hover: #3b82f6;  /* Brighter blue - button "lights up" on hover */
  --color-primary-active: #1e40af; /* Darker blue for active/pressed state */
  
  /* FullRMC brand accent color (purple for buttons/highlights) */
  --fullrmc-accent: #667eea;
  --fullrmc-accent-dark: #764ba2;  /* Darker purple for gradients */

  /* Python syntax highlighting colors */
  --pythoncolor-comment: #6a9955;    /* Green - comments */
  --pythoncolor-function: #dcdcaa;   /* Yellow - function names */
  --pythoncolor-string: #ce9178;     /* Orange - strings */
  --pythoncolor-syntax: #569cd6;     /* Blue - keywords, syntax */

  /* Typography */
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-family-mono: ui-monospace, 'Cascadia Code', 'SF Mono', Consolas, Monaco, 'Courier New', monospace;
  
  /* Font size scale - Extended (6 sizes) */
  --font-size-sm: 12px;    /* Small text, labels, captions */
  --font-size-base: 14px;  /* Body text, buttons, most UI */
  --font-size-md: 16px;    /* Subsection titles, layer headers */
  --font-size-lg: 20px;    /* Section headings, major titles */
  --font-size-xl: 32px;    /* Hero text, page titles */
  
  /* Font weights for hierarchy */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Layout dimensions (used by LeftBar / TopMenuBar / LogDiv / SidebarDiv) */
  --leftbarwidth: 300px;
  --topmenuheight: 55px;
  --logdivheight: 150px;
  --sidebardivwidth: 350px;

  /* LeftBar colors */
  --leftbar-bg: var(--fullrmc-bg);
  --leftbar-text: #ffffff;

  /* TopMenuBar colors */
  --topmenu-bg: var(--fullrmc-bg);
  --topmenu-text: #ffffff;

  /* Control heights */
  --control-height: 38px;       /* default single-line controls (increased for descenders) */
  --control-height-small: 28px; /* compact controls (e.g., small buttons) */
  
  /* Border widths */
  --border-width: 1px;
  --border-width-thick: 2px;
  
  /* Shadow colors */
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-medium: rgba(0, 0, 0, 0.2);
  --shadow-accent: rgba(102, 126, 234, 0.3);
  --shadow-info: rgba(33, 150, 243, 0.2);
  
  /* Text opacity variations */
  --text-white-90: rgba(255, 255, 255, 0.9);
  
  /* Transform utilities */
  --transform-lift-sm: translateY(-2px);
  --transform-scale-hover: scale(1.05);
}

/* Apply consistent font family globally */
/*
 * Note: This file defines global primitives only (tokens, buttons, inputs,
 * forms, and overall layout). Reusable higher-level components like the
 * upload zone or help popovers should live in dedicated component CSS
 * files (e.g. component_upload.css, help_system.css) and be included by
 * pages that use them.
 */

body {
  font-family: var(--font-family);
  color: var(--text-primary);
  line-height: 1.5;
}

body.waiting * {
  cursor: progress;
}

body.locking * {
  cursor: not-allowed;
}

/* Utility helpers */
.DivCentered {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  text-align: center;
}



/* Font weight utilities */
.fw-normal {
  font-weight: 400;
}

.fw-medium,
.fw-500 {
  font-weight: 500;
}

.fw-semibold,
.fw-600 {
  font-weight: 600;
}

.fw-bold {
  font-weight: 700;
}

/* Overflow utilities */
.overflow-x-auto {
  overflow-x: auto;
}

.overflow-y-auto {
  overflow-y: auto;
}

.overflow-hidden {
  overflow: hidden;
}

/* Text size utilities */
.text-xs {
  font-size: var(--font-size-sm);
}

.text-sm {
  font-size: var(--font-size-base);
}

.text-base {
  font-size: var(--font-size-base);
}

.text-lg {
  font-size: var(--font-size-base);
}

.text-xl {
  font-size: var(--font-size-lg);
}

.text-xxl {
  font-size: 150%;
}

/* Text overflow and truncation utilities */
.text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-wrap {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.text-nowrap {
  white-space: nowrap;
}

/* Cursor utilities */
.cursor-pointer {
  cursor: pointer;
}

.cursor-default {
  cursor: default;
}

/* User select utilities */
.user-select-none {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.user-select-all {
  user-select: all;
}

/* Display utilities */
.is-hidden {
  display: none !important;
}

/* Text divider utility */
.text-divider {
  text-align: center;
  margin: var(--space-lg) 0;
  color: var(--text-muted);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
}

/* Badge component - inline pill indicators */
.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--border-radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-white);
  line-height: 1;
  vertical-align: middle;
}

.badge-primary {
  background: var(--fullrmc-accent);
}

.badge-muted {
  background: var(--text-muted);
}

.badge-success {
  background: var(--color-success);
}

.badge-error {
  background: var(--color-error);
}

.badge-warning {
  background: var(--color-warning);
}

.badge-info {
  background: var(--color-info);
}

/* ========================================
   TYPOGRAPHY SYSTEM - Element Agnostic
   Use these classes on ANY element for consistent typography
   ======================================== */

/* Heading Level 1 - Page Titles */
.heading-1 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Heading Level 2 - Major Sections */
.heading-2 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Heading Level 3 - Subsections */
.heading-3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Heading Level 4 - Minor Subsections */
.heading-4 {
  font-size: var(--font-size-base);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Heading Level 5 - Small Headers */
.heading-5 {
  font-size: var(--font-size-base);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

/* Body Text - Explicitly defined for clarity */
.body-text {
  font-size: var(--font-size-base);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Label Text - For form labels */
.label-text {
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--text-primary);
}

/* Code and preformatted text */
pre {
  background: white;
  padding: var(--space-sm);
  border-radius: var(--border-radius);
  margin: 5px 0;
  overflow-x: auto;
  font-size: var(--font-size-sm);
  font-family: var(--font-family-mono);
  line-height: 1.5;
  border: 1px solid var(--border-color-light);
  white-space: pre;
}

code {
  font-family: var(--font-family-mono);
  font-size: 0.9em;
  background: var(--bg-light);
  padding: 2px 4px;
  border-radius: var(--border-radius-sm);
}

/**********************************************
 * 2. BUTTON SYSTEM
**********************************************/

/* Standardized button components for all user actions.
 *
 * BASE CLASS: .btn
 *   Standard button with neutral styling
 *   USAGE: <button class="btn">Click Me</button>
 *   USED IN: All pages (100+ instances)
 *
 * VARIANTS:
 *   .btn-primary   - Primary actions (submit, save, create)
 *                    USED IN: builder_structures.html (upload, create)
 *                             data_visualizations.html (add trace, save)
 *
 *   .btn-secondary - Secondary actions (cancel, close)
 *                    USED IN: Modal dialogs, form cancellations
 *
 *   .btn-success   - Positive actions (confirm, accept)
 *                    USED IN: Confirmation dialogs
 *
 *   .btn-danger    - Destructive actions (delete, remove)
 *                    USED IN: Delete buttons throughout app
 *
 *   .btn-info      - Information actions (help, learn more)
 *                    USED IN: Help dialogs, info panels
 *
 *   .btn-accent    - Brand accent actions (FullRMC purple)
 *                    USED IN: account_sessions.html (Manage Sessions button)
 *
 * SIZE MODIFIERS:
 *   .btn-small (or .btn-sm) - Compact buttons (28px height)
 *                             USED IN: Inline actions, toolbars
 *
 *   .btn-large  - Larger buttons with more padding
 *                 USED IN: Hero CTAs, primary page actions
 *
 *   .btn-block  - Full-width button
 *                 USED IN: Mobile layouts, modal actions
 *
 * SPECIAL TYPES:
 *   .btn-icon   - Icon-only button (transparent, hover effect)
 *                 USED IN: Section toggles, toolbars, action menus
 *                 EXAMPLE: <button class="btn-icon">▼</button>
 *
 *   .btn-group  - Container for horizontal button groups
 *                 USED IN: builder_structures.html (action groups)
 *                          data_visualizations.html (trace actions)
 *                 EXAMPLE: <div class="btn-group">
 *                            <button class="btn">Option 1</button>
 *                            <button class="btn">Option 2</button>
 *                          </div>
 *
 * TABS:
 *   .tab-strip  - Container for tab navigation
 *   .tab-btn    - Individual tab button (underline style)
 *   .type-tab   - Trace type tab (data visualizations)
 *                 USED IN: data_visualizations.html (scatter, bar, histogram tabs)
 *                 EXAMPLE: <div class="tab-strip">
 *                            <button class="tab-btn active">Tab 1</button>
 *                            <button class="tab-btn">Tab 2</button>
 *                          </div>
 */

/* Group of buttons laid out horizontally */
.btn-group {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.btn-group .btn {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-height);
  padding: 0 12px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  background: var(--bg-white);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
}

.btn:hover {
  background: #f5f5f5;
  box-shadow: var(--shadow);
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--text-white);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--bg-light);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-light-hover);
}

.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: var(--text-white);
}

.btn-success:hover {
  background: var(--color-success-hover);
}

.btn-info {
  background: var(--color-info);
  border-color: var(--color-info);
  color: var(--text-white);
}

.btn-info:hover {
  background: var(--color-info-hover);
}

.btn-danger {
  background: var(--color-error);
  border-color: var(--color-error);
  color: var(--text-white);
}

.btn-danger:hover {
  background: var(--color-error-hover);
}

.btn-warning {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: var(--text-white);
}

.btn-warning:hover {
  background: var(--color-warning-hover);
}

.btn-critical {
  background: var(--color-critical);
  border: 2px solid var(--color-critical-border);
  color: var(--text-white);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(198, 40, 40, 0.3);
}

.btn-critical:hover {
  background: var(--color-critical-hover);
  border-color: var(--color-critical-active);
  box-shadow: 0 4px 12px rgba(198, 40, 40, 0.5);
}

.btn-critical:active:not(:disabled) {
  background: var(--color-critical-active);
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(198, 40, 40, 0.4);
}

/* ========================================
 * BUTTON VARIANT: Accent (FullRMC Purple)
 * For FullRMC brand-colored actions
 * USED IN: account_sessions.html (Manage Sessions button)
 * ======================================== */

.btn-accent {
  background: var(--fullrmc-accent);
  border-color: var(--fullrmc-accent);
  color: var(--text-white);
}

.btn-accent:hover {
  background: #5568d3;  /* Darker purple for hover (calculated: 85% lightness) */
  border-color: #5568d3;
}

.btn-accent:active:not(:disabled) {
  background: #4451b8;  /* Even darker for active state (calculated: 70% lightness) */
}

/* ========================================
 * BUTTON STATES - Disabled & Active
 * ======================================== */

/* Disabled state - all button variants */
.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-success:disabled,
.btn-danger:disabled,
.btn-warning:disabled,
.btn-info:disabled,
.btn-critical:disabled,
.btn-accent:disabled,
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Active (pressed) state */
.btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-primary:active:not(:disabled) {
  background: var(--color-primary-active);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* Small buttons - merged duplicate classes */
.btn-small,
.btn-sm {
  height: var(--control-height-small);
  padding: 0 8px;
  font-size: var(--font-size-sm);
}

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

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-large {
  /* Larger button keeps dynamic height from padding */
  padding: 10px 16px;
  font-size: var(--font-size-base);
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  opacity: 0.7;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s, transform 0.25s ease-in-out;
  color: inherit;
  flex-shrink: 0;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
}

.btn-icon:hover {
  opacity: 1;
  background: #f5f5f5;
}

/* Icon button semantic modifiers */
.btn-icon--danger {
  color: var(--color-error);
}

.btn-icon--danger:hover {
  color: var(--color-error-hover);
  background: rgba(244, 67, 54, 0.1);
}

/* ========================================
 * Icon Button Size Variants
 * ======================================== */

/* Square icon buttons with fixed size */
.btn-icon--square {
  width: 32px;
  height: 32px;
  padding: 0;
}

.btn-icon--square-sm {
  width: 24px;
  height: 24px;
  padding: 0;
}

/* ========================================
 * Icon Button Content Modifiers
 * ======================================== */

/* Add button (+) */
.btn-icon--add::before {
  content: '+';
  font-size: 18px;
  font-weight: 700;
}

/* Remove button (−) */
.btn-icon--remove::before {
  content: '−';  /* Minus sign (U+2212), not hyphen */
  font-size: 18px;
  font-weight: 700;
}

/* Arrow button (▼) with rotation support */
.btn-icon--arrow::before {
  content: '▼';
  font-size: 12px;
  display: inline-block;
  transition: transform var(--transition-normal, 0.2s ease);
}

/* Rotation states for arrows */
.btn-icon--arrow.rotated::before {
  transform: rotate(-90deg);
}

/* Section header toggle arrows */
.section-header .btn-icon {
  width: 32px;
  height: 32px;
  pointer-events: none;  /* Let clicks pass through to header */
  position: relative;
}

.section-header .btn-icon::before {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 9px;  /* Right-pointing triangle */
  border-color: transparent transparent transparent currentColor;
}

.section-header:hover .btn-icon {
  opacity: 1;
  background: var(--bg-light);
  border: 1px solid var(--moduleSelectionColor);
}

.section-header .btn-icon.active {
  background: var(--moduleSelectionColor) !important;
  color: white !important;
  opacity: 1;
  border: 1px solid var(--moduleSelectionColor) !important;
}

/* ========================================
 * Toggle Buttons (Collapsible Sections)
 * ======================================== */

/* Toggle button for expandable/collapsible content */
.btn-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs, 4px);
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text, #333);  /* Neutral color */
  cursor: pointer;
  transition: color var(--transition-fast, 0.15s ease);
}

.btn-toggle:hover {
  color: var(--color-primary, #2196F3);
}

/* Toggle arrow indicator */
.btn-toggle__arrow {
  display: inline-block;
  flex-shrink: 0;
  color: var(--color-text-secondary, #666);  /* Neutral gray */
  transition: transform var(--transition-fast, 0.15s ease), color var(--transition-fast, 0.15s ease);
}

/* Arrow color on hover */
.btn-toggle:hover .btn-toggle__arrow {
  color: var(--color-primary, #2196F3);
}

/* Expanded state - rotate arrow 90 degrees */
.btn-toggle.expanded .btn-toggle__arrow {
  transform: rotate(90deg);
}

.section-header .btn-icon.rotated {
  transform: rotate(90deg);
  background-color: var(--moduleSelectionColor) !important;
  color: white;
}

/* Shared underline-style tabs used across pages */
.tab-strip {
  display: flex;
  gap: var(--space-sm);
  border-bottom: 2px solid var(--border-color);
  margin-bottom: var(--space-md);
  overflow-x: auto;
}

/* File Viewer tabs (.tab-btn) and Add Trace tabs (.type-tab) */
.tab-btn,
.type-tab {
  background: none;
  border: none;
  padding: var(--space-sm) var(--space-12);
  cursor: pointer;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.tab-btn:hover,
.type-tab:hover {
  background: #f5f5f5;
  color: var(--moduleSelectionColor);
}

.tab-btn.active,
.type-tab.active {
  color: var(--moduleSelectionColor);
  background: var(--bg-white);
  border-bottom-color: var(--moduleSelectionColor);
  font-weight: 600;
}

/* Generic tab content visibility helper */
.tab-content {
  display: none;
  background: var(--bg-white);
  padding: var(--space-md);
}

.tab-content.active {
  display: block;
  background: var(--bg-white);
}

.preset-group {
  margin: var(--space-md) 0;
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.preset-group label {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: var(--font-size-base);
}

.preset-btn {
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.preset-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: #f5faff;
}

.preset-btn.active {
  background: var(--color-primary);
  color: var(--text-white);
  border-color: var(--color-primary);
}

/* ========================================
 * BUTTON GROUP UTILITIES
 * ======================================== */

/* .form-actions - Standard right-aligned button group for form endings
 * USAGE: Place at bottom of forms to group action buttons
 * FEATURES: Right-aligned, separator line, responsive mobile stacking */
.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-color);
}

/* .inline-actions - Right-aligned button group without separator
 * USAGE: For inline button groups in content (upload, bulk actions, etc.)
 * FEATURES: Right-aligned, no border, responsive mobile stacking */
.inline-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* Mobile: Stack buttons vertically, primary on top */
@media (max-width: 640px) {
  .form-actions,
  .inline-actions {
    flex-direction: column-reverse;
  }
  
  .form-actions .btn,
  .inline-actions .btn {
    width: 100%;
  }
}


/**********************************************
 * 3. INPUTS, SELECTS & FORMS
 **********************************************/

/* Form controls with consistent styling and behavior.
 *
 * TEXT INPUTS:
 *   .input  - Standard text input field (38px height)
 *             USAGE: <input type="text" class="input" />
 *             USED IN: All forms throughout the application
 *             FEATURES: Focus ring, consistent padding, 14px font
 *
 * SELECT DROPDOWNS:
 *   .select - Standard dropdown select (38px height)
 *             USAGE: <select class="select"><option>...</option></select>
 *             USED IN: All forms with dropdown options
 *             NOTE: Being replaced by SearchableSelect component where beneficial
 *
 * SEARCHABLE SELECT:
 *   .searchable-select-dropdown - Custom dropdown container (created by JS)
 *                                 USAGE: Created automatically by SearchableSelect class
 *                                 USED IN: builder_structures.html (stored structures)
 *                                          data_visualizations.html (file selectors)
 *                                 FEATURES: Fixed positioning, scroll, max 8 items visible
 *
 *   .searchable-select-item - Individual dropdown item
 *                             USED IN: Rendered by SearchableSelect.populate_custom_dropdown()
 *                             STATES: .empty (no results), :hover (highlight)
 *                             FEATURES: 32px height, consistent padding, hover effect
 *
 * COLOR PICKER:
 *   .color-input - Native HTML5 color input
 *                  USAGE: <input type="color" class="color-input" />
 *                  USED IN: data_visualizations.html (trace colors, axis colors)
 *                  FEATURES: Matches control height, consistent border radius
 *
 * CHECKBOXES:
 *   .checkbox-label - Wrapper for checkbox + label
 *                     USAGE: <label class="checkbox-label">
 *                              <input type="checkbox" /> Enable feature
 *                            </label>
 *                     USED IN: All pages with checkbox options
 *                     FEATURES: Inline-flex, 6px gap, 14px checkbox size
 *
 * SEARCH:
 *   .search-box - Search input container
 *                 USAGE: <div class="search-box">
 *                          <input type="text" placeholder="Search..." />
 *                        </div>
 *                 USED IN: File lists, structure browsers
 *                 FEATURES: Full width, focus ring, consistent styling
 */

.search-box {
  margin-bottom: var(--space-md);
}

.search-box input {
  width: 100%;
  padding: var(--space-sm) var(--space-12);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: var(--font-size-base);
}

.search-box input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/**********************************************
 * 3. INPUTS & SELECTS
 **********************************************/

/* Checkbox label wrapper used throughout forms */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
  /* font-size removed - inherits from parent (e.g., text-lg) */
  cursor: pointer;
  user-select: none;
  line-height: 1.2;
}

/* Ensure checkbox labels are not bold even inside form-group */
.form-group .checkbox-label {
  font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  vertical-align: baseline;
  position: relative;
  top: 0;
}


/* Input fields - includes Bootstrap legacy .form-control alias */
.input,
.form-control {
  display: inline-block; /* Changed from block to inline-block for inline usage */
  width: 100%;
  height: var(--control-height);
  padding: var(--space-sm) var(--space-12);
  line-height: 1.5;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background-color: var(--bg-white);
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  vertical-align: middle; /* Align with checkboxes */
}

.input:focus,
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* Textarea variant - auto-height for multi-line */
textarea.input,
textarea.form-control {
  height: auto;
  resize: vertical;
  min-height: var(--control-height);
}

.select {
  display: block;
  width: 100%;
  height: var(--control-height);
  padding: var(--space-sm) var(--space-12);
  line-height: 1.5;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background-color: var(--bg-white);
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* SearchableSelect Dropdown */
.searchable-select-dropdown {
  position: fixed;
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  box-shadow: var(--shadow-dropdown);
  z-index: var(--z-top);
  max-height: 256px;
  overflow-y: auto;
  overflow-x: hidden;
  /* Ensure dropdown is always above everything */
  pointer-events: auto;
}

.searchable-select-item {
  padding: var(--space-sm) var(--space-12);
  cursor: pointer;
  height: 32px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  font-size: var(--font-size-base);
  font-family: inherit;
  font-weight: normal;
  color: var(--text-primary);
  background-color: var(--bg-white);
  transition: background-color 0.15s ease;
}

.searchable-select-item:hover {
  background-color: var(--bg-light);
}

.searchable-select-item.empty {
  color: var(--text-muted);
  font-style: italic;
  cursor: default;
}

.searchable-select-item.empty:hover {
  background-color: var(--bg-white);
}

.color-input {
  /* Consistent color input: match other controls */
  width: 100%;
  min-width: 52px;
  height: var(--control-height);
  padding: 0; /* let inner swatch control the gap */
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  background: transparent;
  cursor: pointer;
  box-sizing: border-box;
}

/* Standardize the swatch gap across contexts (WebKit/Blink) */
.color-input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: calc(var(--border-radius) - 2px);
}

/* Firefox inner swatch */
.color-input::-moz-color-swatch {
  border: none;
  border-radius: calc(var(--border-radius) - 2px);
}

input[type="checkbox"] {
  cursor: pointer;
}


/**********************************************
 * 7. MODAL DIALOGS & ALERTS
 **********************************************/

/* Modal dialog system for user interactions.
 *
 * MODAL STRUCTURE:
 *   .modal - Full-screen overlay container
 *            USAGE: <div class="modal" style="display: none;">
 *                     <div class="modal-content">
 *                       <div class="modal-header"><h3>Title</h3></div>
 *                       <div class="modal-body">...</div>
 *                       <div class="modal-footer">
 *                         <button class="btn">Cancel</button>
 *                         <button class="btn btn-primary">Confirm</button>
 *                       </div>
 *                     </div>
 *                   </div>
 *            USED IN: data_visualizations.html (save plot modal)
 *                     All pages for confirmations and forms
 *            FEATURES:
 *              - Fixed fullscreen overlay (rgba black 50%)
 *              - Centered content (flexbox)
 *              - z-index 10000 (above all content)
 *              - Click overlay to close (requires JS)
 *
 *   .modal-content - The actual dialog box
 *                    FEATURES: White bg, rounded, shadow, max 500px wide
 *
 *   .modal-header - Title section with bottom border
 *   .modal-body   - Main content area
 *   .modal-footer - Action buttons (right-aligned)
 *
 * ALERTS & BADGES:
 *   .alert - Colored notification banner
 *            USAGE: <div class="alert success">Operation successful!</div>
 *            VARIANTS:
 *              - .success (green) - Confirmations, completed actions
 *              - .error (red) - Errors, failed operations
 *              - .warning (orange) - Warnings, cautions
 *              - .info (blue) - Information, tips
 *            USED IN: Flash messages, inline notifications
 *            FEATURES: Left border accent, consistent padding
 *
 *   .badge - Small inline status indicator
 *            USAGE: <span class="badge success">Active</span>
 *            VARIANTS: .success, .error
 *            USED IN: Status indicators, counts
 *
 *   .error-message - Inline error text (non-banner)
 *                    USAGE: <p class="error-message">Invalid input</p>
 *                    USED IN: Form validation errors
 */

/* Modal dialog system */
.modal {
  display: none; /* Hidden by default, JavaScript sets to 'flex' to show */
  position: fixed;
  z-index: var(--z-modal);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

/* When modal is shown by JavaScript (sets display: flex) */
.modal[style*="display: flex"],
.modal[style*="display: block"] {
  display: flex;
}

.modal-content {
  background: var(--bg-white);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;        /* Prevent modal from exceeding viewport height */
  overflow: hidden;        /* Hide overflow, body will scroll */
  display: flex;
  flex-direction: column;  /* Stack header/body/footer vertically */
  position: relative;
  cursor: default;
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;                    /* Scroll when content is long */
  max-height: calc(90vh - 150px);      /* Account for header + footer */
  flex: 1;                             /* Take remaining space */
}

.modal-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* Simple inline error message (non-banner) */
.error-message {
  color: var(--color-error);
  font-size: var(--font-size-base);
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--border-radius-lg);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.badge.success {
  background: var(--color-success);
  color: white;
}

.badge.error {
  background: var(--color-error);
  color: white;
}

/**********************************************
 * 8. LAYOUT PRIMITIVES - Application Shell
 **********************************************/

/* Core layout system defining the application's visual structure.
 * These components create the main shell: left navigation, top menu,
 * content area, bottom log, and optional right sidebar.
 *
 * LAYOUT HIERARCHY:
 *   ┌─────────────────────────────────────────────────┐
 *   │ TopMenuBar (55px height)                       │
 *   ├──────────┬────────────────────────┬────────────┤
 *   │          │                        │            │
 *   │          │   ContentDiv           │  SidebarDiv│
 *   │ LeftBar  │   (main content)       │  (350px)   │
 *   │ (300px)  │                        │  optional  │
 *   │          │                        │            │
 *   │          ├────────────────────────┤            │
 *   │          │ LogDiv (150px bottom)  │            │
 *   └──────────┴────────────────────────┴────────────┘
 *
 * LEFT NAVIGATION:
 *   .LeftBar - Fixed left sidebar for navigation
 *              WIDTH: var(--leftbarwidth) = 300px
 *              FEATURES:
 *                - Fixed position, full height
 *                - Dark background (#333)
 *                - Minimizable with .minimized class
 *                - Smooth 0.3s width transition
 *              USED IN: All pages via layout.html
 *              TOGGLE: .leftbar-toggle-btn (arrow button)
 *
 * TOP MENU:
 *   .TopMenuBar - Horizontal top navigation bar
 *                 HEIGHT: var(--topmenuheight) = 55px
 *                 FEATURES:
 *                   - Fixed position at top
 *                   - Dark background (#333)
 *                   - Contains navigation links
 *                 USED IN: All pages via layout.html
 *                 ACTIVE STATE: .active class on current page link
 *
 * MAIN CONTENT:
 *   .BodyDiv - Container for all content below TopMenuBar
 *              POSITION: left: var(--leftbarwidth)
 *              HEIGHT: calc(100% - var(--topmenuheight))
 *              USED IN: All pages as main container
 *
 *   .ContentDiv - Scrollable content area (excludes LogDiv)
 *                 POSITION: Fixed, between LeftBar and LogDiv
 *                 HEIGHT: calc(100% - var(--logdivheight) - var(--topmenuheight))
 *                 USED IN: All pages for main scrollable content
 *
 *   .SubcontentDiv - Actual content area (inside ContentDiv)
 *                    DEFAULT: Full width with padding
 *                    PAIRED: Reduces width when SidebarDiv present
 *                    CLASS: .sidebardiv-paired (added by JS)
 *                    WIDTH PAIRED: calc(100% - var(--sidebardivwidth))
 *                    FEATURES: Smooth 0.3s width transition
 *                    USED IN: All pages, contains actual page content
 *
 * BOTTOM LOG:
 *   .LogDiv - Fixed bottom panel for system logs
 *             HEIGHT: var(--logdivheight) = 150px
 *             FEATURES:
 *               - Fixed at bottom (above edge)
 *               - Minimizable with .minimized class
 *               - Border, scroll, dark theme
 *             USED IN: All pages via layout.html
 *             TOGGLE: .log-toggle-btn (arrow button)
 *             CONTENT: .log-content (scrollable area)
 *
 * RIGHT SIDEBAR:
 *   .SidebarDiv - Optional fixed right sidebar for tools/config
 *                 WIDTH: var(--sidebardivwidth) = 350px
 *                 FEATURES:
 *                   - Fixed right position
 *                   - Border-left separator
 *                   - Minimizable with .minimized class
 *                   - Smooth 0.3s width transition
 *                 USED IN: data_visualizations.html (trace config)
 *                          builder_structures.html (structure viewer)
 *                 TOGGLE: .sidebardiv-toggle-btn (arrow button)
 *                 PAIRING: Auto-pairs with SubcontentDiv via JS
 *
 * TOGGLE BUTTONS:
 *   .leftbar-toggle-btn     - Show/hide left navigation
 *   .log-toggle-btn         - Show/hide bottom log
 *   .sidebardiv-toggle-btn  - Show/hide right sidebar
 *   FEATURES:
 *     - Transparent background initially
 *     - .show class reveals button
 *     - .minimized class rotates arrow
 *     - Hover effects and focus rings
 *     - Text shadows for visibility
 *
 * RESPONSIVE BEHAVIOR:
 *   .menu-toggle - Hamburger menu for mobile (hidden on desktop)
 *   .hamburger-dropdown - Mobile navigation menu
 *   BREAKPOINT: Handled by media queries in page-specific CSS
 *
 * TRANSITION CONTROL:
 *   body.sidebardiv-transitions-enabled - Enables smooth animations
 *                                         Added by app_ui.js after page load
 *                                         Prevents initial layout jump
 *
 * OVERLAY:
 *   .overlay - Full-screen dimming overlay
 *              USAGE: <div class="overlay" style="display:none;"></div>
 *              USED IN: Modal backdrops, loading states
 *              FEATURES: rgba(0,0,0,0.5), z-index 1000
 *
 * UTILITIES:
 *   .DivCentered - Absolutely center an element
 *                  USAGE: <div class="DivCentered">Centered Content</div>
 *                  FEATURES: Absolute position, transform centering
 *
 * SPACING UTILITIES:
 *   .mg-top-sm, .mg-top-md     - Top margins
 *   .mg-bottom-sm, .mg-bottom-md - Bottom margins
 *   .pd-sm, .pd-md             - Padding
 *   .is-hidden                 - display: none
 *
 * CURSOR STATES:
 *   body.waiting * - cursor: progress (loading state)
 *   body.locking * - cursor: not-allowed (disabled state)
 */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.modal-content {
  background: var(--bg-white);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;                    /* Scroll when content is long */
  max-height: calc(90vh - 150px);      /* Account for header + footer */
  flex: 1;                             /* Take remaining space */
}

.modal-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal .form-group {
  margin-bottom: 15px;
}

.modal .form-group:last-child {
  margin-bottom: 0;
}

.modal label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--font-size-base);
}

.modal .checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: normal;
  cursor: pointer;
}

.modal .checkbox-label input[type="checkbox"] {
  cursor: pointer;
}

.modal .input {
  width: 100%;
  padding: var(--space-sm) var(--space-12);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: var(--font-size-base);
  box-sizing: border-box;
}

.modal .input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* ============================================================================
   FULLRMC BRANDED MODALS (AppUI.notify, AppUI.confirm, AppUI.prompt_*)
   ============================================================================
   
   Beautiful branded modal system used by app_ui.js functions.
   All modals share consistent FullRMC Cloud branding with logo and status badges.
   
   USAGE:
     AppUI.notify('Message', 'success')  - Notifications
     AppUI.confirm('Question?', {})      - Confirmations
     AppUI.prompt_text('Title', ...)     - Text input
     AppUI.prompt_password('Title', ...) - Password input
   ============================================================================ */

.fullrmc-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  animation: fadeIn 0.2s ease-out;
}

.fullrmc-modal-dialog {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.1);
  /* Responsive min-width with fallback for older browsers */
  min-width: 90vw;              /* Fallback: old browsers use this */
  min-width: min(480px, 90vw);  /* Modern browsers: smaller of 480px or 90% viewport */
  max-width: 600px;
  width: 90vw;                  /* Base width for responsiveness */
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideDown 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fullrmc-modal-header {
  background: var(--fullrmc-bg, #2c3e50);
  padding: 20px 24px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.fullrmc-modal-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: 0.3px;
}

.fullrmc-modal-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  animation: pulse 2s infinite;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 2px;
}

.fullrmc-modal-status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.fullrmc-modal-status-success {
  background: rgba(16, 185, 129, 0.9);
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}

.fullrmc-modal-status-error {
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}

.fullrmc-modal-status-warning {
  background: rgba(245, 158, 11, 0.9);
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}

.fullrmc-modal-status-info {
  background: rgba(59, 130, 246, 0.9);
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}

.fullrmc-modal-body {
  padding: 32px 24px;
  min-height: 80px;
  max-height: calc(90vh - 180px);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.fullrmc-modal-body::-webkit-scrollbar {
  width: 8px;
}

.fullrmc-modal-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.fullrmc-modal-body::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.fullrmc-modal-body::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.fullrmc-modal-message {
  font-size: 15px;
  line-height: 1.7;
  color: #2c3e50;
  word-wrap: break-word;
  word-break: break-word;
  text-align: center;
  max-width: 100%;
  font-weight: 400;
  white-space: pre-wrap;
}

.fullrmc-modal-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: center;
  gap: 10px;
  background: #fafafa;
}

.fullrmc-modal-footer-buttons {
  justify-content: flex-end;
  gap: 12px;
}

.fullrmc-modal-button {
  padding: 12px 32px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: white;
  min-width: 120px;
  letter-spacing: 0.5px;
}

.fullrmc-modal-button:hover {
  transform: translateY(-1px);
}

.fullrmc-modal-button:active {
  transform: translateY(0);
}

.fullrmc-modal-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.fullrmc-modal-button-secondary {
  background: #e0e0e0;
  color: #333;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fullrmc-modal-button-secondary:hover {
  background: #d0d0d0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.fullrmc-modal-button-secondary:focus {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.fullrmc-modal-button-primary {
  background: linear-gradient(135deg, var(--fullrmc-accent, #667eea) 0%, var(--fullrmc-accent-dark, #764ba2) 100%);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.fullrmc-modal-button-primary:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.fullrmc-modal-button-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.fullrmc-modal-button-danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.fullrmc-modal-button-danger:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

/* ============================================================================
   FULLRMC MODAL FORM ELEMENTS
   ============================================================================ */

.fullrmc-modal-subtitle {
  margin: 0 0 16px 0;
  color: #64748b;
  font-size: 14px;
  text-align: center;
}

.fullrmc-modal-form-group {
  display: block;
  width: 100%;
  margin-bottom: 0;
  text-align: left;
}

/* Override flex layout for form modals (prompt_text, prompt_password) */
.fullrmc-modal-body--form {
  display: block !important;
  align-items: unset !important;
  justify-content: unset !important;
  text-align: left;
}

.fullrmc-modal-form-label {
  display: block;
  margin-bottom: 8px;
  color: #475569;
  font-weight: 500;
  font-size: 14px;
}

.fullrmc-modal-input,
.fullrmc-modal-textarea {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
  font-family: inherit;
}

.fullrmc-modal-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Single-row textarea (for rename/simple input) */
.fullrmc-modal-textarea[rows="1"] {
  min-height: auto;
  height: auto;
  resize: none; /* Disable resize for single-line inputs */
  overflow: hidden; /* Hide scrollbar for single line */
}

.fullrmc-modal-textarea--monospace {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
  font-size: 12px;
}

.fullrmc-modal-input:focus,
.fullrmc-modal-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.fullrmc-modal-help-text {
  display: block;
  margin-top: 8px;
  color: #94a3b8;
  font-size: 12px;
}

/* Wider modal for text prompts */
.fullrmc-modal-dialog--wide {
  min-width: 500px;
  max-width: 700px;
}

/**********************************************
 * 4. FORM LAYOUT & STRUCTURE
 **********************************************/

/* Form layout components for organizing inputs and controls.
 *
 * BASIC FORM GROUP:
 *   .form-group - Standard vertical form field container
 *                 USAGE: <div class="form-group">
 *                          <label>Field Name</label>
 *                          <input class="input" />
 *                        </div>
 *                 USED IN: All forms (200+ instances)
 *                 FEATURES: Vertical flex, label above input, 12px bottom margin
 *
 * LAYOUT HELPERS:
 *   .form-stack - Vertical stack of form groups with consistent spacing
 *                 USAGE: <div class="form-stack">
 *                          <div class="form-group">...</div>
 *                          <div class="form-group">...</div>
 *                        </div>
 *                 USED IN: data_visualizations.html (trace forms)
 *                          builder_structures.html (parameter sections)
 *                 FEATURES: Flex column, var(--space-md) gap
 *
 *   .inline-group - Horizontal layout for side-by-side controls
 *                   USAGE: <div class="inline-group">
 *                            <div class="form-group">...</div>
 *                            <div class="form-group">...</div>
 *                          </div>
 *                   USED IN: data_visualizations.html (50+ instances)
 *                            X/Y column selectors, error bar configs, marker settings
 *                   FEATURES: Flex row, 8px gap, responsive wrap, equal flex
 *
 *   .form-grid - CSS Grid layout for multi-column forms
 *                USAGE: <div class="form-grid cols-2">
 *                         <div class="form-group">...</div>
 *                         <div class="form-group">...</div>
 *                       </div>
 *                VARIANTS: .cols-2 (2 columns), .cols-3 (3 columns)
 *                USED IN: Complex configuration forms
 *                FEATURES: Responsive grid, consistent gaps
 *
 * SPECIAL FORM TYPES:
 *   .trace-form - Container for trace type forms (scatter, bar, etc.)
 *                 USAGE: <div id="form-scatter" class="trace-form active">
 *                 USED IN: data_visualizations.html (5 trace forms)
 *                 BEHAVIOR: display:none by default, .active shows block
 *
 * SECTION ORGANIZATION:
 *   .subsection-header - Header within form sections
 *                        USAGE: <span class="subsection-header">Line Style</span>
 *                        USED IN: data_visualizations.html (trace config sections)
 *                        FEATURES: Top border, uppercase, 13px font, spacing
 *
 * EMPTY STATES:
 *   .empty-state-sm - Small empty state (15px padding, 11px text)
 *                     USED IN: Inline "no data" messages
 *
 *   .empty-state-md - Medium empty state (20px padding, 12px text)
 *                     USED IN: Table rows, full-width sections
 *                     EXAMPLE: <tr><td class="empty-state-md">No files found</td></tr>
 *
 * TEXT EDITOR:
 *   .text-editor - Container for code/text editing
 *                  USAGE: <div class="text-editor">
 *                           <textarea></textarea>
 *                         </div>
 *                  FEATURES: Monospace font, min 200px height, resize vertical
 *
 *   .editor-hint - Hint text below editor
 *                  USED IN: Below text editors for format guidance
 */

/* Trace type forms: only the active one should be visible */
.trace-form {
  display: none;
}

.trace-form.active {
  display: block;
}

/* Inline group layout helper for side-by-side controls */
.inline-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.inline-group > * {
  flex: 1;
  min-width: 0;
}

/* Radio buttons and checkboxes should NOT grow - use natural width with fixed gap */
.inline-group > label:has(input[type="radio"]),
.inline-group > label:has(input[type="checkbox"]) {
  flex: 0 0 auto;  /* Don't grow, don't shrink, use content size */
}

/* Small empty state helper */
.empty-state-sm {
  text-align: center;
  padding: 15px 10px;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.empty-state-sm p {
  margin: 4px 0;
}

/* Medium empty state helper (e.g., full-width table rows) */
.empty-state-md {
  text-align: center;
  padding: var(--space-lg);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.text-editor textarea {
  width: 100%;
  min-height: 200px;
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  resize: vertical;
}

.text-editor textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.editor-hint {
  margin-top: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* Code/Data Textarea - For displaying code, JSON, logs, file content */
.code-textarea {
  width: 100%;
  min-height: 200px;
  padding: var(--space-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  overflow-y: auto;
  resize: vertical;
  background: var(--bg-white);
  color: var(--text-primary);
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.code-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.code-textarea:disabled,
.code-textarea[readonly] {
  background: var(--bg-light);
  cursor: default;
  opacity: 0.9;
}

/* Size variant for larger code displays */
.code-textarea-large {
  min-height: 400px;
}

/**********************************************
 * 4. FORM LAYOUT
 **********************************************/

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--space-md);
}

/* Inline form group - label and input on same line */
.form-group-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
  flex-wrap: wrap;
}

.form-group-inline label {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  margin-bottom: 0;
  white-space: nowrap;
}

.form-group-inline input,
.form-group-inline select {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: inherit;
  font-size: var(--font-size-base);
  background-color: var(--bg-white);
}

.form-group-inline .form-text {
  flex-basis: 100%;
  margin-top: var(--space-xs);
}

.form-group label {
  display: block;
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-xs);
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: var(--space-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: inherit;
  font-size: var(--font-size-base);
  background-color: var(--bg-white);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* Form helper text */
.form-text {
  display: block;
  margin-top: var(--space-xs);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* ========================================
 * FORM INPUT STATES - Disabled & Read-only
 * ======================================== */

/* Disabled inputs */
input:disabled,
select:disabled,
textarea:disabled {
  background-color: var(--bg-light);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Read-only inputs (user can see but not edit) */
input:read-only {
  background-color: var(--bg-light);
  cursor: default;
}

/* ========================================
 * KEYBOARD FOCUS INDICATORS
 * WCAG 2.1 Level AA - Criterion 2.4.7
 * Visible focus for keyboard navigation
 * ======================================== */

/* Modern focus-visible (keyboard focus only, not mouse clicks) */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Button focus for keyboard users */
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Input focus for keyboard users */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-color: var(--color-primary);
}

/* ========================================
 * FORM VALIDATION STATES
 * Visual feedback for valid/invalid inputs
 * ======================================== */

/* HTML5 validation - DISABLED
 * Automatic :invalid styling removed to prevent false positives from step validation.
 * Use .is-invalid class for explicit validation feedback instead.
 *
 * REASON: Scientific inputs often have high-precision values (e.g., 2.684335231781006)
 *         that don't match step="0.01", causing unwanted red borders.
 *
 * MIGRATION: Use JavaScript validation + .is-invalid class for error states.
 */

/* Class-based validation for JavaScript control */
.is-invalid {
  border-color: var(--color-error) !important;
}

.is-valid {
  border-color: var(--color-success) !important;
}

/* Error message styling */
.invalid-feedback,
.error-message {
  color: var(--color-error);
  font-size: var(--font-size-sm);
  margin-top: var(--space-xs);
  display: none;
}

/* Show error message when input is invalid */
.is-invalid ~ .invalid-feedback,
.is-invalid + .invalid-feedback {
  display: block;
}

/* Valid message styling */
.valid-feedback {
  color: var(--color-success);
  font-size: var(--font-size-sm);
  margin-top: var(--space-xs);
  display: none;
}

/* Show valid message when input is valid */
.is-valid ~ .valid-feedback,
.is-valid + .valid-feedback {
  display: block;
}

/* Form section organization */
.form-section-group {
  margin-bottom: var(--space-lg);
}

/* Legacy alias - use .heading-3 for new code */
.subsection-header {
  font-size: var(--font-size-lg);  /* Fixed from 1.1em for consistency */
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Section title within forms/cards - semantic typography */
.section-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--fullrmc-accent);  /* Purple to differentiate from card titles */
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.section-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--space-md) 0;
  opacity: 0.6;
}

hr.section-divider {
  margin-bottom: var(--space-md);
}

.form-group.checkbox-item {
  flex-direction: row;
  align-items: center;
}

.form-group.checkbox-item input {
  margin-right: var(--space-sm);
  width: auto;
}

.form-group.checkbox-item label {
  margin-bottom: 0;
}

/* Radio button styling */
.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  user-select: none;
  font-weight: normal;
  font-size: var(--font-size-base);
}

/* Ensure radio labels are not bold even inside form-group */
.form-group .radio-label {
  font-weight: normal;
}

.radio-label input[type="radio"] {
  cursor: pointer;
  margin: 0;
}

.radio-label span {
  white-space: nowrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin: var(--space-md) 0;
}

.form-grid .checkbox-item {
  grid-column: 1 / -1;
}

.form-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.form-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* Form stack - vertical layout for parameters */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.subsection-header {
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 8px;
  padding-top: 12px;
  display: block;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.sidebar-section > .form-group:first-of-type .subsection-header,
.trace-form > .form-group:first-of-type .subsection-header {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.sidebar-section > .form-group:last-of-type,
.trace-form > .form-group:last-of-type {
  margin-bottom: 0;
}


/* Checkbox groups (stacked checkboxes) */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/**********************************************
 * 6. TABLES & LISTS
 **********************************************/

/* Table components for displaying tabular data.
 *
 * DATA TABLES:
 *   .data-table - Standard data table with sticky header
 *                 USAGE: <table class="data-table">
 *                          <thead><tr><th>Column</th></tr></thead>
 *                          <tbody><tr><td>Data</td></tr></tbody>
 *                        </table>
 *                 USED IN: File lists, trace lists, structure browsers
 *                 FEATURES:
 *                   - Sticky header (position: sticky)
 *                   - Hover effect on rows
 *                   - .selected class for active row
 *                   - Consistent borders and padding
 *
 * TABLE CONTAINERS:
 *   .table-scroll-wrapper - Wrapper with fixed height and scroll
 *                           USAGE: <div class="table-scroll-wrapper">
 *                                    <table class="data-table">...</table>
 *                                  </div>
 *                           FEATURES: Max 200px height, overflow-y: auto
 *
 *   .table-container - Full-featured table container
 *                      USAGE: <div class="table-container">
 *                               <table class="data-table">...</table>
 *                             </div>
 *                      FEATURES: Max 600px height, border, rounded corners
 *
 * TABLE TOOLBAR:
 *   .table-toolbar - Toolbar above tables for actions and info
 *                    USAGE: <div class="table-toolbar">
 *                             <div class="table-info">10 items</div>
 *                             <div class="table-actions">
 *                               <button class="btn">Action</button>
 *                             </div>
 *                           </div>
 *                    FEATURES: Flex space-between, bg-light, consistent padding
 *
 *   .table-info - Information display (count, selection status)
 *                 USED IN: Left side of table toolbar
 *
 *   .table-actions - Action buttons for table
 *                    USED IN: Right side of table toolbar
 */

.table-scroll-wrapper {
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-base);
  table-layout: auto; /* Changed from fixed to allow responsive sizing */
  min-width: 100%; /* Ensure table uses full width */
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg-light);
  border-bottom: 2px solid var(--border-color);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-color-light);
  cursor: pointer;
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: var(--bg-light);
}

.data-table tbody tr.selected {
  background: rgba(0, 0, 0, 0.03);
  border-left: 3px solid var(--color-primary);
}

.data-table th {
  padding: var(--space-sm);
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}

.data-table td {
  padding: var(--space-sm);
  color: var(--text-primary);
}

.data-table .filename {
  font-weight: 500;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding: var(--space-sm);
  background: var(--bg-light);
  border-radius: var(--border-radius);
}

.table-info {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  display: flex;
  gap: var(--space-md);
}

.table-actions {
  display: flex;
  gap: var(--space-sm);
}

.table-container {
  max-height: 600px;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

/**********************************************
 * 5. CARDS & SECTIONS
 **********************************************/

/* Card and section containers for organizing content.
 *
 * BASIC CARD:
 *   .card - Standard card container
 *           USAGE: <div class="card">...</div>
 *           USED IN: Dashboard widgets, content blocks
 *           FEATURES: White background, border, shadow, rounded corners
 *
 * COLLAPSIBLE SECTIONS:
 *   .section-header - Clickable header that toggles section visibility
 *                     USAGE: <div class="section-header" onclick="toggle_section('id')">
 *                              <h3>Section Title</h3>
 *                              <button class="btn-icon"></button>
 *                            </div>
 *                     USED IN: builder_structures.html (upload, manage, viewer sections)
 *                              data_visualizations.html (load plot section)
 *                     FEATURES: Flex layout, cursor pointer, arrow rotation on toggle
 *
 *   .section-content - Content area controlled by section header
 *                      USAGE: <div class="section-content" id="my-section" hidden>
 *                      USED IN: Paired with .section-header
 *                      BEHAVIOR: Toggle [hidden] attribute to show/hide
 *
 *   .section-actions - Action buttons at bottom of section
 *                      USAGE: <div class="section-actions">
 *                               <button class="btn btn-primary">Save</button>
 *                             </div>
 *                      FEATURES: Right-aligned, top border, consistent spacing
 *
 * EXPANDABLE CARDS:
 *   .expandable-card - Collapsible card with header + body
 *                      USAGE: <div class="expandable-card">
 *                               <div class="expandable-card-header">...</div>
 *                               <div class="expandable-card-body" hidden>...</div>
 *                             </div>
 *                      USED IN: Parameter configuration panels
 *                      COMPONENTS:
 *                        - .expandable-card-header (clickable, bg-light)
 *                        - .expandable-card-bullet (icon/emoji, flex-shrink: 0)
 *                        - .expandable-card-title (bold, truncates)
 *                        - .expandable-card-controls (right-aligned buttons)
 *                        - .expandable-card-body (main content, toggle [hidden])
 *
 * SIDEBAR SECTIONS:
 *   .sidebar-section - Section within SidebarDiv
 *                      USAGE: <div class="sidebar-section">
 *                               <h4>Section Title</h4>
 *                               <div class="form-group">...</div>
 *                             </div>
 *                      USED IN: data_visualizations.html (right sidebar configs)
 *                      FEATURES: Consistent bottom margin, h4 styling
 *
 * PARAMETER GROUPS:
 *   .param-group - Group of related parameters
 *                  USAGE: <div class="param-group">
 *                           <span class="param-group-title">GROUP NAME</span>
 *                           <div class="form-group">...</div>
 *                         </div>
 *                  USED IN: Complex configuration forms
 *                  FEATURES: 24px bottom margin, uppercase title
 *
 * VECTOR INPUTS:
 *   .vector-input - Container for x,y,z coordinate triplets
 *                   USAGE: <div class="vector-input">
 *                            <div class="vector-component">
 *                              <label>X</label>
 *                              <input type="number" />
 *                            </div>
 *                            <div class="vector-component">...</div>
 *                          </div>
 *                   USED IN: 3D coordinate inputs, RGB color inputs
 *                   FEATURES: Flex row, wraps, equal components
 */

/* Expandable card - reusable for collapsible parameter sections */
.expandable-card {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-white);
  margin-bottom: var(--space-sm);
  overflow: hidden;
}

.expandable-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-light);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.expandable-card-header:hover {
  background: #e9ecef;
}

/* Modifier: horizontally scrollable header for long content */
.expandable-card-header--scrollable {
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.expandable-card-header--scrollable .expandable-card-title {
  overflow: visible;
  text-overflow: unset;
  flex-shrink: 0;
}

.expandable-card-bullet {
  font-size: var(--font-size-lg);
  color: var(--color-primary);
  line-height: 1;
  flex-shrink: 0;
}

.expandable-card-title {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--font-size-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expandable-card-controls {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  flex-shrink: 0;
}

/* Expandable card arrow - uses module color */
.expandable-card-controls .btn-icon {
  color: var(--moduleSelectionColor, var(--color-primary));
  opacity: 1;
  font-size: 10px;
  padding: 4px;
  min-width: 20px;
}

.expandable-card-controls .btn-icon::before {
  content: '\25B6';  /* ▶ Right-pointing triangle */
  display: inline-block;
  transition: transform 0.25s ease-in-out;
}

.expandable-card-controls .btn-icon.rotated::before {
  transform: rotate(90deg);  /* Rotates ▶ to point down ▼ */
}

.expandable-card-controls .btn-icon:hover {
  opacity: 0.8;
  background: transparent;
}

.expandable-card-body {
  padding: var(--space-md);
  background: var(--bg-white);
  overflow-x: auto;  /* Allow horizontal scroll for wide content */
}

.expandable-card-body[hidden] {
  display: none;
}

/* Geometry-type-specific parameter container */
.geometry-params-container {
  background: var(--bg-light);
  border: 1px solid #dee2e6;
  border-radius: var(--border-radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

/* Parameter groups within expandable cards */
.param-group {
  margin-bottom: var(--space-lg);
}

.param-group:last-child {
  margin-bottom: 0;
}

.param-group-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.param-group-title.mg-top {
  margin-top: 16px;
}

/* ========================================
   FORM ENHANCEMENTS - Specialized Form Elements
   ======================================== */

/* Large checkbox for better visibility */
.checkbox-lg {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Highlighted form group (important field) */
.form-group-highlight {
  background: #fff8e1;
  padding: var(--space-sm);
  border-radius: var(--border-radius);
  border-left: 4px solid var(--color-highlight);
}

/* Vector inputs - reusable for x,y,z coordinate triplets */
.vector-input {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
  flex-wrap: wrap;
}

.vector-component {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 70px;
}

.vector-component label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.vector-component input {
  width: 100%;
}

.vector-label {
  display: inline-block;
  min-width: 70px;
  font-weight: 600;
  margin-right: var(--space-sm);
  color: var(--text-primary);
}

/* Icon-only buttons - already defined above, enhanced here */
.btn-icon.danger:hover {
  color: var(--color-error);
  background: var(--bg-error-light);
}

.btn-icon:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon:disabled:hover {
  background: transparent;
  opacity: 0.4;
}

.card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow);
  overflow: hidden;
  width: 100%; /* Ensure cards scale to container width */
  max-width: 100%; /* Prevent cards from exceeding container */
  box-sizing: border-box; /* Include padding and border in width calculation */
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-white);
  cursor: pointer;
  user-select: none;
}

.card-header:hover {
  background: var(--bg-light);
}

.card-header h3,
.card-header h4 {
  margin: 0;
  flex: 1;
}

.card-body {
  padding: var(--space-md);
}

.card-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-color);
  background: var(--bg-light);
}

.card.expanded {
  /* No special styling needed, just for state tracking */
}

.card-content {
  padding: var(--space-md);
  display: none;
  background: var(--bg-white);
}

.card.expanded .card-content {
  display: block;
  background: var(--bg-white);
}

/* ========================================
   COLLAPSIBLE DETAILS/SUMMARY COMPONENTS
   Interactive expandable sections with visual affordance
   ======================================== */

/* Details card container */
details.details-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: var(--space-md);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

details.details-card:hover {
  box-shadow: var(--shadow);
}

details.details-card[open] {
  box-shadow: var(--shadow-hover);
}

/* Summary header - the clickable part */
details.details-card > summary {
  padding: var(--space-md);
  background: var(--bg-light);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: var(--fullrmc-accent);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: background-color var(--transition-fast);
  list-style: none; /* Remove default marker */
}

/* Remove default disclosure triangle */
details.details-card > summary::-webkit-details-marker {
  display: none;
}

details.details-card > summary::marker {
  display: none;
}

/* Add custom chevron icon */
details.details-card > summary::before {
  content: '›';
  display: inline-block;
  font-size: var(--font-size-lg);
  font-weight: bold;
  transition: transform 0.2s;
  color: var(--fullrmc-accent);
}

details.details-card[open] > summary::before {
  transform: rotate(90deg);
}

/* Hover state for summary */
details.details-card > summary:hover {
  background: #e8eaf6; /* Slightly darker on hover */
}

/* Active/pressed state */
details.details-card > summary:active {
  background: #c5cae9;
}

/* Content area when expanded */
details.details-card > .details-content {
  padding: var(--space-md);
  border-top: 1px solid var(--border-color-light);
  background: var(--bg-white);
}

/* ========================================
   STATS DISPLAY (generic)
   Used for: Session statistics, analytics, dashboards
   ======================================== */
.stats {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.stat-item {
  flex: 1;
  background: var(--bg-light);
  padding: var(--space-sm);
  border-radius: var(--border-radius);
  text-align: center;
  min-width: 120px;
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}

.stat-value {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

/* ========================================
   ALERT SYSTEM (generic)
   Used for: Warnings, errors, success messages, info boxes
   ======================================== */
.alert {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  font-size: var(--font-size-base);
}

.alert-warning {
  background: var(--bg-warning-light);
  border-color: #ffc107;
  color: var(--text-warning);
}

.alert-error {
  background: var(--bg-error-light);
  border-left: 4px solid var(--color-error);
  color: var(--color-critical);
}

.alert-success {
  background: var(--bg-success-light);
  border-color: var(--color-success);
  color: var(--text-success);
}

.alert-info {
  background: #d1ecf1;
  border-color: #2196f3;
  color: #0c5460;
}

/* Error message styling */
.error-message {
  color: var(--color-error);
  padding: var(--space-md);
  background: #f8d7da;
  border: 1px solid var(--color-error);
  border-radius: var(--border-radius);
  font-weight: 500;
}

/* Placeholder message styling */
.placeholder-message {
  text-align: center;
  color: var(--text-secondary);
  padding: var(--space-xl);
  background: var(--bg-light);
  border-radius: var(--border-radius);
  border: 2px dashed var(--border-color);
}

/* Coming soon message */
.coming-soon {
  text-align: center;
  padding: var(--space-lg);
  color: var(--text-secondary);
  font-style: italic;
}

/* ========================================
   SELECT LIST (multi-select dropdowns)
   Used for: Group lists, item lists
   ======================================== */
.select-list {
  width: 100%;
  min-height: 250px;
  max-height: 400px;
  font-family: var(--font-family-mono);  /* Monospace for aligned indexed lists */
  font-size: var(--font-size-sm);
  padding: var(--space-xs);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-white);
  overflow-y: auto;
}

/* ========================================
   MESSAGE DISPLAYS
   Used for: Flash messages, placeholders, empty states
   ======================================== */
.flash-error {
  color: var(--color-error);
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.placeholder-message {
  color: var(--text-secondary);
  padding: var(--space-md);
  text-align: center;
  background: var(--bg-light);
  border-radius: var(--border-radius);
}

/* ========================================
   INLINE LAYOUTS
   Used for: Inline checkboxes, inline form elements
   ======================================== */
.inline-checkbox-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.inline-checkbox-group .checkbox-label {
  margin-bottom: 0;
}

/* ========================================
   FORM GROUPS (generic)
   Used throughout all forms
   Note: Base .form-group styles defined in section 4 above
   ======================================== */

.form-group small {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  margin-top: 4px;
  display: block;
}

/* ========================================
   INPUT VALIDATION STATES
   Used for real-time form validation feedback
   ======================================== */
.input-wrapper {
  position: relative;
}

.input.valid {
  border-color: var(--color-success);
  background: #f1f8f4;
}

.input.invalid {
  border-color: var(--color-danger);
  background: #fff5f3;
}

.validation-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--font-size-base);
  z-index: var(--z-base);
}

.password-toggle-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 1.1rem;
  color: var(--color-text-secondary, #666);
  opacity: 0.6;
  transition: opacity 0.15s ease;
  z-index: var(--z-base);
}

.password-toggle-btn:hover {
  opacity: 1;
}

.password-toggle-btn:focus-visible {
  outline: 2px solid var(--color-focus, #0053e2);
  outline-offset: 2px;
  border-radius: 4px;
}

.input-wrapper .input.password-has-toggle {
  padding-right: 40px;
}

/* ========================================
   ALERT SYSTEM
   Used for flash messages, warnings, errors
   ======================================== */
/* ========================================
   PASSWORD STRENGTH INDICATOR
   Used for real-time password strength feedback
   ======================================== */
.password-strength {
  margin-top: 8px;
  height: 4px;
  background: #e0e0e0;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

.password-strength-fill {
  height: 100%;
  transition: width 0.3s, background 0.3s;
  width: 0;
  background: #e0e0e0;
}

.password-strength-fill.weak {
  background: var(--color-danger);
  width: 33%;
}

.password-strength-fill.medium {
  background: var(--color-highlight);
  width: 66%;
}

.password-strength-fill.strong {
  background: var(--color-success);
  width: 100%;
}

.password-strength-label {
  font-size: var(--font-size-sm);
  margin-top: 4px;
  color: var(--text-muted);
}

/* ========================================
   PASSWORD MATCH INDICATOR
   Used for password confirmation matching
   ======================================== */
.password-match {
  font-size: var(--font-size-sm);
  margin-top: 4px;
  color: var(--text-secondary);
}

.password-match.match {
  color: var(--color-success);
}

.password-match.nomatch {
  color: var(--color-danger);
}

/* ========================================
   PAGE CONTAINERS
   Centered containers for single-column pages
   ======================================== */
.auth-container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-lg);
}

/* ========================================
   PAGE HEADERS
   Standard page title and subtitle styling
   ======================================== */
.page-title {
  font-size: var(--font-size-xl);
  color: var(--text-primary);
  margin-bottom: 8px;
  font-weight: 600;
}

.page-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* ========================================
   PAGE LINKS
   Centered bottom links for navigation between pages
   ======================================== */
.auth-link {
  text-align: center;
  margin-top: 24px;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

.auth-link a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-link a:hover {
  text-decoration: underline;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-light);
  flex-wrap: nowrap;
  gap: var(--space-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.section-header:hover {
  background: #e9ecef;
}

/* Collapsible modifier - for interactive collapsible sections */
.section-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.section-content {
  padding: var(--space-md);
  overflow-x: auto; /* Allow horizontal scroll for wide content */
  max-width: 100%; /* Prevent overflow beyond card */
}

.section-content[hidden] {
  display: none;
}

/* Widget toggle content - tighter padding, aligns under toggle label */
.widget-toggle-content {
  padding: var(--space-xs) 0 var(--space-xs) var(--space-lg);
}

/* ========================================================================
 * PAGE-LEVEL COMPONENTS
 * ======================================================================== */

/* Page title - main heading for each page */
.page-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--moduleSelectionColor);
}

/* Page subtitle - secondary text (frame info, etc.) */
.page-subtitle {
  font-weight: normal;
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
}

/* Stats display boxes - used for showing key-value pairs */
.stats-box {
  background: var(--bg-light);
  padding: var(--space-md);
  border-radius: var(--border-radius);
  margin-bottom: var(--space-sm);
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.stats-box p {
  margin: var(--space-xs) 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.stats-box strong {
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Groups list - horizontal scroll if needed */
.groups-list {
  overflow-x: auto;
  overflow-y: auto;
  white-space: nowrap;
}

/* ======================================================================== */

.section-actions {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-color-light);
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.sidebar-section {
  margin-bottom: var(--space-lg);
}

.sidebar-section h4 {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
}

/* Action Groups - Grouped action buttons with labels */
.action-group {
  margin-bottom: var(--space-md);
}

.action-group:last-child {
  margin-bottom: 0;
}

.action-group-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.action-group .btn-group {
  width: 100%;
}

.action-group .btn-group .btn {
  flex: 1;
}

.action-group-danger {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-color);
}

.hint-text {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}


  z-index: var(--z-base);
  transition: height var(--transition-normal);
}

.LogDiv.minimized {
  height: 40px;
  min-height: 40px;
}

.log-content {
  height: 100%;
  overflow: auto;
  padding-top: 5px;
}

.LogDiv.minimized .log-content {
  display: none;
}

/* ===================================================
   LOG PANEL COMPONENTS
   =================================================== */

/* Log panel header - sticky at top of log panel */
.log-resize-handle {
  position: sticky;
  top: 0;
  width: 100%;
  padding: 4px 0;
  background: var(--fullrmc-bg);
  color: white;
  font-size: var(--font-size-sm);
  text-align: center;
  z-index: var(--z-sticky);
  overflow: hidden;
}

/* Log content area */
.log-content-text {
  font-size: var(--font-size-sm);
  vertical-align: text-top;
  font-family: var(--font-family-mono);
  line-height: 1.4;
  width: 100%;
  margin: 0;
  padding: 5px;
}

.LeftBar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--leftbarwidth);
  height: 100%;
  padding: 0;
  background-color: var(--leftbar-bg);
  color: var(--leftbar-text);
  overflow-y: auto;
  font-family: var(--font-family);
  font-size: var(--font-size-base) !important;
  transition: width var(--transition-normal);
  display: flex;
  flex-direction: column;
}

/* Remove dotted underlines from abbr tags in LeftBar */
.LeftBar abbr[title] {
  text-decoration: none !important;
  border-bottom: none !important;
}

/* Logo container in LeftBar */
#leftbar-logo-container {
  width: 50px;
  height: 50px;
  background: transparent;
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: var(--space-xs);
}

/* Quick links container */
#leftbar-quick-links {
  padding: var(--space-12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#leftbar-quick-links-flex {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
}

/* Quick link icons */
.quick-link-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 6px;
  transition: background-color var(--transition-fast);
}

.quick-link-icon:hover {
  background: rgba(255, 255, 255, 0.2);
}

.quick-link-icon svg {
  width: 20px;
  height: 20px;
}

/* Application Mode Selector */
#leftbar-mode-section {
  padding: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#leftbar-mode-label {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
  margin-bottom: 8px;
  display: block;
  font-weight: 600;
}

/* Account Actions Section */
#leftbar-account-section {
  padding: var(--space-12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#leftbar-account-label {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
  margin-bottom: 8px;
  display: block;
  font-weight: 600;
}

/* Standardized section labels for LeftBar */
.leftbar-section-label {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
  margin-bottom: 8px;
  display: block;
  font-weight: 600;
  font-family: var(--font-family);
  color: var(--leftbar-text);
}

/* Standardized subsection labels for LeftBar */
.leftbar-section-sublabel {
  font-size: var(--font-size-sm);
  letter-spacing: 0.3px;
  opacity: 0.9;
  margin-bottom: 8px;
  display: block;
  font-weight: 600;
  font-family: var(--font-family);
  color: var(--leftbar-text);
}

/* Lock and Shield Icons */
.lock-icon,
.shield-icon {
  cursor: pointer !important;
  transition: all var(--transition-normal);
  border-radius: var(--border-radius-lg);
  padding: var(--space-xs);
  position: relative;
}

.lock-icon:hover,
.shield-icon:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.3);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
}

.lock-icon.unlocked {
  color: var(--color-success);
}

.lock-icon.unlocked:hover {
  color: #66BB6A;
  background: rgba(76, 175, 80, 0.25);
  box-shadow: 0 0 16px rgba(76, 175, 80, 0.6);
}

.lock-icon.locked {
  color: var(--color-danger);
  animation: shake 1s ease-in-out infinite;
}

.lock-icon.locked:hover {
  color: #FF7043;
  background: rgba(255, 87, 34, 0.25);
  box-shadow: 0 0 16px rgba(255, 87, 34, 0.6);
  animation: shake 0.3s ease-in-out infinite;
}

.shield-icon.inactive {
  color: var(--color-highlight);
  animation: slowPulse 3s ease-in-out infinite;
}

.shield-icon.inactive:hover {
  color: #FFD54F;
  background: rgba(255, 193, 7, 0.25);
  box-shadow: 0 0 16px rgba(255, 193, 7, 0.6);
  animation: none;
}

.shield-icon.active {
  color: #2196F3;
  animation: pulse 1.5s ease-in-out infinite;
}

.shield-icon.active:hover {
  color: #64B5F6;
  background: rgba(33, 150, 243, 0.25);
  box-shadow: 0 0 16px rgba(33, 150, 243, 0.6);
  animation: none;
}

/* Animations */
@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  10%, 30%, 50%, 70%, 90% { transform: rotate(-8deg); }
  20%, 40%, 60%, 80% { transform: rotate(8deg); }
}

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

@keyframes slowPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ============================================ */
/* MODERN SHIELD MODAL                         */
/* ============================================ */

.shield-modal-overlay {
  backdrop-filter: blur(4px);
}

.shield-modal-modern {
  background: white;
  border-radius: var(--border-radius-xl);
  width: 500px;
  max-width: 90vw;
  position: relative;
  animation: slideUpScale 0.3s ease;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  z-index: var(--z-shield-modal);
  cursor: default;
}

@keyframes slideUpScale {
  from { 
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to { 
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.shield-modal-modern .modal-header {
  background: linear-gradient(135deg, var(--fullrmc-accent) 0%, var(--fullrmc-accent-dark) 100%);
  color: white;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shield-modal-modern .modal-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  display: flex;
  align-items: center;
  gap: var(--space-12);
  font-weight: 600;
}

.shield-modal-modern .shield-animated {
  width: 28px;
  height: 28px;
  animation: shieldPulse 2s ease-in-out infinite;
}

@keyframes shieldPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.95); }
}

.shield-modal-modern .modal-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: var(--font-size-lg);
  cursor: pointer;
  padding: var(--space-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-lg);
  transition: background 0.2s;
  font-family: var(--font-family);
  line-height: 1;
}

.shield-modal-modern .modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.shield-modal-modern .modal-body {
  padding: 32px 24px;
  color: var(--text-primary);
}

.shield-modal-modern .user-info {
  background: #f5f5f5;
  padding: var(--space-12) var(--space-md);
  border-radius: var(--border-radius-lg);
  margin-bottom: 24px;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

.shield-modal-modern .user-info strong {
  color: var(--text-primary);
}

.shield-modal-modern .form-group {
  margin-bottom: 24px;
  position: relative;
}

.shield-modal-modern label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.shield-modal-modern .input-wrapper {
  position: relative;
}

.shield-modal-modern input[type="password"],
.shield-modal-modern input[type="text"] {
  width: 100%;
  padding: 14px 40px 14px 14px;
  border: 2px solid #e0e0e0;
  border-radius: var(--border-radius-lg);
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
  font-family: var(--font-family);
  box-sizing: border-box;
}

.shield-modal-modern input:focus {
  outline: none;
  border-color: var(--fullrmc-accent);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.shield-modal-modern .toggle-visibility {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: var(--font-size-lg);
  color: var(--text-muted);
  padding: var(--space-xs);
  line-height: 1;
}

.shield-modal-modern .toggle-visibility:hover {
  color: var(--fullrmc-accent);
}

.shield-modal-modern .strength-meter {
  height: 6px;
  background: #e0e0e0;
  border-radius: var(--border-radius-sm);
  margin-top: 8px;
  overflow: hidden;
}

.shield-modal-modern .strength-fill {
  height: 100%;
  transition: width 0.3s, background 0.3s;
  border-radius: var(--border-radius-sm);
}

.shield-modal-modern .strength-fill.weak {
  background: var(--color-danger);
  width: 33%;
}

.shield-modal-modern .strength-fill.medium {
  background: var(--color-highlight);
  width: 66%;
}

.shield-modal-modern .strength-fill.strong {
  background: var(--color-success);
  width: 100%;
}

.shield-modal-modern .strength-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 4px;
}

.shield-modal-modern .warning {
  background: var(--bg-warning-light);
  border-left: 4px solid #ffc107;
  padding: var(--space-md);
  margin-bottom: 24px;
  border-radius: var(--border-radius);
}

.shield-modal-modern .warning-title {
  font-weight: 700;
  color: var(--text-warning);
  margin-bottom: 8px;
  font-size: var(--font-size-base);
}

.shield-modal-modern .warning-text {
  font-size: var(--font-size-sm);
  line-height: 1.6;
  color: var(--text-warning);
  margin: 0;
}

.shield-modal-modern .modal-actions {
  display: flex;
  gap: var(--space-12);
}

.shield-modal-modern button.modal-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--border-radius-lg);
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-family);
}

.shield-modal-modern .btn-primary {
  background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.shield-modal-modern .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

.shield-modal-modern .btn-danger {
  background: white;
  color: var(--color-danger);
  border: 2px solid var(--color-danger);
}

.shield-modal-modern .btn-danger:hover {
  background: var(--color-danger);
  color: white;
  transform: translateY(-2px);
}

/* Idle Time Countdown Progress Bars */
.countdown-bar-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.countdown-bar-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.countdown-bar-icon {
  font-size: var(--font-size-sm);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.countdown-bar-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  min-width: 42px;
  flex-shrink: 0;
}

.countdown-bar-container {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-sm);
  overflow: visible;
  position: relative;
}

.countdown-bar-fill {
  height: 100%;
  border-radius: var(--border-radius-sm);
  transition: width var(--transition-normal);
  position: absolute;
  left: 0;
  top: 0;
}

.countdown-bar-scroller {
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: right 0.3s ease;
  border: 2px solid;
}

.countdown-bar-value {
  font-size: var(--font-size-sm);
  font-weight: 700;
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

#leftbar-account-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 180px;
  margin: 0 auto;
}

.account-icon {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 6px;
  transition: background-color var(--transition-fast);
}

.account-icon:hover {
  background: rgba(255, 255, 255, 0.2);
}

.account-icon svg {
  width: 20px;
  height: 20px;
}

/* Also remove from main content if it's bleeding through */
abbr[title],
abbr {
  text-decoration: none !important;
  border-bottom: none !important;
}

.LeftBar.minimized {
  width: 50px;
  overflow: hidden;
}

.LeftBar.minimized > *:not(.leftbar-toggle-btn) {
  display: none;
}

.leftbar-toggle-btn {
  /* Position - fixed to viewport, not LeftBar container */
  position: fixed;
  left: calc(var(--leftbarwidth) - 28px);  /* Position on right edge of LeftBar */
  top: 50vh;  /* Center vertically in viewport */
  transform: translateY(-50%);
  
  /* Visual - match sidebardiv style */
  background: transparent;
  color: white;
  border: none;
  
  /* Typography */
  padding: 10px 6px;
  font-size: var(--font-size-base);
  line-height: 1;
  
  /* Interaction */
  cursor: pointer;
  z-index: var(--z-dropdown);
  opacity: 0;
  pointer-events: none;
  
  /* Text shadow for visibility */
  text-shadow:
    0 0 10px rgba(0, 0, 0, 0.9),
    0 0 20px rgba(0, 0, 0, 0.7);
  
  /* Animation */
  transition: opacity 0.3s ease, transform 0.2s ease, background 0.2s ease, left 0.3s ease;
}

.leftbar-toggle-btn.show {
  opacity: 1;
  pointer-events: auto;
}

.leftbar-toggle-btn:hover {
  background: rgba(68, 68, 68, 0.5);
  border-radius: var(--border-radius);
  transform: translateY(-50%) scale(1.1);
  text-shadow:
    0 0 15px rgba(255, 255, 255, 0.8),
    0 0 8px rgba(0, 0, 0, 0.9);
}

.leftbar-toggle-btn:focus {
  outline: 2px solid var(--moduleSelectionColor);
  outline-offset: 2px;
  opacity: 1;
}

.leftbar-toggle-btn.minimized {
  /* When LeftBar is minimized, rotate arrow and stay visible */
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateY(-50%) rotate(180deg);
  left: 22px;  /* Position on right edge of minimized LeftBar (50px - 28px) */
}

.leftbar-toggle-btn.minimized:hover {
  transform: translateY(-50%) rotate(180deg) scale(1.1);
}

.BodyDiv {
  position: absolute;
  left: var(--leftbarwidth);
  height: calc(100% - var(--topmenuheight));
  width: calc(100% - var(--leftbarwidth));
  font-family: var(--font-family);
}

.ContentDiv {
  position: fixed;
  left: var(--leftbarwidth);
  height: calc(100% - var(--logdivheight) - var(--topmenuheight));
  width: calc(100% - var(--leftbarwidth));
  z-index: var(--z-content);
}

.TopMenuBar {
  border-radius: 0 var(--border-radius-full) 0 0;
  height: var(--topmenuheight);
  position: relative;
  top: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style-type: none;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 500;
  letter-spacing: 0.3px;
  color: var(--topmenu-text);
  background-color: var(--topmenu-bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

TopMenuLi {
  float: left;
}

TopMenuLi a {
  display: block;
  font-family: var(--font-family);
  text-align: center;
  padding: 16px 20px;
  text-decoration: none;
  color: var(--topmenu-text);
  transition: background-color 0.2s ease, color 0.2s ease;
  border-bottom: 3px solid transparent;
}

TopMenuLi a:hover:not(.active) {
  background-color: rgba(0, 0, 0, 0.2);
  border-bottom-color: rgba(255, 255, 255, 0.3);
}

TopMenuLi a.active {
  /* Top menu active tab follows layout-mode accent, not UI primary */
  /* Fallback colors in order of priority */
  background-color: var(--color-success); /* Default green */
  background-color: var(--moduleSelectionColor, var(--color-success)) !important;
  border-bottom-color: rgba(255, 255, 255, 0.8) !important;
  font-weight: 600 !important;
  color: white !important;
}

.menu-toggle {
  display: none;
  background-color: var(--leftbar-bg);
  border: none;
  color: var(--leftbar-text);
  font-size: var(--font-size-xl);
  font-weight: bold;
  cursor: pointer;
  padding: 12px 20px;
  margin: 0;
  line-height: 1;
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: var(--z-modal-backdrop);
  border-radius: var(--border-radius);
  transition: background-color var(--transition-normal);
}

.menu-toggle:hover {
  background: var(--moduleSelectionColor, var(--color-success));
}

.menu-toggle:focus {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.hamburger-dropdown {
  position: fixed;
  /* Position is set dynamically by JS (positionDropdownUnderButton in layout.js) */
  /* Fallback values in case JS fails - safe defaults for mobile */
  top: 60px;
  left: 10px;
  background-color: var(--leftbar-bg);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.8);
  z-index: var(--z-popover);
  min-width: 250px;
  max-width: calc(100vw - 20px);  /* Prevent overflow on narrow screens */
  max-height: 80vh;
  overflow-y: auto;
  padding: 5px 0;
}

.hamburger-dropdown-item {
  display: block;
  padding: 12px 20px;
  color: var(--leftbar-text);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: background-color var(--transition-fast);
}

.hamburger-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.hamburger-dropdown-item.active {
  background: var(--moduleSelectionColor, var(--color-success));
}

.LogDiv {
  position: fixed;
  left: var(--leftbarwidth);
  bottom: 0;
  border: 2px solid var(--text-primary);
  padding-left: 2px;
  padding-right: 2px;
  margin-left: 2px;
  margin-right: 2px;
  width: calc(100% - var(--leftbarwidth));
  height: var(--logdivheight);
  min-height: var(--logdivheight);
  font-family: var(--font-family);
  overflow: hidden;
  z-index: var(--z-base);
  transition: height var(--transition-normal);
}

.LogDiv.minimized {
  height: 40px;
  min-height: 40px;
}

.log-content {
  height: 100%;
  overflow: auto;
  padding-top: 5px;
}

.LogDiv.minimized .log-content {
  display: none;
}

/* ===================================================
   LOG PANEL COMPONENTS
   =================================================== */

/* Log panel header - sticky at top of log panel */
.log-resize-handle {
  position: sticky;
  top: 0;
  width: 100%;
  padding: 4px 0;
  background: var(--fullrmc-bg);
  color: white;
  font-size: var(--font-size-sm);
  text-align: center;
  z-index: var(--z-sticky);
  overflow: hidden;
}

/* Log content area */
.log-content-text {
  font-size: var(--font-size-sm);
  vertical-align: text-top;
  font-family: var(--font-family-mono);
  line-height: 1.4;
  width: 100%;
  margin: 0;
  padding: 5px;
}

.overlay {
  position: fixed;
  display: none;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  z-index: var(--z-shield-backdrop);
  align-items: center;
  justify-content: center;
}

.log-toggle-btn {
  position: fixed;
  right: 15px;
  bottom: calc(var(--logdivheight) - 31px);
  background: transparent;
  color: white;
  border: none;
  padding: 6px 8px;
  font-size: var(--font-size-base);
  line-height: 1;
  cursor: pointer;
  z-index: var(--z-overlay);
  opacity: 0;
  transition: all var(--transition-normal);
  text-shadow:
    0 0 10px rgba(0, 0, 0, 0.9),
    0 0 20px rgba(0, 0, 0, 0.7);
}

.log-toggle-btn.show {
  opacity: 1;
}

.log-toggle-btn:hover {
  background: rgba(68, 68, 68, 0.5);
  border-radius: var(--border-radius);
  transform: scale(1.1);
}

.log-toggle-btn:focus {
  outline: 2px solid var(--moduleSelectionColor);
  outline-offset: 2px;
  opacity: 1;
}

.log-toggle-btn.minimized {
  transform: rotate(180deg);
  opacity: 1;
}

.log-toggle-btn.minimized:hover {
  transform: rotate(180deg) scale(1.1);
}

.modeSelector {
  width: 250px;
  height: 40px;
  background-color: var(--moduleSelectionColor);
  border: 10px solid transparent;
  color: white;
  font-size: var(--font-size-base) !important;
  border-radius: var(--border-radius-lg);
  font-family: var(--font-family);
}

.log-toggle-btn:focus {
  outline: 2px solid var(--moduleSelectionColor);
  outline-offset: 2px;
  opacity: 1;
}

.log-toggle-btn.minimized {
  transform: rotate(180deg);
  opacity: 1;
}

.log-toggle-btn.minimized:hover {
  transform: rotate(180deg) scale(1.1);
}


/**********************************************
 * 7. SIDEBAR (RIGHT) LAYOUT: SidebarDiv + SubcontentDiv
 **********************************************/

/* Generic base layout for SubcontentDiv. Individual pages can override
   (e.g. to reserve space for a sidebar) in their own CSS. */
.SubcontentDiv {
  float: left;
  padding: var(--space-10);
  width: 100%;
  min-width: 100px;  /* Prevent extreme narrowing */
  height: 100%;
  overflow: auto;
  background: var(--content-bg);  /* Explicit background - no browser default reliance */
}

/* Note: JS can add the class "sidebardiv-paired" to SubcontentDiv
   when a SidebarDiv is present on the page. */

.SubcontentDiv.sidebardiv-paired {
  width: calc(100% - var(--sidebardivwidth));
  min-width: 100px;  /* Prevent collapse when window very narrow */
  transition: none;
}

.SidebarDiv {
  position: absolute;
  padding: var(--space-10);
  width: var(--sidebardivwidth);
  height: 100%;
  left: calc(100% - var(--sidebardivwidth));
  border-left: double 4px var(--text-primary);
  overflow-y: auto;
  overflow-x: hidden;
  transition: none;
  z-index: var(--z-sidebar);  /* Above LogDiv and ContentDiv */
  background: var(--content-bg);  /* Explicit background - matches SubcontentDiv */
}

body.sidebardiv-transitions-enabled .SubcontentDiv.sidebardiv-paired {
  transition: width var(--transition-normal);
}

body.sidebardiv-transitions-enabled .SidebarDiv {
  transition: width var(--transition-normal);
}

.SidebarDiv.minimized {
  width: 0 !important;
  overflow: hidden;
  padding: 0 !important;
  border: none !important;
  min-width: 0 !important;
  left: 100% !important;  /* Move completely off-screen */
}

.sidebardiv-toggle-btn {
  position: fixed;
  right: calc(var(--sidebardivwidth) - 35px);
  top: 50vh;
  transform: translateY(-50%);
  background: transparent;
  color: white;
  border: none;
  padding: 10px 6px;
  font-size: var(--font-size-base);
  line-height: 1;
  cursor: pointer;
  z-index: var(--z-dropdown);
  opacity: 0;
  pointer-events: none;
  text-shadow:
    0 0 10px rgba(0, 0, 0, 0.9),
    0 0 20px rgba(0, 0, 0, 0.7);
}

.sidebardiv-toggle-btn.show {
  opacity: 1;
  pointer-events: auto;
}

.sidebardiv-toggle-btn:hover {
  background: rgba(68, 68, 68, 0.5);
  border-radius: var(--border-radius);
  transform: translateY(-50%) scale(1.1);
  text-shadow:
    0 0 15px rgba(255, 255, 255, 0.8),
    0 0 8px rgba(0, 0, 0, 0.9);
}

.sidebardiv-toggle-btn:focus {
  outline: 2px solid var(--moduleSelectionColor);
  outline-offset: 2px;
  opacity: 1;
}

.sidebardiv-toggle-btn.minimized {
  opacity: 1 !important;
  right: 15px;
  pointer-events: auto !important;
}

.sidebardiv-toggle-btn.minimized:hover {
  transform: translateY(-50%) scale(1.1);
}

/* ========================================
 * SCREEN MODE STYLES
 * ========================================
 * 
 * Uses [data-screen-mode] attribute set by JavaScript.
 * Two modes: 'desktop' and 'mobile'
 * 
 * Desktop: Side panels, floating toggle buttons (hover)
 * Mobile: Takeover mode, TopMenuBar toggle buttons
 * 
 * BREAKPOINT: 768px OR (hover: none)
 * ======================================== */

/* ----------------------------------------
 * TopMenuBar Panel Toggle Buttons
 * ---------------------------------------- */

/* Base styles for TopMenuBar toggle buttons */
.topbar-panel-toggle {
  display: none;  /* Hidden by default (desktop) */
}

.topbar-leftbar-toggle,
.topbar-sidebar-toggle {
  display: none;  /* Hidden by default, shown via JS in mobile mode */
  background: transparent;
  border: none;
  color: white;
  font-size: 20px;
  font-weight: bold;
  padding: 12px 16px;
  margin: 0;
  line-height: 1;
  cursor: pointer;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: var(--z-modal-backdrop);  /* Same as hamburger */
  border-radius: var(--border-radius);
  transition: background-color var(--transition-normal);
}

/* LeftBar toggle - positioned after hamburger */
.topbar-leftbar-toggle {
  left: 60px;  /* After hamburger button */
}

/* Sidebar toggle - positioned on right side */
.topbar-sidebar-toggle {
  right: 10px;
}

.topbar-leftbar-toggle:hover,
.topbar-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.topbar-leftbar-toggle:focus,
.topbar-sidebar-toggle:focus {
  outline: 2px solid var(--moduleSelectionColor);
  outline-offset: 2px;
}

/* ----------------------------------------
 * DESKTOP MODE
 * ---------------------------------------- */

[data-screen-mode="desktop"] .topbar-panel-toggle {
  display: none;  /* Hide TopMenuBar toggle buttons */
}

[data-screen-mode="desktop"] .leftbar-toggle-btn,
[data-screen-mode="desktop"] .sidebardiv-toggle-btn {
  /* Floating buttons: keep default behavior (opacity controlled by .show class) */
}

/* ----------------------------------------
 * MOBILE MODE
 * ---------------------------------------- */

[data-screen-mode="mobile"] .topbar-panel-toggle {
  display: block;  /* Show TopMenuBar toggle buttons */
}

[data-screen-mode="mobile"] .leftbar-toggle-btn,
[data-screen-mode="mobile"] .sidebardiv-toggle-btn {
  display: none;  /* Hide floating buttons */
}

/* Adjust main layout containers for mobile */
[data-screen-mode="mobile"] .BodyDiv {
  left: 0 !important;
  width: 100% !important;
}

[data-screen-mode="mobile"] .ContentDiv {
  left: 0 !important;
  width: 100% !important;
}

[data-screen-mode="mobile"] .LogDiv {
  left: 0 !important;
  width: 100% !important;
}

/* ----------------------------------------
 * MOBILE MODE: LeftBar Takeover
 * ---------------------------------------- */

/* Default: LeftBar hidden on mobile */
[data-screen-mode="mobile"] .LeftBar {
  position: fixed;
  top: var(--topmenuheight, 50px);
  left: 0;
  width: 0;
  height: calc(100vh - var(--topmenuheight, 50px) - var(--logdivheight, 100px));
  overflow: hidden;
  transition: width 0.3s ease;
  z-index: var(--z-modal, 1000);
  background: var(--leftbar-bg);
}

/* Expanded: LeftBar takes over SubcontentDiv */
[data-screen-mode="mobile"] .LeftBar.mobile-expanded {
  width: 100% !important;
  overflow-y: auto;
}

/* Hide minimized state styling on mobile */
[data-screen-mode="mobile"] .LeftBar.minimized {
  width: 0 !important;
}

/* ----------------------------------------
 * MOBILE MODE: SidebarDiv Takeover
 * ---------------------------------------- */

/* Default: SidebarDiv hidden on mobile */
[data-screen-mode="mobile"] .SidebarDiv {
  position: fixed;
  top: var(--topmenuheight, 50px);
  right: 0;
  width: 0;
  padding: 0;  /* Prevent padding sliver when collapsed */
  height: calc(100vh - var(--topmenuheight, 50px) - var(--logdivheight, 100px));
  overflow: hidden;
  transition: width 0.3s ease, padding 0.3s ease;
  z-index: var(--z-modal, 1000);
  background: var(--content-bg);
  border-left: none !important;
}

/* Expanded: SidebarDiv takes over SubcontentDiv */
[data-screen-mode="mobile"] .SidebarDiv.mobile-expanded {
  width: 100% !important;
  padding: var(--space-10);  /* Restore padding when visible */
  overflow-y: auto;
  left: 0;
  right: 0;
}

/* SubcontentDiv full width on mobile */
[data-screen-mode="mobile"] .SubcontentDiv {
  width: 100% !important;
  float: none !important;
}

[data-screen-mode="mobile"] .SubcontentDiv.sidebardiv-paired {
  width: 100% !important;
}

/* ----------------------------------------
 * CSS FALLBACK (before JS runs)
 * ---------------------------------------- */

@media (max-width: 768px), (hover: none) {
  /* Fallback if data-screen-mode not set yet */
  html:not([data-screen-mode]) .topbar-panel-toggle {
    display: block;
  }
  
  html:not([data-screen-mode]) .leftbar-toggle-btn,
  html:not([data-screen-mode]) .sidebardiv-toggle-btn {
    display: none;
  }
  
  html:not([data-screen-mode]) .LeftBar {
    width: 0 !important;
    overflow: hidden !important;
  }
  
  html:not([data-screen-mode]) .BodyDiv,
  html:not([data-screen-mode]) .ContentDiv,
  html:not([data-screen-mode]) .LogDiv {
    left: 0 !important;
    width: 100% !important;
  }
}

/* ========================================
 * LEFTBAR CHILD COMPONENTS
 * Styling for elements inside .LeftBar
 * ======================================== */

/* Header Section */
.leftbar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.leftbar-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.leftbar-version-container {
  flex: 1;
  min-width: 0;
}

.leftbar-version-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.leftbar-version-number {
  font-size: 12px;
  opacity: 0.8;
  font-weight: 400;
}

.leftbar-links {
  display: flex;
  gap: 8px;
  font-size: 11px;
}

.leftbar-link {
  color: #64B5F6;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}

.leftbar-link:hover {
  color: #90CAF9;
  text-decoration: underline;
}

/* Mode Selector */
.mode-selector {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius);
  color: white;
  font-size: var(--font-size-sm);
  cursor: pointer;
  font-family: var(--font-family);
  line-height: 1.6;
  height: auto;
}

.mode-selector option {
  background: #2c3e50;
  color: white;
}

/* Session Info Section */
.leftbar-session-info {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex: 1;
  min-height: 400px;
  overflow-y: auto;
}

.leftbar-session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.leftbar-session-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.leftbar-session-header-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

.leftbar-section-label--no-margin {
  margin-bottom: 0 !important;
}

.leftbar-section-sublabel--no-margin {
  margin-bottom: 0 !important;
}

/* Icon Links and Buttons */
.leftbar-icon-link {
  position: relative;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.leftbar-icon-link:hover svg {
  transform: translateY(-2px);
}

.leftbar-icon-svg {
  transition: all 0.3s ease;
}

.leftbar-icon-container {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.leftbar-icon-button {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background: transparent;
  transition: all 0.2s;
  padding: 0;
}

.leftbar-icon-button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.leftbar-badge {
  position: absolute;
  top: -6px;
  right: -12px;
  background: #FF5722;
  color: white;
  border-radius: 8px;
  padding: 2px 5px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  border: 2px solid #2c3e50;
}

/* Session Stats */
.leftbar-session-stats {
  font-size: 12px;
  line-height: 1.8;
  opacity: 0.95;
}

.leftbar-stat-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leftbar-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.leftbar-stat-value {
  font-weight: 600;
  color: #4CAF50;
  font-size: 13px;
}

.leftbar-stat-details {
  margin-left: 12px;
  font-size: 11px;
  line-height: 1.8;
}

.leftbar-stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}

.leftbar-progress-bar {
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
}

.leftbar-cpu-indicator {
  width: 5px;
  height: 14px;
  background: #666;
  border-radius: 2px;
  transition: background 0.3s ease;
}

/* ========================================
   COLLAPSIBLE SECTIONS
   ======================================== */

.Collapsible {
  background-color: var(--leftbar-bg);
  color: var(--leftbar-text);
  cursor: pointer;
  padding: var(--space-xs);
  width: 300px;
  border: none;
  text-align: left;
  outline: none;
  font-size: var(--font-size-lg);
  display: block;
  transition: background-color var(--transition-normal);
  font-family: var(--font-family);
}

.Collapsible_1 {
  background-color: var(--leftbar-bg);
  color: var(--leftbar-text);
  cursor: pointer;
  padding: var(--space-xs);
  width: calc(100% - 2px);
  border: none;
  text-align: left;
  outline: none;
  font-size: var(--font-size-lg);
  display: block;
  transition: background-color var(--transition-normal);
  font-family: var(--font-family);
}

.Collapsible:hover,
.Collapsible:focus {
  background: var(--moduleSelectionColor, var(--color-success)) !important;
  outline: none;
}

.Collapsible.active,
.Collapsible.active:hover,
.Collapsible.active:focus {
  background: var(--moduleSelectionColor, var(--color-success)) !important;
  color: var(--leftbar-text) !important;
}

.Collapsible_1:hover,
.Collapsible_1:focus {
  background: var(--moduleSelectionColor, var(--color-success)) !important;
  outline: none;
}

.Collapsible_1.active,
.Collapsible_1.active:hover,
.Collapsible_1.active:focus {
  background: var(--moduleSelectionColor, var(--color-success)) !important;
  color: var(--leftbar-text) !important;
}

.CollapsibleContent {
  padding: 0 14px;
  display: none;
  width: 100%;
  overflow: hidden;
  background-color: #f1f1f1;
}

/**********************************************
 * WARPING SECTION GROUPING
 **********************************************/

.warping-section {
  background: rgba(33, 150, 243, 0.02); /* Subtle blue tint */
  padding: var(--space-md);
  border-radius: var(--border-radius);
  margin: var(--space-md) 0;
  border-left: 3px solid var(--primary-color);
  transition: background-color var(--transition-fast);
}

.warping-section:hover {
  background: rgba(33, 150, 243, 0.04);
}

.warping-section-title {
  font-weight: 500;
  margin-bottom: var(--space-sm);
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-base);
}

/* Remove bottom margin from last form-group in warping section */
.warping-section .form-group:last-child {
  margin-bottom: 0;
}

/**********************************************
 * HELP SYSTEM - Icons & Popovers
 **********************************************/

/* Help Icon */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3498db;
  color: white;
  font-size: var(--font-size-sm);
  font-weight: bold;
  cursor: pointer;
  margin-left: 4px;
  user-select: none;
  transition: all 0.2s ease;
  vertical-align: middle;
}

.help-icon:hover {
  background: #2980b9;
  transform: scale(1.1);
}

/* Larger help icon for use in headings */
.help-icon-lg,
h1 .help-icon,
h2 .help-icon,
h3 .help-icon,
h4 .help-icon {
  width: 18px;
  height: 18px;
  font-size: var(--font-size-base);
}

/* Help Popover */
.help-popover {
  position: fixed;
  z-index: var(--z-modal);
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  width: 500px;
  max-width: calc(100vw - 40px);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.help-popover.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* Popover Arrow (using ::before pseudo-element) */
.help-popover::before {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border: 8px solid transparent;
}

/* Arrow positioning for different placements */
.help-popover:not(.above):not(.left):not(.right):not(.center)::before {
  /* Below (default) - arrow on top */
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  border-bottom-color: white;
}

.help-popover.above::before {
  /* Above - arrow on bottom */
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  border-top-color: white;
}

.help-popover.left::before {
  /* Left - arrow on right */
  right: -16px;
  top: 50%;
  transform: translateY(-50%);
  border-left-color: white;
}

.help-popover.right::before {
  /* Right - arrow on left */
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  border-right-color: white;
}

.help-popover.center::before {
  /* Center - no arrow */
  display: none;
}

/* Popover Header */
.help-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-12) var(--space-md);
  border-bottom: 1px solid #e9ecef;
  background: var(--bg-light);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.help-popover-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--fullrmc-bg);
}

.help-popover-title > span:first-child {
  font-size: var(--font-size-base);
}

.help-popover-close {
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  line-height: 1;
  color: #6c757d;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  transition: all 0.2s ease;
}

.help-popover-close:hover {
  background: #dee2e6;
  color: var(--fullrmc-bg);
}

/* Popover Content */
.help-popover-content {
  padding: var(--space-md);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: #495057;
  max-height: 400px;
  overflow-y: auto;
}

.help-popover-content p {
  margin: 0 0 12px 0;
}

.help-popover-content p:last-child {
  margin-bottom: 0;
}

.help-popover-content ul,
.help-popover-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.help-popover-content li {
  margin: 4px 0;
}

.help-popover-content code {
  background: var(--bg-light);
  padding: 2px 6px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  color: #e83e8c;
}

.help-popover-content pre {
  background: var(--bg-light);
  padding: var(--space-sm);
  border-radius: var(--border-radius);
  overflow-x: auto;
  font-size: var(--font-size-sm);
  line-height: 1.4;
  margin: 8px 0;
  /* ASCII art support - preserve whitespace and use monospace font */
  white-space: pre !important;
  font-family: var(--font-family-mono, 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace) !important;
  /* Prevent text wrapping that would break ASCII art alignment */
  word-wrap: normal;
  word-break: normal;
}

/* Specific class for ASCII art diagrams - maximum specificity */
.help-popover-content pre.ascii-art {
  white-space: pre !important;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace !important;
  line-height: 1.2 !important;
  letter-spacing: 0 !important;
  word-spacing: 0 !important;
  tab-size: 4 !important;
}

/* ASCII diagram using divs for guaranteed line breaks */
.help-popover-content .ascii-diagram {
  background: var(--bg-light);
  padding: var(--space-sm);
  border-radius: var(--border-radius);
  margin: 8px 0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace !important;
  font-size: var(--font-size-sm);
  line-height: 1.2;
  overflow-x: auto;
}

.help-popover-content .ascii-diagram div {
  white-space: pre !important;
  font-family: inherit;
  margin: 0;
  padding: 0;
}

.help-popover-content strong {
  font-weight: 600;
  color: var(--fullrmc-bg);
}

/* Help Section (within popover content) */
.help-popover-section {
  margin: 12px 0;
}

.help-popover-section:first-child {
  margin-top: 0;
}

.help-popover-section:last-child {
  margin-bottom: 0;
}

.help-popover-section-title {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: #495057;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e9ecef;
}

/* Scrollbar styling for popover content */
.help-popover-content::-webkit-scrollbar {
  width: 6px;
}

.help-popover-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: var(--border-radius-sm);
}

.help-popover-content::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: var(--border-radius-sm);
}

.help-popover-content::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .help-popover {
    max-width: calc(100vw - 32px);
    min-width: 260px;
  }
  
  .help-popover-content {
    max-height: 300px;
  }
}

/**********************************************
 * GROUPS PAGE COMPONENTS
 **********************************************/

/* Button group - horizontal button container */
.button-group {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.button-group > .btn {
  flex: 1;
}

/* Help text - muted instructional text */
.help-text {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin: var(--space-sm) 0;
  font-style: italic;
}

/**********************************************
 * FLEXBOX UTILITIES
 **********************************************/

/* Flex sizing utilities */
.flex-1 {
  flex: 1;
}

/* Flex row layouts with different gaps */
.flex-row-xs {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
}

.flex-row-sm {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.flex-row-md {
  display: flex;
  gap: var(--space-md);
}

/**********************************************
 * VECTOR INPUT COMPONENTS (Geometrical Groups)
 **********************************************/

/* Label for vector components (X, Y, Z) */
.vector-label {
  margin: 0;
  min-width: 20px;
  flex-shrink: 0;
  font-weight: normal;
  font-size: var(--font-size-sm);
}

/* Wide label variant for longer text */
.vector-label-wide {
  margin: 0;
  min-width: 60px;
  flex-shrink: 0;
  font-weight: 500;
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

/* Input field for vector components */
.vector-input-field {
  flex: 1;
  min-width: 60px;
}

/**********************************************
 * UTILITY CLASSES
 **********************************************/

/* Font weight utilities */
.font-normal {
  font-weight: normal !important;
}

/* Width constraints */
.max-w-150 {
  max-width: 150px;
}

/* Margin utilities (extend existing) */
.mg-bottom-none { margin-bottom: 0; }

/* ============================================================================
 * COMPACT PLOT PARAMETERS
 * Ultra-compact form controls for constraint plot parameter forms
 * Used in: Server-generated plot parameter HTML (utils.py)
 * ============================================================================ */

/* Small number inputs (60px) - for numeric parameters */
.plot-input-sm {
  height: 21px;
  width: 60px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 2px 4px;
  box-sizing: border-box;
}

/* Medium text inputs (60%) - for labels and text */
.plot-input-md {
  height: 21px;
  width: 60%;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 2px 4px;
  box-sizing: border-box;
}

/* Wide number inputs (70px) - for limits */
.plot-input-wide {
  height: 21px;
  width: 70px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 2px 4px;
  box-sizing: border-box;
}

/* Select dropdowns (50% width) */
.plot-select {
  height: 21px;
  width: calc(50%);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 1px 4px;
  box-sizing: border-box;
  line-height: 19px;
  vertical-align: middle;
}

.plot-select option {
  font-size: var(--font-size-sm);
  padding: 2px;
}

/* Wide select dropdowns (60% width) */
.plot-select-wide {
  height: 21px;
  width: calc(60%);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 1px 4px;
  line-height: 19px;
  vertical-align: middle;
}

.plot-select-wide option {
  font-size: var(--font-size-sm);
  padding: 2px;
}

/* Narrow select dropdowns (30% width) */
.plot-select-narrow {
  height: 21px;
  width: calc(30%);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 1px 4px;
  line-height: 19px;
  vertical-align: middle;
}

.plot-select-narrow option {
  font-size: var(--font-size-sm);
  padding: 2px;
}

/* Color picker inputs */
.plot-color-picker {
  height: 21px;
  width: 40px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  vertical-align: middle;
}

/* Section toggle (replaces old rounded_toggle pattern) */
.plot-section-toggle {
  display: inline-block;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: var(--font-size);
  user-select: none;
  margin: 4px 0;
  line-height: 20px;
}

.plot-section-toggle:hover {
  opacity: 0.8;
}

/* Toggle arrow (replaces inline style arrow) */
.toggle-arrow {
  color: var(--moduleSelectionColor);
  cursor: pointer;
  font-size: var(--font-size-sm);
  display: inline-block;
  width: 12px;
  transition: transform 0.2s ease;
}

.toggle-arrow.rotated {
  transform: rotate(90deg);
}

/* Toggle label */
.toggle-label {
  font-weight: 500;
  margin-left: 4px;
  font-family: var(--font-family);
}

/* Inline help icon (ultra-compact for plot params) */
.help-icon-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  line-height: 12px;
  text-align: center;
  background-color: var(--info-color, #3498db);
  color: white;
  border-radius: 50%;
  font-size: var(--font-size-sm);
  font-weight: bold;
  margin-left: 6px;
  cursor: help;
  vertical-align: middle;
  font-family: var(--font-family);
}

.help-icon-inline:hover {
  background-color: var(--info-color-dark, #2980b9);
  transform: scale(1.1);
}

/* Inline labels (for compact forms) */
.inline-label-sm {
  display: inline-block;
  width: 10px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
}

.inline-label-md {
  display: inline-block;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  margin-right: 4px;
}

/* Plot parameter checkboxes */
.plot-checkbox {
  vertical-align: middle;
  margin: 0 4px;
}
/**********************************************
 * ENGINE STATUS COMPONENTS
 **********************************************/

/* Stat group - container for related statistics
 * USAGE: <div class="stat-group">...</div>
 * USED IN: Engine status sidebar, runtime monitoring
 */
.stat-group {
  margin-bottom: var(--space-md);
}

/* Stat group title - section header within stats
 * USAGE: <div class="stat-group-title">Run Datetime</div>
 */
.stat-group-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--bg-light);
}

/* Stat row - individual metric display (label + value)
 * USAGE: <div class="stat-row">
 *          <span class="stat-row-label">Start</span>
 *          <span class="stat-row-value">10:30:00</span>
 *        </div>
 */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-color-light);
}

.stat-row:last-child {
  border-bottom: none;
}

/* Stat row label - left side (metric name) */
.stat-row-label {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  flex-shrink: 0;
  margin-right: var(--space-md);
}

/* Stat row value - right side (metric value) */
.stat-row-value {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--font-size-base);
  text-align: right;
  word-break: break-word;
}

/* Current/active stat values - highlighted */
.stat-row-value.current {
  color: var(--color-info);
  font-size: var(--font-size-base);
  font-weight: 700;
}

/* Engine state badge container */
.engine-state-badge {
  margin-bottom: var(--space-md);
}

/* Engine State Gradient Pill - Modern status indicator */
.engine-state-pill {
  display: inline-block;
  padding: 6px 16px;
  border-radius: var(--border-radius-xl);
  font-weight: 600;
  font-size: var(--font-size-base);
  color: white;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all var(--transition-normal);
  margin-bottom: var(--space-sm);
}

/* Running state - Green gradient */
.engine-state-pill.running {
  background: linear-gradient(135deg, var(--color-success) 0%, #66bb6a 100%);
  box-shadow: 0 2px 12px rgba(76, 175, 80, 0.4);
}

/* Idle state - Gray gradient */
.engine-state-pill.idle {
  background: linear-gradient(135deg, #9e9e9e 0%, #bdbdbd 100%);
  box-shadow: 0 2px 8px rgba(158, 158, 158, 0.3);
}

/* Error state - Red gradient */
.engine-state-pill.error {
  background: linear-gradient(135deg, #f44336 0%, #ef5350 100%);
  box-shadow: 0 2px 12px rgba(244, 67, 54, 0.4);
}

/* Stopping/Warning state - Orange gradient */
.engine-state-pill.warning {
  background: linear-gradient(135deg, #ff9800 0%, #ffa726 100%);
  box-shadow: 0 2px 12px rgba(255, 152, 0, 0.4);
}

/* Optimizing state - Blue gradient */
.engine-state-pill.optimizing {
  background: linear-gradient(135deg, #2196f3 0%, #42a5f5 100%);
  box-shadow: 0 2px 12px rgba(33, 150, 243, 0.4);
}

/* Context line below pill */
.engine-state-context {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
  margin-bottom: var(--space-md);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.engine-state-context::before {
  content: '▸';
  color: var(--color-info);
  font-weight: 700;
}

/* Subtle pulse animation for running state */
@keyframes pill-pulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(76, 175, 80, 0.4); }
  50% { box-shadow: 0 2px 16px rgba(76, 175, 80, 0.6); }
}

.engine-state-pill.running {
  animation: pill-pulse 2s ease-in-out infinite;
}

/* ========================================
 * LOADING SPINNER ANIMATION
 * ======================================== */

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

/* Basic spinner component */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--bg-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Small spinner (for buttons) */
.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

/* Large spinner (for full-page loading) */
.spinner-lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

/* ========================================
 * BUTTON LOADING STATE
 * ======================================== */

/* Button with loading spinner */
.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Loading button variants - inherit button color */
.btn-primary.loading::after,
.btn-success.loading::after,
.btn-danger.loading::after,
.btn-warning.loading::after,
.btn-info.loading::after,
.btn-critical.loading::after {
  border-color: var(--text-white);
  border-top-color: transparent;
}

/* ========================================
 * FULL-PAGE LOADING OVERLAY
 * ======================================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.loading-overlay .spinner {
  width: 64px;
  height: 64px;
  border-width: 6px;
  border-color: var(--bg-white);
  border-top-color: var(--color-primary);
}

.loading-overlay .loading-message {
  color: rgba(255, 255, 255, 0.95);
  font-size: 16px;
  font-weight: 500;
  margin-top: 20px;
  text-align: center;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  max-width: min(80%, 400px);
}

/* Runtime hook button group */
.runtime-hook-buttons {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

/**********************************************
 * UTILITY CLASSES
 * 
 * Generic, reusable utility classes for common
 * layout patterns. Use these instead of inline
 * styles or page-specific duplicates.
 **********************************************/

/* ========================================
 * SPACING UTILITIES (using CSS variables)
 * ======================================== */

/* Margin Bottom */
.mb-xs { margin-bottom: var(--space-xs); }  /* 4px */
.mb-sm { margin-bottom: var(--space-sm); }  /* 8px */
.mb-md { margin-bottom: var(--space-md); }  /* 16px */
.mb-lg { margin-bottom: var(--space-lg); }  /* 24px */
.mb-xl { margin-bottom: var(--space-xl); }  /* 32px */

/* Margin Top */
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

/* Margin Y-axis (top and bottom) */
.my-xs { margin-top: var(--space-xs); margin-bottom: var(--space-xs); }
.my-sm { margin-top: var(--space-sm); margin-bottom: var(--space-sm); }
.my-md { margin-top: var(--space-md); margin-bottom: var(--space-md); }
.my-lg { margin-top: var(--space-lg); margin-bottom: var(--space-lg); }

/* Margin Zero */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* Margin Left */
.ml-xs { margin-left: var(--space-xs); }
.ml-sm { margin-left: var(--space-sm); }
.ml-md { margin-left: var(--space-md); }
.ml-lg { margin-left: var(--space-lg); }
.ml-xl { margin-left: var(--space-xl); }

/* Margin Right */
.mr-xs { margin-right: var(--space-xs); }
.mr-sm { margin-right: var(--space-sm); }
.mr-md { margin-right: var(--space-md); }
.mr-lg { margin-right: var(--space-lg); }
.mr-xl { margin-right: var(--space-xl); }

/* Margin X-axis (left and right) */
.mx-xs { margin-left: var(--space-xs); margin-right: var(--space-xs); }
.mx-sm { margin-left: var(--space-sm); margin-right: var(--space-sm); }
.mx-md { margin-left: var(--space-md); margin-right: var(--space-md); }
.mx-lg { margin-left: var(--space-lg); margin-right: var(--space-lg); }
.mx-xl { margin-left: var(--space-xl); margin-right: var(--space-xl); }

/* ========================================
 * FLEXBOX UTILITIES
 * ======================================== */

/* Flex Container */
.flex { display: flex; }
.flex-inline { display: inline-flex; }

/* Flex Direction */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }

/* Flex Item Sizing */
.flex-1 { flex: 1; }
.flex-auto { flex: auto; }
.flex-none { flex: none; }

/* Alignment */
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

/* Gap */
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* ========================================
 * GRID UTILITIES
 * ======================================== */

/* Grid Containers */
.grid { display: grid; }
.grid-2col { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: var(--space-sm);
}
.grid-3col { 
  display: grid; 
  grid-template-columns: 1fr 1fr 1fr; 
  gap: var(--space-sm);
}
.grid-4col { 
  display: grid; 
  grid-template-columns: 1fr 1fr 1fr 1fr; 
  gap: var(--space-sm);
}

/* ========================================
 * VISIBILITY UTILITIES
 * ======================================== */

.hidden { display: none; }
.visible { display: block; }

/* ========================================
 * WIDTH UTILITIES
 * ======================================== */

/* Percentage widths */
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-screen { width: 100vw; }
.w-50 { width: 50%; }
.w-33 { width: 33.333%; }
.w-25 { width: 25%; }

/* Fixed pixel widths (common form control sizes) */
.w-50px { width: 50px; }
.w-60px { width: 60px; }
.w-75px { width: 75px; }
.w-80px { width: 80px; }
.w-100px { width: 100px; }
.w-150px { width: 150px; }
.w-200px { width: 200px; }
.w-250px { width: 250px; }
.w-300px { width: 300px; }
.w-325px { width: 325px; }

/* Min-width utilities */
.min-w-75px { min-width: 75px; }
.min-w-200px { min-width: 200px; }

/* Min-height utilities */
.min-h-500px { min-height: 500px; }

/* Special width patterns */
.w-full-minus-border { width: calc(100% - 2px); }
.w-full-minus-65px { width: calc(100% - 65px); }
.w-full-minus-100px { width: calc(100% - 100px); }

/* ========================================
 * TEXT UTILITIES
 * ======================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-bold { font-weight: 600; }
.font-normal { font-weight: normal; }

/* Text Colors - Semantic */
.text-info { color: var(--color-info); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-danger { color: var(--color-error); }
.text-warning { color: var(--color-warning); }

/* Text Colors - Brand */
.text-accent { color: var(--moduleSelectionColor); }
.text-primary-color { color: var(--color-primary); }

/* ========================================
 * DISPLAY UTILITIES
 * ======================================== */

.inline-block { display: inline-block; }
.block { display: block; }
.inline { display: inline; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.hidden { display: none; }

/* Combined display + width utilities (common patterns) */
.inline-w-60px { display: inline-block; width: 60px; }
.inline-w-75px { display: inline-block; width: 75px; }
.inline-w-80px { display: inline-block; width: 80px; }
.inline-w-100px { display: inline-block; width: 100px; }
.inline-w-250px { display: inline-block; width: 250px; }
.inline-w-300px { display: inline-block; width: 300px; }
.inline-w-325px { display: inline-block; width: 325px; }

/* Combined display + width + text-align utilities (table headers, labels) */
.inline-w-80px-center { display: inline-block; width: 80px; text-align: center; }
.inline-w-250px-center { display: inline-block; width: 250px; text-align: center; }
.inline-w-325px-left { display: inline-block; width: 325px; text-align: left; }

/* ========================================
 * PADDING UTILITIES (using CSS variables)
 * ======================================== */

/* Padding All Sides */
.p-0 { padding: 0; }
.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

/* Padding Top */
.pt-0 { padding-top: 0; }
.pt-xs { padding-top: var(--space-xs); }
.pt-sm { padding-top: var(--space-sm); }
.pt-md { padding-top: var(--space-md); }
.pt-lg { padding-top: var(--space-lg); }
.pt-xl { padding-top: var(--space-xl); }

/* Padding Bottom */
.pb-0 { padding-bottom: 0; }
.pb-xs { padding-bottom: var(--space-xs); }
.pb-sm { padding-bottom: var(--space-sm); }
.pb-md { padding-bottom: var(--space-md); }
.pb-lg { padding-bottom: var(--space-lg); }
.pb-xl { padding-bottom: var(--space-xl); }

/* Padding Left */
.pl-0 { padding-left: 0; }
.pl-xs { padding-left: var(--space-xs); }
.pl-sm { padding-left: var(--space-sm); }
.pl-md { padding-left: var(--space-md); }
.pl-lg { padding-left: var(--space-lg); }
.pl-xl { padding-left: var(--space-xl); }

/* Padding Right */
.pr-0 { padding-right: 0; }
.pr-xs { padding-right: var(--space-xs); }
.pr-sm { padding-right: var(--space-sm); }
.pr-md { padding-right: var(--space-md); }
.pr-lg { padding-right: var(--space-lg); }
.pr-xl { padding-right: var(--space-xl); }

/* Padding X-axis (left and right) */
.px-0 { padding-left: 0; padding-right: 0; }
.px-xs { padding-left: var(--space-xs); padding-right: var(--space-xs); }
.px-sm { padding-left: var(--space-sm); padding-right: var(--space-sm); }
.px-md { padding-left: var(--space-md); padding-right: var(--space-md); }
.px-lg { padding-left: var(--space-lg); padding-right: var(--space-lg); }
.px-xl { padding-left: var(--space-xl); padding-right: var(--space-xl); }

/* Padding Y-axis (top and bottom) */
.py-0 { padding-top: 0; padding-bottom: 0; }
.py-xs { padding-top: var(--space-xs); padding-bottom: var(--space-xs); }
.py-sm { padding-top: var(--space-sm); padding-bottom: var(--space-sm); }
.py-md { padding-top: var(--space-md); padding-bottom: var(--space-md); }
.py-lg { padding-top: var(--space-lg); padding-bottom: var(--space-lg); }
.py-xl { padding-top: var(--space-xl); padding-bottom: var(--space-xl); }

/* ========================================
 * DISPLAY UTILITIES
 * ======================================== */

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

/* ========================================
 * POSITION UTILITIES
 * ======================================== */

.position-static { position: static !important; }
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-fixed { position: fixed !important; }
.position-sticky { position: sticky !important; }

/* Common positioning helpers */
.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

.inset-0 {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

/* ========================================
 * OVERFLOW UTILITIES
 * ======================================== */

.overflow-auto { overflow: auto !important; }
.overflow-hidden { overflow: hidden !important; }
.overflow-visible { overflow: visible !important; }
.overflow-scroll { overflow: scroll !important; }

.overflow-x-auto { overflow-x: auto !important; }
.overflow-x-hidden { overflow-x: hidden !important; }
.overflow-y-auto { overflow-y: auto !important; }
.overflow-y-hidden { overflow-y: hidden !important; }

/* ========================================
 * BORDER UTILITIES
 * ======================================== */

/* Border All Sides */
.border { border: 1px solid var(--border-color); }
.border-0 { border: none; }

/* Border Individual Sides */
.border-top { border-top: 1px solid var(--border-color); }
.border-bottom { border-bottom: 1px solid var(--border-color); }
.border-left { border-left: 1px solid var(--border-color); }
.border-right { border-right: 1px solid var(--border-color); }

/* Border Top Only (no other sides) */
.border-top-0 { border-top: none; }
.border-bottom-0 { border-bottom: none; }
.border-left-0 { border-left: none; }
.border-right-0 { border-right: none; }

/* Border Dashed Variants */
.border-dashed { border-style: dashed; }
.border-top-dashed { border-top: 1px dashed var(--border-color-light); }
.border-bottom-dashed { border-bottom: 1px dashed var(--border-color-light); }
.border-left-dashed { border-left: 1px dashed var(--border-color-light); }
.border-right-dashed { border-right: 1px dashed var(--border-color-light); }

/* ========================================
 * HEIGHT UTILITIES
 * ======================================== */

.h-auto { height: auto; }
.h-full { height: 100%; }
.h-screen { height: 100vh; }

.min-h-0 { min-height: 0; }
.min-h-full { min-height: 100%; }
.min-h-screen { min-height: 100vh; }

.max-h-full { max-height: 100%; }
.max-h-screen { max-height: 100vh; }

/* ========================================
 * WIDTH UTILITIES (EXTENDED)
 * ======================================== */

/* Already have .w-full and .w-auto above */
.w-screen { width: 100vw; }
.w-50 { width: 50%; }
.w-33 { width: 33.333%; }
.w-25 { width: 25%; }

.min-w-0 { min-width: 0; }
.min-w-full { min-width: 100%; }

.max-w-full { max-width: 100%; }
.max-w-screen { max-width: 100vw; }

/* Input width constraints - common sizes for form inputs */
.max-w-80 { max-width: 80px; }   /* Narrow: coordinates, small numbers, single digits */
.max-w-120 { max-width: 120px; } /* Short: 2-3 digit numbers, compact fields */
.max-w-200 { max-width: 200px; } /* Medium: longer numbers, short text fields */
.max-w-300 { max-width: 300px; } /* Wide: longer text fields, selects */
.max-w-400 { max-width: 400px; } /* Extra wide: long text inputs */
.max-w-500 { max-width: 500px; } /* Very wide: descriptions, long selects */

/* ========================================
 * TEXT TRANSFORM UTILITIES
 * ======================================== */

.uppercase { text-transform: uppercase !important; }
.lowercase { text-transform: lowercase !important; }
.capitalize { text-transform: capitalize !important; }
.normal-case { text-transform: none !important; }

/* ========================================
 * TEXT DECORATION UTILITIES
 * ======================================== */

.underline { text-decoration: underline !important; }
.no-underline { text-decoration: none !important; }
.line-through { text-decoration: line-through !important; }

/* ========================================
 * WHITESPACE UTILITIES
 * ======================================== */

.whitespace-normal { white-space: normal !important; }
.whitespace-nowrap { white-space: nowrap !important; }
.whitespace-pre { white-space: pre !important; }
.whitespace-pre-wrap { white-space: pre-wrap !important; }

/* ========================================
 * TEXT OVERFLOW UTILITIES
 * ======================================== */

.truncate {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.text-ellipsis { text-overflow: ellipsis !important; }
.text-clip { text-overflow: clip !important; }

/* ========================================
 * OPACITY UTILITIES
 * ======================================== */

.opacity-0 { opacity: 0 !important; }
.opacity-25 { opacity: 0.25 !important; }
.opacity-50 { opacity: 0.5 !important; }
.opacity-75 { opacity: 0.75 !important; }
.opacity-100 { opacity: 1 !important; }

/* ========================================
 * POINTER EVENTS UTILITIES
 * ======================================== */

.pointer-events-none { pointer-events: none !important; }
.pointer-events-auto { pointer-events: auto !important; }

/* ========================================
 * USER SELECT UTILITIES
 * ======================================== */

.select-none { user-select: none !important; }
.select-text { user-select: text !important; }
.select-all { user-select: all !important; }
.select-auto { user-select: auto !important; }

/* ========================================
 * CURSOR UTILITIES
 * ======================================== */

.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }
.cursor-wait { cursor: wait; }
.cursor-move { cursor: move; }
.cursor-help { cursor: help; }

/* ========================================
 * VISIBILITY & ACCESSIBILITY UTILITIES
 * ======================================== */

/* Hide element but keep in layout */
.invisible { visibility: hidden; }
.visible { visibility: visible; }

/* Hide element completely (display: none already exists as .hidden above) */
.is-hidden { display: none !important; }  /* Alias for .hidden */

/* Screen reader only - visually hidden but accessible */
.visually-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ========================================
 * DIVIDER UTILITIES
 * ======================================== */

/* Section divider - horizontal rule */
.divider,
.section-divider {
  margin: var(--space-md) 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

/* ========================================
 * BADGE UTILITIES
 * Color variants for badge component
 * ======================================== */

/* Badge base class already exists earlier in file */
/* Adding semantic color variants */

.badge-success {
  background: var(--color-success);
  color: white;
}

.badge-warning {
  background: var(--color-warning);
  color: white;
}

.badge-danger {
  background: var(--color-danger);
  color: white;
}

.badge-info {
  background: var(--color-info);
  color: white;
}

.badge-highlight {
  background: var(--color-highlight);
  color: white;
}

/* ========================================
 * BUTTON GROUP UTILITIES
 * ======================================== */

/* Flex container for button groups with consistent spacing */
.btn-group {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
}

.btn-group-vertical {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: stretch;
}

/* Keep btn-icon inline within btn-group (don't let it wrap) */
.btn-group .btn-icon {
  flex: 0 0 auto;
}

/* ========================================
 * TABLE UTILITIES
 * ======================================== */

/* Responsive table wrapper - adds horizontal scroll on mobile */
.table-responsive,
.table-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;  /* Smooth scrolling on iOS */
}

/**********************************************
 * ACCESSIBILITY
 * 
 * Critical accessibility features for WCAG 2.1
 * Level AA compliance and inclusive design.
 **********************************************/

/* ========================================
 * REDUCED MOTION SUPPORT
 * WCAG 2.1 Level AA - Criterion 2.3.3
 * Respects user's OS-level motion preference
 * ======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================ */
/* ADDITIONAL UTILITY CLASSES FOR TABLES       */
/* ============================================ */

/* Vertical alignment */
.v-top { vertical-align: top; }
.v-middle { vertical-align: middle; }
.v-bottom { vertical-align: bottom; }

/* Combined utilities for table cells */
.v-top-center {
  vertical-align: top;
  text-align: center;
}

/* Width utilities for specific sizes */
.w-70px { width: 70px; }
.w-75px { width: 75px; }
.w-400px { width: 400px; }

/* Inline block with width */
.inline-w-10px {
  display: inline-block;
  width: 10px;
}

/* Combined width and vertical alignment */
.w-400px-v-top {
  width: 400px;
  vertical-align: top;
}


/* ============================================ */
/* FIXED-WIDTH INPUT UTILITIES                 */
/* ============================================ */

/* Fixed-width inputs (not responsive) */
.input.input-fixed {
  width: auto;
  min-width: 100px;
  max-width: 100px;
}

.input.input-sm {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
}

.input.input-md {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

.input.input-lg {
  width: 160px;
  min-width: 160px;
  max-width: 160px;
}

.input.input-xl {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
}

/* Specific widths for numeric inputs */
.input.input-w-60 {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
}

.input.input-w-80 {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
}

.input.input-w-100 {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

.input.input-w-120 {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

.input.input-w-150 {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
}


/* ============================================ */
/* TABLE SCROLL WRAPPER                        */
/* ============================================ */

/* Wrapper for tables to enable horizontal and vertical scrolling */
.table-scroll-wrapper {
  width: 100%;
  max-height: 800px; /* Maximum vertical size - double the typical table height */
  overflow-x: auto; /* Horizontal scroll when needed */
  overflow-y: auto; /* Vertical scroll when table exceeds max-height */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  border: 1px solid var(--border-color, #ddd); /* Visual boundary */
}

/* Let tables size naturally based on content */
.table-scroll-wrapper table {
  width: auto; /* Natural width based on content */
  white-space: nowrap; /* Prevent text wrapping in cells */
}


/* Combined vertical and horizontal alignment */
.v-middle-center {
  vertical-align: middle;
  text-align: center;
}


/* Additional specific widths for symmetry inputs */
.input.input-w-65 {
  width: 65px;
  min-width: 65px;
  max-width: 65px;
}

.input.input-w-110 {
  width: 110px;
  min-width: 110px;
  max-width: 110px;
}


/* ============================================ */
/* MARGIN UTILITIES                            */
/* ============================================ */

/* Margin bottom */
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* Margin top */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

/* Font weight */
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }


/* Chain input width */
.input.input-w-70 {
  width: 70px;
  min-width: 70px;
  max-width: 70px;
}


/* Flexbox alignment utilities */
.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.align-end { align-items: flex-end; }

/* Gap utilities (numeric) */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }


/* Text color utilities */
.text-muted {
  color: var(--text-muted);
}

/* Button size variants */
.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
}

/* Flexbox direction */
.flex-col {
  display: flex;
  flex-direction: column;
}


/* Flex utilities for responsive layouts */
.flex-nowrap {
  flex-wrap: nowrap;
}

.flex-shrink-0 {
  flex-shrink: 0;
}


/* Responsive flex row - wraps on small screens */
.flex-row-responsive {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

/* On larger screens (768px+), prevent wrapping */
@media (min-width: 768px) {
  .flex-row-responsive {
    flex-wrap: nowrap;
  }
}

/* ========================================
 * DECORATIVE ELEMENTS
 * For arrows, icons, and visual separators
 * ======================================== */

.arrow-decorator {
  font-size: 20px;
  vertical-align: middle;
}

/* Arrow element for move up/down actions */
.arrow {
  border-style: solid;
  border-color: black;
}

/* ========================================
 * LINK UTILITIES
 * Compact padding for inline action links
 * ======================================== */

.link-compact {
  padding: 0 2px;
}

/* Action link icons (delete, edit, copy, move) */
.action-link-icon {
  padding: 0 2px;
  cursor: pointer;
  color: var(--color-info);
  font-size: 20px;
  text-decoration: none;
}

.action-link-icon:hover {
  color: var(--color-info-hover);
}

/* Arrow navigation links (up/down for reordering) */
.arrow-nav-link {
  padding: 0 2px;
  text-decoration: none;
  display: inline-block;
  border-radius: 50%;
  font-size: 18px;
}

.arrow-nav-link-disabled {
  padding: 0 2px;
  text-decoration: none;
  display: inline-block;
  border-radius: 50%;
  color: var(--pythoncolor-comment);
  font-size: 18px;
  cursor: not-allowed;
  opacity: 0.5;
}

.arrow-nav-link-active {
  padding: 0 2px;
  text-decoration: none;
  display: inline-block;
  border-radius: 50%;
  font-weight: bold;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.2s ease, font-size 0.2s ease;
}

.arrow-nav-link-active:hover {
  transform: scale(1.3);
  font-size: 22px;
}

/* Delete icon link for cycle functions */
.cycle-delete-icon {
  padding: 0 2px;
  text-decoration: none;
  display: inline-block;
  border-radius: 50%;
  font-size: 18px;
  vertical-align: baseline;
  cursor: pointer;
  transition: transform 0.2s ease, font-size 0.2s ease;
}

.cycle-delete-icon:hover {
  transform: scale(1.3);
  font-size: 22px;
  color: #f44336;
}

/* Grow animation classes for interactive elements */
.grow2 {
  transition: transform 0.2s ease, font-size 0.2s ease;
}

.grow2:hover {
  transform: scale(1.2);
}

.grow12 {
  transition: transform 0.2s ease, font-size 0.2s ease;
}

.grow12:hover {
  transform: scale(1.2);
}

/* ========================================
 * PYTHON SYNTAX HIGHLIGHTING
 * For displaying Python code snippets
 * ======================================== */

.python-comment { color: var(--pythoncolor-comment); }
.python-function { color: var(--pythoncolor-function); }
.python-string { color: var(--pythoncolor-string); }
.python-syntax { color: var(--pythoncolor-syntax); }

/* ========================================
 * ACTION SECTIONS (Generic, Reusable)
 * For all update/apply/reset action sections
 * ======================================== */

/* Base action section styles */
.action-section {
  padding: 12px;
  border-radius: var(--border-radius);
  margin: 12px 0;
  border-left: 3px solid;
}

/* Color variants */
.action-section-warning {
  background: var(--bg-warning-light);
  border-left-color: var(--color-warning);
}

.action-section-success {
  background: var(--bg-success-light);
  border-left-color: var(--color-success);
}

.action-section-info {
  background: var(--bg-info-light);
  border-left-color: var(--color-primary);
}

/* Action section header */
.action-header {
  margin-bottom: 4px;
}

/* Action section label (title + icon) */
.action-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========================================
 * INFO BANNER
 * Informational message banner
 * ======================================== */

.info-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-info-light);
  border-left: 3px solid var(--color-info);
  border-radius: var(--border-radius);
  margin: 12px 0;
}

.info-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.info-text {
  color: var(--text-primary);
  font-size: var(--font-size-base);
}

/* ========================================
 * WARNING BANNER
 * Warning message banner (matches info-banner pattern)
 * ======================================== */

.warning-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-warning-light);
  border-left: 3px solid var(--color-warning);
  border-radius: var(--border-radius);
  margin: 12px 0;
}

.warning-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.warning-text {
  color: var(--text-primary);
  font-size: var(--font-size-base);
}

/* ========================================
 * ERROR BANNER
 * Error message banner (matches info-banner pattern)
 * ======================================== */

.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-error-light);
  border-left: 3px solid var(--color-error);
  border-radius: var(--border-radius);
  margin: 12px 0;
}

.error-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.error-text {
  color: var(--text-primary);
  font-size: var(--font-size-base);
}

/* Margin left utilities */
.ml-1 { margin-left: 4px; }
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 12px; }
.ml-4 { margin-left: 16px; }


/* ============================================ */
/* PARAMETER ROWS (for inline label + input)   */
/* ============================================ */

/* Nested box for conditional options */
.nested-options-box {
  border: 1px dashed #aaa;
  background: #f9f9f9;
  padding: 12px;
  margin: 12px 0;
  border-radius: 4px;
}

.nested-options-header {
  font-size: 13px;
  font-weight: 600;
  color: #666;
  margin-bottom: 8px;
}

/* Parameter row (label + input on same line) */
.param-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.param-row:last-child {
  margin-bottom: 0;
}

.param-label {
  min-width: 220px;
  flex-shrink: 0;
  font-size: 14px;
}

.param-input {
  flex: 1;
}


/**********************************************
 * TAB NAVIGATION SYSTEM
 **********************************************/

/* Tab Navigation Container */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border, #ddd);
  margin-bottom: var(--space-md, 16px);
}

/* Tab Button */
.tab-btn {
  flex: 0 0 auto;
  padding: var(--space-sm, 12px) var(--space-md, 16px);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: var(--font-size-base, 14px);
  font-weight: var(--font-weight-medium, 500);
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
  position: relative;
  top: 2px;
}

.tab-btn:hover {
  color: var(--color-text, #333);
  background: var(--color-bg-hover, #f5f5f5);
}

.tab-btn.active {
  color: var(--color-primary, #2196F3);
  border-bottom-color: var(--color-primary, #2196F3);
  font-weight: var(--font-weight-semibold, 600);
}

.tab-btn span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs, 4px);
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.2s ease-in;
}

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

/* Responsive: Stack tabs on mobile */
@media (max-width: 768px) {
  .tab-nav {
    flex-direction: column;
    border-bottom: none;
  }
  
  .tab-btn {
    border-bottom: none;
    border-left: 3px solid transparent;
    top: 0;
  }
  
  .tab-btn.active {
    border-bottom-color: transparent;
    border-left-color: var(--color-primary, #2196F3);
  }
}
