/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* Color Variables & Reset */
:root {
  --bg-main: #080c14;
  --bg-gradient-start: #080c14;
  --bg-gradient-end: #0f172a;
  
  --panel-bg: rgba(15, 23, 42, 0.65);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);

  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  
  --color-s1: #f43f5e; /* Rose */
  --color-s2: #3b82f6; /* Blue */
  --color-s3: #10b981; /* Emerald */
  --color-sub: #f59e0b; /* Amber */
  
  --color-s1-glow: rgba(244, 63, 94, 0.2);
  --color-s2-glow: rgba(59, 130, 246, 0.2);
  --color-s3-glow: rgba(16, 185, 129, 0.2);
  --color-sub-glow: rgba(245, 158, 11, 0.2);

  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(8, 12, 20, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(to right, #a5b4fc, #6366f1, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

header h1::before {
  content: '🎯';
  font-size: 1.6rem;
}

.badge {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #a5b4fc;
}

/* Layout Container */
.app-container {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 2rem;
  padding: 2rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* Sidebar Inputs */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--panel-shadow);
}

.card h2 {
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.5rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Form Styling */
.form-group-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.form-group-title:first-of-type {
  margin-top: 0;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.input-field label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.input-field input {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  transition: var(--transition-fast);
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.input-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px var(--primary-glow);
}

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

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

/* Main Content Area */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* SVG Map Grid Layout */
.visualization-panel {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

.map-container {
  position: relative;
  width: 100%;
  height: 480px;
  background: radial-gradient(circle at center, #111a2e 0%, #080d1a 100%);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--panel-shadow);
}

.map-grid-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
}

.map-svg {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
}

/* Station Details in Map Panel */
.station-legend-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.station-badge {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.station-badge .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}

.badge-s1 { color: var(--color-s1); border-left: 4px solid var(--color-s1); }
.badge-s2 { color: var(--color-s2); border-left: 4px solid var(--color-s2); }
.badge-s3 { color: var(--color-s3); border-left: 4px solid var(--color-s3); }
.badge-sub { color: var(--color-sub); border-left: 4px solid var(--color-sub); }

.station-badge .info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.station-badge .title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}

.station-badge .coords {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Steps Accordion & Details */
.solutions-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.step-card {
  transition: var(--transition-normal);
}

.step-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-card h3 span.num {
  background: rgba(255, 255, 255, 0.08);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
}

.step-content {
  padding-left: 2rem;
  border-left: 2px solid rgba(255, 255, 255, 0.05);
}

.step-math-block {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.75rem 0;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
}

.step-content p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.highlight-val {
  color: var(--text-main);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* SVG styling */
.svg-station {
  cursor: pointer;
}

.svg-station-ring {
  animation: pulse 2s infinite;
  transform-origin: center;
}

.svg-line {
  stroke-dasharray: 4 4;
  animation: dash 30s linear infinite;
}

.svg-line-main {
  stroke-dasharray: 0;
}

.svg-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 11px;
  fill: #fff;
  pointer-events: none;
}

@keyframes pulse {
  0% {
    r: 6px;
    opacity: 0.8;
  }
  50% {
    r: 16px;
    opacity: 0;
  }
  100% {
    r: 6px;
    opacity: 0;
  }
}

@keyframes dash {
  to {
    stroke-dashoffset: -1000;
  }
}

/* Responsiveness */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  
  .visualization-panel {
    grid-template-columns: 1fr;
  }
}

/* Custom styled math fraction display if Katex fails */
.fraction {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  padding: 0 4px;
}
.fraction > span {
  padding: 1px;
}
.fraction-num {
  border-bottom: 1px solid var(--text-main);
}
