/* Modern layout system for Visual Speech (Bootstrap 5 + custom tokens)
   Clean implementation using modern CSS practices.
*/

:root {
  /* Phase 7: Core design tokens - Light Theme */
  /* Surfaces */
  --vs-color-bg: #f8f9fa;
  --vs-color-bg-alt: #ffffff;
  --vs-color-surface: #ffffff;
  --vs-color-surface-alt: #f8f9fa;
  --vs-color-overlay: rgba(255, 255, 255, 0.9);

  /* Borders & outlines */
  --vs-color-border: #dee2e6;
  --vs-color-border-strong: #adb5bd;

  /* Text */
  --vs-color-text: #212529;
  --vs-color-text-muted: #6c757d;
  --vs-color-text-faint: #adb5bd;
  --vs-color-heading: #343a40;

  /* Brand & accents */
  --vs-color-accent: #3d8bfd; /* primary accent */
  --vs-color-accent-hover: #2f78e8;
  --vs-color-accent-active: #2569d6;
  --vs-color-accent-rgb: 61, 139, 253;
  --vs-color-success: #28c76f;
  --vs-color-danger: #ef4444;
  --vs-color-warning: #f59e0b;
  --vs-color-info: #5bc0de; /* legacy accent retained as token */

  /* State overlays */
  --vs-overlay-hover: rgba(0, 0, 0, 0.05);
  --vs-overlay-active: rgba(0, 0, 0, 0.1);

  /* Shadows */
  --vs-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --vs-shadow-md: 0 2px 4px rgba(0, 0, 0, 0.15);
  --vs-shadow-lg: 0 4px 18px -2px rgba(0, 0, 0, 0.2);

  /* Radii */
  --vs-radius-xs: 2px;
  --vs-radius-sm: 4px;
  --vs-radius-md: 6px;
  --vs-radius-lg: 10px;
  --vs-radius-pill: 999px;

  /* Typography */
  --vs-font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --vs-font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --vs-font-size-xs: 0.7rem;
  --vs-font-size-sm: 0.8rem;
  --vs-font-size-md: 0.9rem;
  --vs-font-size-base: 1rem;
  --vs-font-size-lg: 1.15rem;
  --vs-line-height-tight: 1.15;
  --vs-line-height-base: 1.4;
  --vs-line-height-relaxed: 1.6;
  /* Footer */
  --vs-footer-height: 56px;

  /* Spacing scale */
  --vs-space-0: 0;
  --vs-space-1: 0.125rem;
  --vs-space-2: 0.25rem;
  --vs-space-3: 0.375rem;
  --vs-space-4: 0.5rem;
  --vs-space-5: 0.625rem;
  --vs-space-6: 0.75rem;
  --vs-space-8: 1rem;
  --vs-space-10: 1.25rem;
  --vs-space-12: 1.5rem;
  --vs-space-16: 2rem;
  --vs-space-20: 2.5rem;

  /* Transitions */
  --vs-transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --vs-transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Legacy compat (old variable names) */
  --vs-bg: var(--vs-color-bg);
  --vs-surface: var(--vs-color-surface);
  --vs-border: var(--vs-color-border);
}

body.vs-app {
  background: var(--vs-color-bg);
  color: var(--vs-color-text);
  font-family: var(--vs-font-sans);
  font-size: var(--vs-font-size-base);
  line-height: var(--vs-line-height-base);
  -webkit-font-smoothing: antialiased;
}

/* Viewport-fit: prevent page scroll; only middle content scrolls */
html,
body {
  height: 100%;
  overflow: hidden;
}
body.vs-app {
  height: 100vh;
  overflow: hidden;
}

/* Top-level flex layout */
.vs-layout {
  display: flex;
  flex-direction: column; /* Stack header on top, then main content */
  height: 100vh; /* lock to viewport height */
  overflow: hidden; /* prevent page scroll; content area will scroll */
  background: var(--vs-bg);
}

/* Header */
.vs-header {
  background: var(--vs-color-surface);
  border-bottom: 1px solid var(--vs-color-border);
  padding: 0; /* navbar handles its own spacing */
  position: relative;
  z-index: 1030; /* above content/canvas */
  flex: 0 0 auto; /* prevent shrinking in flex */
}

/* Sidebar */
.vs-sidebar {
  width: 240px;
  background: var(--vs-surface);
  border-right: 1px solid var(--vs-border);
  display: flex;
  flex-direction: column;
  transition: width 0.18s ease-in-out;
}

/* Content area */
.vs-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevent overflow in flex context */
  min-height: 0; /* Allow child to shrink within flex and enable scrolling */
  overflow: auto; /* Only content area scrolls */
  padding-bottom: var(--vs-footer-height); /* ensure fixed footer never covers content */
}

/* Optional future main region wrapper */
.vs-content main {
  flex: 1;
  padding: 1rem 1.25rem 2rem;
}

/* Placeholder collapsed state (actual toggle logic in Phase 4) */
.vs-sidebar.collapsed {
  width: 64px;
  overflow: hidden;
}
body.sidebar-collapsed .vs-sidebar nav a span {
  display: none;
}

/* Body state adjustments */
/* Placeholder for future content shift adjustments (removed empty ruleset) */

/* Accessibility focus visible outline helper */
:focus-visible {
  outline: 2px solid #3d8bfd;
  outline-offset: 2px;
}

/* Enhanced focus for canvas elements */
canvas:focus-visible {
  outline: 3px solid #3d8bfd;
  outline-offset: 2px;
}

/* Skip link for keyboard navigation */
.sr-only:not(:focus):not(:active) {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Utility to visually confirm no layout shift (remove later if unused) */
/* .vs-layout-debug * { outline: 1px solid rgba(255,0,0,0.1); } */

/* Phase 3 bridge: ensure cards mimic boxes visually before full migration */
.card.card-default {
  background: transparent; /* Card styling handled separately */
  border: none; /* Remove default card border to avoid double edges */
  border-radius: 0; /* Match flat box look */
}
.card-header {
  padding: 0.5rem 0.75rem;
  background: transparent;
  border-bottom: 1px solid var(--vs-color-border);
}
.card-body {
  padding: 0.75rem 0.75rem 1rem;
}

/* Extracted minimal styles for Visual Speech layout */
.vs-sidebar .sidebar {
  padding: 0.5rem 0.25rem;
  flex: 1;
  overflow-y: auto;
}
.vs-sidebar .sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}
.vs-sidebar .sidebar-menu > li > a {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: var(--vs-space-5) var(--vs-space-8);
  color: var(--vs-color-text-muted);
  text-decoration: none;
  font-size: var(--vs-font-size-md);
  border-radius: var(--vs-radius-sm);
  transition:
    background var(--vs-transition-fast),
    color var(--vs-transition-fast);
}
.vs-sidebar .sidebar-menu > li.active > a,
.vs-sidebar .sidebar-menu > li > a:hover {
  background: var(--vs-overlay-hover);
  color: var(--vs-color-text);
}
.vs-sidebar .sidebar-menu i.fa {
  width: 1.1rem;
  text-align: center;
}

.card {
  background: var(--vs-color-surface-alt);
  border: 1px solid var(--vs-color-border);
  border-radius: var(--vs-radius-sm);
  box-shadow: var(--vs-shadow-sm);
}
.card-header {
  border-bottom: 1px solid var(--vs-color-border-strong);
  font-weight: 600;
  font-size: var(--vs-font-size-md);
  color: var(--vs-color-heading);
}
.card-body {
  font-size: 0.9rem;
}

ol.breadcrumb {
  background: transparent;
  padding: var(--vs-space-4) var(--vs-space-8);
  margin-bottom: var(--vs-space-6);
  font-size: var(--vs-font-size-sm);
}
ol.breadcrumb > li + li:before {
  content: '/';
  padding: 0 var(--vs-space-4);
  color: var(--vs-color-text-faint);
}

.text-muted {
  color: var(--vs-color-text-faint) !important;
}

/* Modal header utility using tokenized info color */
.vs-modal-header-info {
  background: var(--vs-color-info);
  color: #fff;
}

/* Simple utility classes for replacing inline styles (initial subset) */
.vs-m-0 {
  margin: 0 !important;
}
.vs-font-100 {
  font-size: 100% !important;
}
.vs-hidden {
  display: none !important;
}

/* Width utility for progress examples */
.vs-w-70 {
  width: 70% !important;
}

/* Minimal treeview fallback */
.sidebar-menu .treeview-menu {
  list-style: none;
  margin: 0 0 0 1rem;
  padding: 0;
}
.sidebar-menu .treeview > a:after {
  content: '';
}

/* Footer styles within flex layout */
.main-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--vs-color-surface);
  border-top: 1px solid var(--vs-color-border);
  color: var(--vs-color-text);
  min-height: var(--vs-footer-height); /* comfortable baseline across views */
  padding: 8px 20px; /* vertical + horizontal padding for breathing room */
  box-sizing: border-box;
  z-index: 1020;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

.main-footer .footer-left {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.main-footer .footer-right {
  white-space: nowrap;
}
/* Vertically center footer contents consistently */
.main-footer > .footer-left,
.main-footer > .footer-right {
  display: flex;
  align-items: center;
}
