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

:root {
  /* Professional Color System */
  --primary-accent: #4f46e5;
  --primary-accent-hover: #4338ca;
  --primary-accent-light: #818cf8;
  
  --success-color: #059669;
  --success-light: #10b981;
  --error-color: #dc2626;
  --error-light: #ef4444;
  --warning-color: #d97706;
  
  /* Neutral Colors */
  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;
  
  /* Background Colors */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-surface: #475569;
  
  /* Text Colors */
  --text-primary: #f8fafc;
  --text-secondary: #e2e8f0;
  --text-muted: #94a3b8;
  
  /* Component Colors */
  --header-bg: var(--bg-secondary);
  --card-bg: var(--bg-secondary);
  --sidebar-bg: var(--bg-tertiary);
  
  /* Spacing System */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  
  /* Border Radius */
  --radius-sm: 0.375rem; /* 6px */
  --radius-md: 0.5rem;   /* 8px */
  --radius-lg: 0.75rem;  /* 12px */
  --radius-xl: 1rem;     /* 16px */
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Typography */
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg-primary);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
}

html,
body {
  height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at top left, rgba(79, 70, 229, 0.1) 0%, transparent 40%),
    radial-gradient(ellipse at bottom right, rgba(129, 140, 248, 0.05) 0%, transparent 40%);
  pointer-events: none;
  z-index: -1;
}

/* --- MODERN SCROLLBAR --- */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(45deg, var(--neutral-600), var(--neutral-500));
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(45deg, var(--neutral-500), var(--neutral-400));
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--neutral-600) transparent;
}

/* --- MODERN HEADER --- */

header {
  width: 100%;
  min-height: 64px;
  height: 64px;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--neutral-700);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 100;
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(79, 70, 229, 0.1) 50%, 
    transparent 100%);
  pointer-events: none;
}

header nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  gap: var(--space-8);
  position: relative;
  z-index: 1;
}

header a {
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  position: relative;
  font-size: 0.9rem;
}

header a::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--primary-accent);
  opacity: 0;
  border-radius: var(--radius-md);
  transition: opacity var(--transition-normal);
  z-index: -1;
}

header a:hover {
  color: var(--text-primary);
  transform: translateY(-1px);
}

header a:hover::before {
  opacity: 0.1;
}

/* --- MODERN CONTAINER --- */
#root-container {
  flex: 1 1 auto;
  display: flex;
  overflow: hidden;
  position: relative;
}

#root-container > aside {
  width: 400px;
  min-width: 350px;
  max-width: 500px;
  height: 100%;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--neutral-700);
  position: relative;
  resize: horizontal;
  overflow: hidden;
}

#root-container > aside::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, 
    transparent 0%, 
    var(--primary-accent) 50%, 
    transparent 100%);
  opacity: 0.3;
}

#root-container > main {
  flex: 1 1 auto;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  position: relative;
}

div.centered-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-8);
  background: radial-gradient(ellipse at center, 
    rgba(79, 70, 229, 0.1) 0%, 
    transparent 50%);
}

/* --- ENHANCED DIAGRAM CONTAINER --- */
#diagram-container {
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at top left, rgba(79, 70, 229, 0.03) 0%, transparent 30%),
    radial-gradient(ellipse at bottom right, rgba(129, 140, 248, 0.02) 0%, transparent 30%);
  position: relative;
  overflow: hidden;
}

#diagram-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    linear-gradient(45deg, transparent 49%, rgba(79, 70, 229, 0.02) 50%, transparent 51%),
    linear-gradient(-45deg, transparent 49%, rgba(79, 70, 229, 0.02) 50%, transparent 51%);
  background-size: 20px 20px;
  opacity: 0.5;
  pointer-events: none;
}

#diagram-container > svg {
  outline: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
  position: relative;
  z-index: 1;
}

/* --- MODERN CARD DESIGN --- */
.card {
  background: var(--card-bg);
  color: var(--text-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--neutral-700);
  padding: var(--space-8);
  margin: var(--space-6);
  width: min(32rem, 90vw);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  
  /* Modern entrance animation */
  animation: cardEntrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--primary-accent) 50%, 
    transparent 100%);
}

.card > p:nth-child(1) {
  font-weight: 600;
  font-size: 1.5rem;
  margin-bottom: var(--space-4);
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--text-primary), var(--primary-accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.3;
}

.card > p:not(:first-child) {
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  line-height: 1.6;
}

.card * {
  animation: fadeInContent 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: 0.2s;
  opacity: 0;
}

/* --- MODERN BUTTONS --- */

.btn {
  background: linear-gradient(135deg, var(--primary-accent), var(--primary-accent-hover));
  color: var(--text-primary);
  border: none;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--primary-accent);
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.2), 
    transparent);
  transition: left var(--transition-slow);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: linear-gradient(135deg, var(--primary-accent-hover), var(--primary-accent));
}

.btn:hover::before {
  left: 100%;
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

.btn:focus-visible {
  outline: 2px solid var(--primary-accent-light);
  outline-offset: 2px;
}

/* --- MODERN SPINNER --- */
.router-spinner {
  width: 40px;
  height: 40px;
  margin: 100px auto;
  display: block;
  position: relative;
}

.router-spinner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-top: 3px solid var(--primary-accent);
  border-right: 3px solid var(--primary-accent-light);
  border-radius: 50%;
  animation: modernSpin 1s linear infinite;
}

.router-spinner::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-bottom: 2px solid var(--primary-accent-light);
  border-left: 2px solid var(--primary-accent);
  border-radius: 50%;
  animation: modernSpin 0.8s linear infinite reverse;
}

/* --- MODERN ANIMATIONS --- */

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

@keyframes cardEntrance {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
  60% {
    opacity: 0.8;
    transform: translateY(-5px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeInContent {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Smooth focus animations */
@keyframes focusRing {
  0% {
    box-shadow: 0 0 0 0 var(--primary-accent);
  }
  100% {
    box-shadow: 0 0 0 4px transparent;
  }
}

/* --- RESPONSIVE DESIGN --- */
@media print {
  header {
    display: none !important;
  }
}

@media screen and (max-width: 1024px) {
  #root-container > aside {
    width: 350px;
    min-width: 300px;
  }
}

@media screen and (max-width: 768px) {
  #root-container > aside {
    position: absolute;
    left: -100%;
    top: 0;
    width: 80%;
    height: 100%;
    z-index: 1000;
    transition: left var(--transition-normal);
    box-shadow: var(--shadow-xl);
  }
  
  #root-container > aside.mobile-open {
    left: 0;
  }
  
  #root-container > main {
    width: 100%;
  }
  
  #root-container > main.editor-hidden::after {
    content: "Tap the menu to open the editor";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    text-align: center;
  }

  .card {
    width: min(28rem, 85vw);
    margin: var(--space-4);
    padding: var(--space-6);
  }
  
  header {
    height: 56px;
    min-height: 56px;
  }
  
  header nav ul {
    gap: var(--space-6);
  }
  
  header a {
    font-size: 0.85rem;
    padding: var(--space-2) var(--space-3);
  }
}

@media screen and (max-width: 480px) {
  .card {
    width: min(24rem, 90vw);
    padding: var(--space-5);
  }
  
  .card > p:nth-child(1) {
    font-size: 1.3rem;
  }
  
  header nav ul {
    gap: var(--space-4);
  }
  
  header a {
    font-size: 0.8rem;
  }
}
