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

/* =========================================================
   SEMIO DB — Enciclopedia (M3 + Naive + Playful Redesign)
   "Clínica Día" (Light) & "Hospital Noche" (Dark)
   ========================================================= */

:root {
  /* Tonal Palette: Material Design 3 (M3) Emerald & Slate */
  --primary: #006C4C;           /* M3 Primary Emerald */
  --on-primary: #FFFFFF;
  --primary-container: #89F8C7;
  --on-primary-container: #002114;

  --secondary: #4D6357;
  --secondary-container: #CFE9DA;
  --on-secondary-container: #0B1F16;

  --tertiary: #3D6373;
  --tertiary-container: #C1E8FB;

  --surface: #FBFDF9;
  --on-surface: #191C1B;
  --surface-variant: #DBE5DE;
  --on-surface-variant: #404944;

  --outline: #707973;
  --error: #BA1A1A;

  /* Playful & Naive UI specifics */
  --bg: var(--surface);
  --panel: #FFFFFF;
  --card-bg: #FFFFFF;
  --text: var(--on-surface);
  --muted: var(--on-surface-variant);
  --line: var(--outline);
  
  /* Naive functional colors */
  --good: #18A058;              /* Naive Success Green */
  --warn: #F0A020;              /* Naive Warning Gold */
  --bad: #D03050;               /* Naive Error Red */
  --info: #2080F0;              /* Naive Info Blue */

  --accent: var(--primary);
  --radius-xl: 28px;            /* M3 Extra Large */
  --radius-l: 16px;             /* M3 Large */
  --radius-m: 12px;
  
  --shadow-soft: 0 4px 12px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.1);
  --shadow-hover: 0 15px 35px rgba(0,0,0,0.1), 0 5px 15px rgba(0,0,0,0.05);

  --sans: 'Outfit', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;

  font-size: 16px;
  color-scheme: light;
}

/* -------------------------
   Dark Theme (Hospital Noche)
-------------------------- */
html[data-theme="black"] {
  --primary: #6CDBAC;
  --on-primary: #003825;
  --primary-container: #005138;
  --on-primary-container: #89F8C7;

  --surface: #191C1B;
  --on-surface: #E1E3E0;
  --surface-variant: #404944;
  --on-surface-variant: #BFC9C2;

  --outline: #89938D;
  --bg: #111413;
  --panel: #191C1B;
  --card-bg: #1D211F;
  --text: #E1E3E0;
  
  --shadow-soft: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-hover: 0 0 30px rgba(0,0,0,0.2);

  color-scheme: dark;
}

/* -------------------------
   Base & Resets
-------------------------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  transition: background-color 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  overflow-x: hidden;
}

button, input { font-family: inherit; }

/* Scrollbar styling (Naive-style) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--outline) 30%, transparent); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--outline); }

/* -------------------------
   Topbar (Glassmorphism + M3 Elevation)
-------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--outline) 10%, transparent);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.brand { display: flex; align-items: center; gap: 16px; }

.logo {
  width: 42px; height: 42px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  transform: rotate(-3deg);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.logo:hover { transform: rotate(0deg) scale(1.1); }

.brand-text .title { font-weight: 800; font-size: 20px; letter-spacing: -0.5px; }
.brand-text .subtitle { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.actions { display: flex; gap: 8px; align-items: center; }

/* Naive UI styled buttons */
.btn {
  border: none;
  background: var(--surface-variant);
  color: var(--on-surface-variant);
  padding: 8px 16px;
  border-radius: var(--radius-m);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.23, 1, 0.32, 1);
  display: flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--outline); color: var(--bg); transform: translateY(-1px); }
.btn:active { transform: scale(0.96); }

.btn.btn-ghost { background: transparent; border: 1px solid var(--outline); }
.btn#refresh { background: var(--primary); color: var(--on-primary); box-shadow: 0 4px 10px rgba(0,108,76,0.2); }
.btn#refresh:hover { background: color-mix(in srgb, var(--primary) 80%, black); }

.status { font-family: var(--mono); font-size: 11px; font-weight: 500; padding: 4px 10px; background: var(--surface-variant); border-radius: 20px; color: var(--muted); }

/* -------------------------
   Layout: Sidebar & Content
-------------------------- */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 67px);
  background: var(--bg);
}

/* Sidebar: Floating Panel Style */
.sidebar {
  padding: 16px;
  background: var(--bg);
  border-right: 1px solid color-mix(in srgb, var(--outline) 8%, transparent);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
}

.search { 
  position: relative;
  display: flex; gap: 4px;
}
.search input {
  flex: 1;
  background: var(--surface-variant);
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-l);
  font-size: 14px;
  color: var(--on-surface);
  outline: none;
  transition: box-shadow 0.2s ease;
}
.search input:focus { box-shadow: 0 0 0 2px var(--primary); background: var(--bg); }

/* Playful Chips (Naive influence) */
.chips {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0;
}
.chip {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  border: none; padding: 6px 14px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chip:hover { filter: brightness(0.9); transform: scale(1.05); }
.chip.is-active { background: var(--primary); color: var(--on-primary); }

.statusrow { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.counts { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); }

/* Navigation Group & Items */
.list .group-title {
  font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin: 16px 0 8px 12px;
}

.item {
  width: 100%; text-align: left;
  background: transparent; border: none;
  padding: 12px 16px;
  border-radius: var(--radius-l);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}
.item:hover { background: var(--surface-variant); transform: translateX(4px); }
.item.active { background: var(--primary-container); border-left: 4px solid var(--primary); }
.item.active div { color: var(--on-primary-container) !important; font-weight: 700; }

.item .badge { font-family: var(--mono); font-size: 9px; color: var(--muted); opacity: 0.7; }

/* -------------------------
   Main Content Area
-------------------------- */
.content {
  padding: 24px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--surface-variant) 5%, var(--bg));
  display: flex; flex-direction: column; gap: 16px;
}

.view-header {
  margin-bottom: 8px;
  animation: fadeIn 0.4s ease;
}
.view-title { font-size: 28px; font-weight: 800; letter-spacing: -1px; color: var(--on-primary-container); }
.view-meta { font-size: 13px; color: var(--muted); margin-top: 4px; font-weight: 500; }

@keyframes fadeIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }

/* -------------------------
   Cards (Naive + M3)
-------------------------- */
.results { display: flex; flex-direction: column; gap: 20px; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 24px;
  border: 1px solid color-mix(in srgb, var(--outline) 8%, transparent);
  box-shadow: var(--shadow-soft);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}
.card:hover { transform: translateY(-4px) scale(1.01); box-shadow: var(--shadow-hover); border-color: var(--primary); }

.card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.card-title { font-size: 1.25rem; font-weight: 800; color: var(--primary); }
.card-id { font-family: var(--mono); font-size: 11px; color: var(--muted); background: var(--surface-variant); padding: 2px 8px; border-radius: 4px; }

.card-body { font-size: 15px; color: var(--on-surface-variant); line-height: 1.6; }

/* Playful Sections */
.clin-section {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px dashed var(--surface-variant);
}
.clin-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--muted); letter-spacing: 0.5px; margin-bottom: 8px;
}

.clin-list { list-style: none; padding: 0; margin: 0; }
.clin-list li {
  padding: 10px 14px; background: var(--surface-variant);
  border-radius: var(--radius-m); margin-bottom: 6px;
  font-size: 14px; position: relative;
  transition: background 0.2s;
}
.clin-list li:hover { background: color-mix(in srgb, var(--primary) 5%, var(--surface-variant)); }
.clin-list li::before { content: "✦"; margin-right: 10px; color: var(--primary); opacity: 0.6; }

/* Yields & Pitfalls (Naive Functional) */
.yield-item { border-left: 4px solid var(--good); background: color-mix(in srgb, var(--good) 5%, transparent) !important; color: var(--good); font-weight: 600; }
.pitfall-item { border-left: 4px solid var(--bad); background: color-mix(in srgb, var(--bad) 5%, transparent) !important; color: var(--bad); font-weight: 600; }

.pill {
  font-size: 11px; font-weight: 700; padding: 4px 12px;
  border-radius: 20px; background: var(--surface-variant);
  color: var(--on-surface-variant); text-transform: capitalize;
}
.pill.critical { background: var(--error); color: white; animation: pulse 2s infinite; }

@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(186, 26, 26, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(186, 26, 26, 0); } 100% { box-shadow: 0 0 0 0 rgba(186, 26, 26, 0); } }

/* -------------------------
   Calculators (v1.2.0)
-------------------------- */
.calculator-card { border: 2px solid var(--primary); background: color-mix(in srgb, var(--primary) 2%, white); }
.calc-field { margin-bottom: 16px; }
.calc-option {
  display: block; width: 100%; border: 1px solid var(--outline);
  border-radius: var(--radius-l); padding: 12px; margin-bottom: 4px;
  cursor: pointer; transition: all 0.2s;
}
.calc-option:hover { border-color: var(--primary); background: var(--primary-container); }
.calc-option:has(input:checked) { background: var(--primary); color: white; border-color: var(--primary); }
.calc-option input { display: none; }

/* -------------------------
   Simulation Bar
-------------------------- */
.sim-bar {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 40px); max-width: 900px;
  background: var(--panel); border-radius: 20px;
  padding: 16px 24px; box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  display: flex; gap: 20px; align-items: center;
  border: 1px solid var(--primary);
  z-index: 1000;
  animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp { from { transform: translate(-50%, 100px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* -------------------------
   Avatars & Overlays
-------------------------- */
.avatar-overlay { bottom: 80px; filter: drop-shadow(0 10px 20px rgba(0,0,0,0.1)); }
.avatar-bubble {
  background: var(--primary); color: white; border: none;
  font-weight: 500; font-size: 14px;
  border-radius: 20px 20px 0 20px;
}

/* -------------------------
   Responsive Grid Fix
-------------------------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; } /* Mobile sidebar behavior would need JS */
  .content { padding: 16px; }
}
