/* ===== Design tokens ===== */
:root {
  --bg: #0b0e13;
  --surface: #11151d;
  --muted: #171c26;
  --text: #e8ecf1;
  --text-dim: #a6b0bf;
  --chip: #1b2433;
  --chip-border: rgba(255,255,255,.08);
  --primary: #7c4dff;
  --primary-2: #22d3ee;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow-1: 0 2px 10px rgba(0,0,0,.25);
  --shadow-2: 0 16px 40px rgba(0,0,0,.45);
  --ring: 0 0 0 2px rgba(124,77,255,.7), 0 0 0 4px rgba(34,211,238,.35);

  /* Extended tokens for existing functionality */
  --bg-primary: var(--surface);
  --bg-secondary: var(--muted);
  --bg-tertiary: var(--chip);
  --bg-elevated: var(--surface);
  --text-primary: var(--text);
  --text-secondary: var(--text-dim);
  --text-muted: var(--text-dim);
  --border-color: var(--chip-border);
  --border-color-hover: rgba(255,255,255,.12);
  
  /* Semantic colors */
  --success: var(--ok);
  --warning: var(--warn);
  --error: var(--danger);
  --info: var(--primary-2);
  
  /* Success/Warning/Error backgrounds */
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning-bg: rgba(245, 158, 11, 0.1);
  --error-bg: rgba(239, 68, 68, 0.1);
  --info-bg: rgba(34, 211, 238, 0.1);
  --success-border: rgba(16, 185, 129, 0.2);
  --warning-border: rgba(245, 158, 11, 0.2);
  --error-border: rgba(239, 68, 68, 0.2);
  --info-border: rgba(34, 211, 238, 0.2);
  --info-color: var(--primary-2);
  --info-text: var(--primary-2);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-2));
  --gradient-secondary: linear-gradient(135deg, #a855f7, #3b82f6);
  --gradient-accent: linear-gradient(135deg, #ec4899, var(--primary), var(--primary-2));
  
  /* Accent colors */
  --accent-primary: var(--primary);
  --accent-secondary: var(--primary-2);
  --accent-tertiary: #ec4899;
  
  /* Primary hover state */
  --primary-hover: #6c3ce6;
  
  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  
  /* Font weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Font sizes */
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-base: 15px;
  --font-size-lg: 18px;
  --font-size-xl: 22px;
  --font-size-2xl: 28px;
  
  /* Border radius scale */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 999px;
  
  /* Additional shadow variants */
  --shadow-light: 0 1px 3px rgba(0,0,0,.1);
  --shadow-medium: 0 4px 12px rgba(0,0,0,.15);
  --shadow-heavy: 0 8px 24px rgba(0,0,0,.25);
  
  /* Toolbar and canvas backgrounds */
  --toolbar-bg: rgba(17, 21, 29, 0.95);
  --toolbar-bg-mobile: var(--surface);
  --canvas-bg: var(--bg);
  
  /* Additional border variants */
  --border-light: rgba(255,255,255,.04);
  
  /* Color palette for board elements */
  --color-white: #ffffff;
  --color-black: #000000;
  --color-red: #ef4444;
  --color-green: #10b981;
  --color-blue: #3b82f6;
  --color-yellow: #f59e0b;
  --color-magenta: #ec4899;
  --color-cyan: #06b6d4;
  --color-orange: #f97316;
  --color-purple: #8b5cf6;
  --color-pink: #f472b6;
  
  /* Hover states */
  --bg-hover: rgba(255,255,255,.05);
  
  /* System font family */
  --font-family-system: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
}

/* Light theme */
html[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --muted: #f2f4f8;
  --text: #0b1220;
  --text-dim: #5b6474;
  --chip: #eef2f7;
  --chip-border: rgba(2,6,23,.08);
  --shadow-1: 0 1px 6px rgba(2,6,23,.07);
  --shadow-2: 0 12px 30px rgba(2,6,23,.12);
  --border-color-hover: rgba(2,6,23,.12);
  
  /* Extended tokens for light theme */
  --bg-primary: #ffffff;
  --bg-secondary: #f2f4f8;
  --bg-tertiary: #eef2f7;
  --bg-elevated: #ffffff;
  --text-primary: #0b1220;
  --text-secondary: #5b6474;
  --text-muted: #5b6474;
  --border-color: rgba(2,6,23,.08);
  
  /* Light theme shadows */
  --shadow-light: 0 1px 3px rgba(2,6,23,.05);
  --shadow-medium: 0 4px 12px rgba(2,6,23,.08);
  --shadow-heavy: 0 8px 24px rgba(2,6,23,.12);
  
  /* Light theme toolbar and canvas */
  --toolbar-bg: rgba(255, 255, 255, 0.95);
  --toolbar-bg-mobile: var(--surface);
  --canvas-bg: var(--bg);
  
  /* Light theme borders */
  --border-light: rgba(2,6,23,.04);
  
  /* Light theme hover states */
  --bg-hover: rgba(2,6,23,.05);
}

/* Reset and base styles - override Bootstrap */
*, *::before, *::after {
  box-sizing: border-box !important;
}

/* Theme transition support for key elements */
.btn,
.card,
.modal,
.surface,
.toolbar,
.status-bar,
.board-container,
input,
select,
textarea {
  transition: background-color 0.3s ease, 
              border-color 0.3s ease, 
              color 0.3s ease,
              box-shadow 0.3s ease;
}

html, body {
  margin: 0 !important;
  padding: 0 !important;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif !important;
  font-size: var(--font-size-base) !important;
  line-height: 1.45 !important;
  color: var(--text) !important;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(124,77,255,.20), transparent 60%),
              radial-gradient(800px 400px at 90% 0%, rgba(34,211,238,.14), transparent 60%),
              var(--bg) !important;
  -webkit-font-smoothing: antialiased !important;
  text-rendering: optimizeLegibility !important;
  min-height: 100vh !important;
  background-attachment: fixed !important;
  transition: background-color 0.3s ease, color 0.3s ease !important;
}

/* Override Bootstrap button styles */
.btn {
  all: unset !important;
  appearance: none !important;
  border: none !important;
  border-radius: var(--radius-md) !important;
  padding: 12px 16px !important;
  font-weight: var(--font-weight-bold) !important;
  cursor: pointer !important;
  transition: transform 0.06s ease, box-shadow 0.2s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: var(--space-sm) !important;
  text-decoration: none !important;
}

/* Override Bootstrap container */
.container {
  width: min(1100px, 92%) !important;
  margin-inline: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  max-width: none !important;
}

/* Utility classes */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: min(1100px, 92%);
  margin-inline: auto;
}

/* Link styles */
a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

a:hover {
  text-decoration: underline;
}

/* Focus styles */
*:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* Button reset */
button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* Form element styles */
input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

input::placeholder, textarea::placeholder {
  color: var(--text-dim);
  opacity: 1;
}

/* Interactive form elements */
input[type="radio"], 
input[type="checkbox"], 
input[type="range"], 
input[type="file"], 
select {
  cursor: pointer;
}

/* Ensure all interactive elements have pointer cursor */
[role="button"],
[tabindex]:not([tabindex="-1"]),
.clickable,
div[onclick],
[data-onclick],
.site-branding,
.template-menu,
.user-info,
.brand {
  cursor: pointer !important;
}

/* Motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Common component styles */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  text-decoration: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn-primary {
  color: white;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-2);
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--chip-border);
}

.btn-ghost:hover {
  background: var(--muted);
}

.chip {
  padding: 6px 10px;
  border-radius: var(--radius-xl);
  background: var(--chip);
  border: 1px solid var(--chip-border);
  color: var(--text-dim);
  font-size: var(--font-size-sm);
}

.toggle {
  border: 1px solid var(--chip-border);
  background: var(--chip);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle:hover {
  background: var(--muted);
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-xl);
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--chip-border);
  border-radius: var(--radius);
  padding: var(--space-2xl);
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-2);
}

.modal-content h3 {
  margin: 0 0 var(--space-xl) 0;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text);
}

.form-group input, .form-group select {
  width: 100%;
  padding: var(--space-md);
  border: 1px solid var(--chip-border);
  border-radius: var(--radius-md);
  background: var(--muted);
  color: var(--text);
  transition: border-color 0.2s ease;
}

.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(124, 77, 255, 0.1);
}

.modal-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  margin-top: var(--space-2xl);
}

.primary {
  background: var(--gradient-primary) !important;
  color: white !important;
  border: none !important;
}

.primary:hover {
  transform: translateY(-1px);
}

.primary:disabled {
  background: var(--muted) !important;
  color: var(--text-dim) !important;
  cursor: not-allowed !important;
  transform: none !important;
}

/* Additional utility classes for compatibility */
.link {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

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

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
}

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

.text-info {
  color: var(--info);
}

.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-dim);
}

.empty-state p {
  margin: 0 0 var(--space-md) 0;
}

/* Toast notifications */
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--chip-border);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  display: none;
  color: var(--text);
  z-index: 1000;
}

.toast.show {
  display: block;
  animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Blazor Error UI */
#blazor-error-ui {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--error);
  color: white;
  padding: 12px 16px;
  box-shadow: var(--shadow-2);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-sm);
}

#blazor-error-ui.show {
  display: flex;
}

#blazor-error-ui .reload {
  color: white;
  text-decoration: underline;
  margin-left: 16px;
  font-weight: var(--font-weight-medium);
  cursor: pointer;
}

#blazor-error-ui .dismiss {
  color: white;
  cursor: pointer;
  margin-left: 16px;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s ease;
}

#blazor-error-ui .dismiss:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ===== User Menu Component (Global Styles) ===== */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--chip);
  display: grid;
  place-items: center;
  font-weight: var(--font-weight-bold);
  color: var(--text);
  font-size: var(--font-size-sm);
}

/* User dropdown */
.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  margin-top: 8px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--chip-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  padding: 6px;
}

.user-dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--chip-border);
}

.user-dropdown-name {
  font-weight: var(--font-weight-semibold);
  color: var(--text);
}

.user-dropdown-email {
  font-size: var(--font-size-sm);
  color: var(--text-dim);
  margin-top: 2px;
}

.user-dropdown-menu {
  padding: 6px;
}

.user-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease;
}

.user-dropdown-item:hover {
  background: var(--muted);
  text-decoration: none;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--chip-border);
  margin: 6px 0;
}