@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap');

:root {
  --bg-start: #eef2ff;
  --bg-end: #f8fafc;
  --card-bg: rgba(255, 255, 255, 0.7);
  --card-accent: linear-gradient(90deg, rgba(79,46,229,0.12), rgba(79,70,229,0.06));
  --primary: #4f46e5;
  --primary-600: #6366f1;
  --primary-dark: #3730a3;
  --text: #0f172a;
  --muted: #6b7280;
  --border: rgba(15, 23, 42, 0.06);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --glass: rgba(255,255,255,0.5);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: radial-gradient(1000px 600px at 10% 10%, rgba(99,102,241,0.06), transparent), linear-gradient(135deg, var(--bg-start), var(--bg-end));
  color: var(--text);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  padding: 40px 20px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Language Selector */
.language-selector {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
}

#language-switcher {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(2, 6, 23, 0.06);
  transition: all 0.2s ease;
}

#language-switcher:hover {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.08);
}

#language-switcher:focus {
  outline: none;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Background Selector */
.background-selector {
  position: fixed;
  top: 20px;
  right: 180px;
  z-index: 100;
}

#background-switcher {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(2, 6, 23, 0.06);
  transition: all 0.2s ease;
}

#background-switcher:hover {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.08);
}

#background-switcher:focus {
  outline: none;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

@media (max-width: 680px) {
  .background-selector {
    top: 50px;
    right: 10px;
  }
}

@media (max-width: 420px) {
  .background-selector {
    top: 50px;
    right: 10px;
  }
  
  #background-switcher {
    padding: 6px 10px;
    font-size: 0.85rem;
  }
}

/* Background Images */
body.bg-campus-green {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.4), rgba(59, 130, 246, 0.4)), 
    url('https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&auto=format&fit=crop&w=2000&q=80') center/cover no-repeat fixed;
  background-attachment: fixed;
}

body.bg-modern-building {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.4), rgba(79, 70, 229, 0.4)), 
    url('https://images.unsplash.com/photo-1451187580459-43490279c0fa?ixlib=rb-4.0.3&auto=format&fit=crop&w=2000&q=80') center/cover no-repeat fixed;
  background-attachment: fixed;
}

body.bg-nature-blur {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(168, 85, 247, 0.3)), 
    url('https://images.unsplash.com/photo-1439066615861-d1af74d74000?ixlib=rb-4.0.3&auto=format&fit=crop&w=2000&q=80') center/cover no-repeat fixed;
  background-attachment: fixed;
}

body.bg-library-interior {
  background: linear-gradient(135deg, rgba(75, 85, 99, 0.4), rgba(55, 48, 163, 0.4)), 
    url('https://images.unsplash.com/photo-1521737711867-e3b97375f902?ixlib=rb-4.0.3&auto=format&fit=crop&w=2000&q=80') center/cover no-repeat fixed;
  background-attachment: fixed;
}

body.bg-sunset-campus {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.3), rgba(239, 68, 68, 0.3)), 
    url('https://images.unsplash.com/photo-1505142468610-359e7d316be0?ixlib=rb-4.0.3&auto=format&fit=crop&w=2000&q=80') center/cover no-repeat fixed;
  background-attachment: fixed;
}


.container {
  width: min(100%, 520px);
  padding: 8px;
  position: relative;
  z-index: 10;
}

.main-wrapper {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 1400px;
  margin-top: 60px;
  align-items: flex-start;
}

.graph-section {
  flex: 0 0 auto;
  width: min(100%, 450px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.graph-card {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 
    0 25px 50px rgba(2, 6, 23, 0.15),
    0 0 1px rgba(255, 255, 255, 0.9) inset,
    0 0 20px rgba(79, 70, 229, 0.1) inset;
  border: 2px solid rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
}

.graph-title {
  margin: 0 0 16px 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
  display: none;
}

.chart-container.active {
  display: block;
}

.chart-placeholder {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 60px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.chart-placeholder.hidden {
  display: none;
}

.history-section {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 
    0 25px 50px rgba(2, 6, 23, 0.15),
    0 0 1px rgba(255, 255, 255, 0.9) inset;
  border: 2px solid rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  max-height: 400px;
  overflow-y: auto;
}

.history-header-title {
  margin: 0 0 12px 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.history-list-sidebar {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.history-list-sidebar li {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 8px rgba(2, 6, 23, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.9rem;
  color: var(--text);
}

.history-list-sidebar li.history-empty {
  text-align: center;
  color: var(--muted);
  padding: 20px;
}

.history-list-sidebar .category-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -1px;
}

.history-list-sidebar .history-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-list-sidebar .history-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.calculator-section {
  flex: 0 0 auto;
  width: min(100%, 520px);
}

.card {
  position: relative;
  overflow: visible;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 36px 28px;
  box-shadow: 0 10px 30px rgba(2,6,23,0.08), 0 2px 6px rgba(79,70,229,0.06) inset;
  border: 1px solid var(--border);
  backdrop-filter: blur(8px) saturate(120%);
}

.card::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 22px;
  background: var(--card-accent);
  filter: blur(14px);
  opacity: 0.9;
  z-index: -1;
}

.header { text-align: center; margin-bottom: 20px; }

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary-600);
  font-size: 12px;
  font-weight: 800;
}

h1 { margin: 0; font-size: 1.75rem; font-weight: 700; color: var(--text); }

.form { display: grid; gap: 16px; }

.field-group { display: grid; gap: 8px; }

label { font-weight: 600; font-size: 0.95rem; color: rgba(15, 23, 42, 0.95); text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5); }

input[type='number'], input[type='text'] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.7);
  font-size: 1rem;
  outline: none;
  transition: box-shadow 0.18s ease, transform 0.12s ease, border-color 0.18s ease, background 0.18s ease;
  box-shadow: 0 4px 12px rgba(2, 6, 23, 0.06), inset 0 1px 2px rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

input::placeholder { color: rgba(15,23,42,0.35); }

input:focus {
  border-color: var(--primary-600);
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-2px);
  box-shadow: 
    0 12px 24px rgba(79, 70, 229, 0.15),
    inset 0 1px 2px rgba(255, 255, 255, 0.9),
    0 0 0 3px rgba(79, 70, 229, 0.1);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 1rem;
  color: white;
  cursor: pointer;
  background: linear-gradient(90deg, var(--primary), var(--primary-600));
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 2px 6px rgba(2, 6, 23, 0.1);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

button:hover { 
  transform: translateY(-4px); 
  filter: brightness(1.05);
  box-shadow: 0 16px 32px rgba(79, 70, 229, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 6px rgba(2, 6, 23, 0.12);
}

button:active {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(79, 70, 229, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.result {
  margin-top: 22px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  padding: 18px 16px;
  text-align: center;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  box-shadow: 
    0 8px 24px rgba(2, 6, 23, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.result-label { margin: 0; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; font-weight: 700; }

#bmi-value { margin: 10px 0 6px; font-size: 2.4rem; color: var(--primary-dark); font-weight: 800; }

#bmi-category { margin: 0; color: var(--text); font-weight: 700; }

.category-dot {
  display: inline-block;
  width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: -1px;
}

/* Small screens */
@media (max-width: 420px) {
  .card { padding: 22px 16px; }
  #bmi-value { font-size: 1.9rem; }
  
  .main-wrapper {
    flex-direction: column;
    gap: 16px;
    margin-top: 50px;
  }
  
  .graph-section {
    width: 100%;
  }
  
  .calculator-section {
    width: 100%;
  }
  
  .graph-card {
    padding: 20px;
  }
  
  .chart-container {
    height: 250px;
  }
  
  .history-section {
    max-height: 350px;
  }
}

@media (max-width: 768px) {
  .main-wrapper {
    flex-direction: column;
    gap: 16px;
    margin-top: 50px;
  }
  
  .graph-section {
    width: 100%;
  }
  
  .calculator-section {
    width: 100%;
  }
}

@media (min-width: 1024px) {
  .main-wrapper {
    gap: 24px;
  }
}

/* Utility helpers */
.muted { color: var(--muted); }
.sr-only { position: absolute; left: -9999px; }

/* Completed step */
/* Design improvements applied */

/* History panel (fixed at bottom) - HIDDEN */
.history-panel {
  display: none;
}

.history-panel.collapsed { max-height: 44px; overflow: hidden; }

.history-header { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:6px 4px; }
.history-title { font-weight:700; color:var(--text); }
.history-actions { display:flex; gap:8px; }

.btn-ghost { 
  background: transparent; 
  border: 1px solid rgba(79, 70, 229, 0.2); 
  color: var(--primary-dark); 
  font-weight: 600; 
  padding: 6px 10px; 
  border-radius: 8px; 
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-ghost:hover { 
  background: rgba(79, 70, 229, 0.1);
  border-color: rgba(79, 70, 229, 0.4);
  color: var(--primary-600);
}

.history-list { list-style: none; margin: 6px 0 4px; padding: 6px; display: grid; gap: 8px; }
.history-empty { text-align: center; padding: 8px 6px; }
.history-item { 
  display: block; 
  padding: 8px 10px; 
  border-radius: 10px; 
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 8px rgba(2, 6, 23, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.history-item .history-row { display:flex; flex-direction:column; gap:4px; }
.history-item .history-meta { color: var(--muted); font-size: 0.85rem; }

@media (max-width: 420px) {
  .history-panel { left: 8px; transform: none; right: 8px; width: auto; bottom: 12px; }
}