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

/* ── Medical Neobrutalism Design System ────────── */
:root {
  --bg: #f5f0e8;
  --bg-alt: #ede8dd;
  --white: #ffffff;
  --black: #1a1a2e;
  --border: 3px solid #1a1a2e;
  --border-thick: 4px solid #1a1a2e;
  --shadow: 6px 6px 0px #1a1a2e;
  --shadow-sm: 4px 4px 0px #1a1a2e;
  --shadow-hover: 8px 8px 0px #1a1a2e;
  --text: #1a1a2e;
  --text-light: #3a3a5e;
  --text-muted: #7a7a9a;

  /* Medical neo-brutal palette */
  --teal: #2EC4B6;
  --coral: #FF6B6B;
  --mint: #A8E6CF;
  --sky: #89CFF0;
  --lavender: #C3AED6;
  --yellow: #FFE156;
  --peach: #FFDAC1;
  --pink: #FFB5C2;
  --lime: #BFFF00;
  --blue: #4361EE;
  --orange: #FF9F1C;
  --green: #06D6A0;
  --red: #EF476F;

  --radius: 12px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
  --font: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'Space Mono', monospace;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Dotted Grid Background ────────────────────── */
body::before {
  content: '';
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background-image: radial-gradient(circle, rgba(26,26,46,0.07) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none; z-index: 0;
}

/* ── Floating Deco Shapes ──────────────────────── */
.floating-shapes { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; overflow: hidden; }
.shape { position: absolute; border: var(--border); animation: drift 22s ease-in-out infinite; }
.shape--1 { width: 70px; height: 70px; background: var(--yellow); top: 6%; left: 4%; border-radius: 50%; animation-delay: 0s; }
.shape--2 { width: 55px; height: 55px; background: var(--pink); top: 18%; right: 6%; border-radius: var(--radius); transform: rotate(12deg); animation-delay: -5s; }
.shape--3 { width: 48px; height: 48px; background: var(--mint); bottom: 12%; left: 8%; border-radius: 50%; animation-delay: -10s; }
.shape--4 { width: 60px; height: 60px; background: var(--sky); bottom: 22%; right: 4%; border-radius: var(--radius); transform: rotate(-8deg); animation-delay: -16s; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(12px, -16px) rotate(4deg); }
  50% { transform: translate(-8px, 12px) rotate(-2deg); }
  75% { transform: translate(16px, 8px) rotate(6deg); }
}

/* ── Container ─────────────────────────────────── */
.container { max-width: 960px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }

/* ── Hero ──────────────────────────────────────── */
.hero { padding: 48px 0 28px; text-align: center; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--yellow); border: var(--border); box-shadow: var(--shadow-sm);
  padding: 8px 20px; border-radius: 100px; font-size: 0.82rem;
  font-weight: 700; color: var(--text); margin-bottom: 18px;
  animation: popIn 0.5s ease both;
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.8rem); font-weight: 700;
  color: var(--text); margin-bottom: 10px; letter-spacing: -0.01em;
  animation: popIn 0.5s ease 0.1s both;
}
.hero h1 .gradient-text {
  background: linear-gradient(135deg, var(--teal), var(--blue), var(--coral));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero p {
  font-size: 1.08rem; color: var(--text-light); max-width: 600px;
  margin: 0 auto; animation: popIn 0.5s ease 0.2s both;
}

/* ── Disclaimer Banner ─────────────────────────── */
.disclaimer-banner {
  background: var(--peach); border: var(--border); box-shadow: var(--shadow-sm);
  border-radius: var(--radius); padding: 14px 20px; margin: 24px 0;
  display: flex; align-items: center; gap: 12px; font-size: 0.88rem;
  color: var(--text); font-weight: 600; animation: popIn 0.5s ease 0.3s both;
}
.disclaimer-banner .icon { font-size: 1.4rem; flex-shrink: 0; }

/* ── Stats Bar ─────────────────────────────────── */
.stats-bar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 28px; animation: popIn 0.5s ease 0.35s both;
}
.stat-item {
  padding: 14px; border: var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); display: flex; align-items: center;
  gap: 10px; font-weight: 700; font-size: 0.85rem;
  transition: var(--transition); cursor: default;
}
.stat-item:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hover); }
.stat-item:nth-child(1) { background: var(--mint); }
.stat-item:nth-child(2) { background: var(--sky); }
.stat-item:nth-child(3) { background: var(--lavender); }
.stat-item:nth-child(4) { background: var(--yellow); }
.stat-item .stat-icon { font-size: 1.3rem; }

/* ── Tabs ──────────────────────────────────────── */
.tabs {
  display: flex; border: var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 20px; background: var(--white);
}
.tab-btn {
  flex: 1; padding: 14px 16px; border: none; background: transparent;
  color: var(--text); font-family: var(--font); font-size: 0.95rem;
  font-weight: 700; cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-right: var(--border);
}
.tab-btn:last-child { border-right: none; }
.tab-btn:hover { background: var(--bg-alt); }
.tab-btn.active { background: var(--teal); color: var(--white); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease; }

/* ── Input Card ────────────────────────────────── */
.input-card {
  background: var(--white); border: var(--border-thick); box-shadow: var(--shadow);
  border-radius: var(--radius-lg); padding: 28px; position: relative;
}

.symptom-textarea {
  width: 100%; min-height: 130px; padding: 16px; background: var(--bg);
  border: var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font); font-size: 1rem;
  resize: vertical; transition: var(--transition); line-height: 1.6;
}
.symptom-textarea:focus { outline: none; box-shadow: var(--shadow-sm); background: var(--white); }
.symptom-textarea::placeholder { color: var(--text-muted); }

/* Chips */
.chip-section { margin-top: 18px; }
.chip-section h4 { font-size: 0.85rem; color: var(--text-light); margin-bottom: 10px; font-weight: 600; }
#symptom-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px; border-radius: 100px; font-size: 0.82rem; font-weight: 600;
  font-family: var(--font); background: var(--white); border: 2px solid var(--text);
  color: var(--text); cursor: pointer; transition: var(--transition);
  user-select: none; box-shadow: 2px 2px 0px var(--text);
}
.chip:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0px var(--text); background: var(--bg-alt); }
.chip.selected { background: var(--mint); transform: translate(2px, 2px); box-shadow: none; }

/* Button */
.btn-primary {
  display: inline-flex; align-items: center; gap: 10px; padding: 16px 36px;
  background: var(--teal); border: var(--border-thick); border-radius: var(--radius);
  color: var(--white); font-family: var(--font); font-size: 1.05rem; font-weight: 700;
  cursor: pointer; transition: var(--transition); margin-top: 18px;
  box-shadow: var(--shadow); letter-spacing: 0.01em;
}
.btn-primary:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hover); }
.btn-primary:active { transform: translate(3px, 3px); box-shadow: none; }

/* Voice */
.voice-container { display: flex; flex-direction: column; align-items: center; padding: 24px 0; }
#mic-btn {
  width: 110px; height: 110px; border-radius: 50%; border: var(--border-thick);
  background: var(--white); font-size: 2.8rem; cursor: pointer;
  transition: var(--transition); display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
#mic-btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hover); background: var(--mint); }
#mic-btn.recording { background: var(--coral); animation: brutPulse 1s infinite; box-shadow: var(--shadow); }
@keyframes brutPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.voice-status { margin-top: 18px; color: var(--text-light); font-size: 0.92rem; font-weight: 600; }
.voice-status.active { color: var(--green); }
.voice-status.error { color: var(--red); }
#voice-transcript {
  width: 100%; min-height: 60px; margin-top: 18px; padding: 16px;
  background: var(--bg); border: var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.95rem;
}
#voice-transcript .interim { color: var(--text-muted); font-style: italic; }

/* Image */
#image-dropzone {
  border: 3px dashed var(--text); border-radius: var(--radius-lg);
  padding: 52px 24px; text-align: center; cursor: pointer;
  transition: var(--transition); color: var(--text); background: var(--bg);
}
#image-dropzone:hover, #image-dropzone.dragover { background: var(--sky); box-shadow: var(--shadow-sm); }
#image-dropzone .drop-icon { font-size: 3.5rem; margin-bottom: 12px; }
#image-dropzone p { font-size: 0.95rem; font-weight: 600; }
#image-preview { display: none; margin-top: 16px; text-align: center; }
#image-preview img { max-width: 100%; max-height: 300px; border-radius: var(--radius); border: var(--border); box-shadow: var(--shadow-sm); }
.image-label { margin-top: 12px; color: var(--text-light); font-size: 0.9rem; font-weight: 600; }
#image-desc {
  display: none; width: 100%; margin-top: 14px; padding: 16px;
  background: var(--bg); border: var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font); font-size: 0.95rem;
  min-height: 80px; resize: vertical;
}
#image-desc:focus { outline: none; box-shadow: var(--shadow-sm); background: var(--white); }
#image-analyze-btn { display: none; }

/* ── Results ───────────────────────────────────── */
#results-section { display: none; margin-top: 40px; padding-bottom: 60px; }

/* Emergency Alert */
#emergency-alert {
  display: none; background: var(--coral); border: var(--border-thick);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 24px;
  box-shadow: var(--shadow); color: var(--white);
}
.emergency-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.emergency-icon { font-size: 2.2rem; }
.emergency-header h3 { color: var(--white); font-size: 1.1rem; font-weight: 700; text-transform: uppercase; }
#emergency-alert ul { list-style: none; }
#emergency-alert li { padding: 10px 0; color: var(--white); font-size: 0.95rem; font-weight: 600; border-bottom: 2px solid rgba(255,255,255,0.2); }
#emergency-alert li:last-child { border-bottom: none; }
.emergency-call {
  margin-top: 16px; padding: 14px; background: rgba(0,0,0,0.12);
  border-radius: var(--radius); text-align: center; color: var(--white);
  font-weight: 700; font-size: 1rem; border: 2px solid rgba(255,255,255,0.3);
}
.animate-alert { animation: shakeIn 0.5s ease; }
@keyframes shakeIn { 0% { transform: translateX(-8px); opacity: 0; } 25% { transform: translateX(8px); } 50% { transform: translateX(-4px); } 75% { transform: translateX(4px); } 100% { transform: translateX(0); opacity: 1; } }

/* Extracted Symptoms */
#extracted-symptoms { display: none; margin-bottom: 24px; }
#extracted-symptoms h4 { color: var(--text); margin-bottom: 12px; font-size: 1rem; font-weight: 700; }
.symptom-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.symptom-tag {
  padding: 6px 16px; border-radius: 100px; font-size: 0.82rem; font-weight: 700;
  background: var(--sky); border: 2px solid var(--text); color: var(--text);
  box-shadow: 2px 2px 0px var(--text);
}
.symptom-tag.matched { background: var(--mint); }

/* Disease Card */
.disease-card {
  background: var(--white); border: var(--border-thick);
  border-radius: var(--radius-lg); margin-bottom: 24px; overflow: hidden;
  box-shadow: var(--shadow); transition: var(--transition);
}
.disease-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hover); }
.card-header {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 28px; border-bottom: var(--border-thick);
}
.card-header-bg-1 { background: var(--yellow); }
.card-header-bg-2 { background: var(--pink); }
.card-header-bg-3 { background: var(--sky); }
.card-header-bg-4 { background: var(--mint); }
.card-header-bg-5 { background: var(--lavender); }
.rank {
  width: 48px; height: 48px; border-radius: var(--radius); display: flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 1.2rem;
  background: var(--white); border: var(--border); box-shadow: var(--shadow-sm);
  color: var(--text); flex-shrink: 0;
}
.card-title { flex: 1; }
.card-title h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 5px; }
.codes { display: flex; gap: 8px; flex-wrap: wrap; }
.code {
  font-size: 0.72rem; padding: 3px 10px; border-radius: 100px;
  font-weight: 700; font-family: var(--font-mono); border: 2px solid var(--text);
}
.code.icd { background: var(--lavender); }
.code.snomed { background: var(--sky); }

.probability { text-align: center; flex-shrink: 0; }
.probability small { color: var(--text-light); font-size: 0.78rem; font-weight: 700; }
.prob-circle { width: 60px; height: 60px; position: relative; }
.prob-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.prob-bg { fill: none; stroke: rgba(26,26,46,0.08); stroke-width: 3.5; }
.prob-fill { fill: none; stroke: var(--teal); stroke-width: 3.5; stroke-linecap: round; transition: stroke-dasharray 1s ease; }
.prob-circle span {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 0.9rem; font-weight: 700; color: var(--text); font-family: var(--font-mono);
}

.card-body { padding: 24px 28px; }
.section { margin-bottom: 22px; }
.section:last-child { margin-bottom: 0; }
.section h4 { font-size: 0.92rem; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.section p { color: var(--text-light); font-size: 0.95rem; line-height: 1.75; }
.section ul { list-style: none; }
.section li { padding: 6px 0 6px 22px; position: relative; color: var(--text-light); font-size: 0.9rem; font-weight: 500; }
.section li::before { content: '→'; position: absolute; left: 2px; color: var(--teal); font-weight: 700; }
.specialist {
  display: inline-block; padding: 10px 20px; background: var(--mint);
  border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  font-weight: 700 !important; color: var(--text) !important; font-size: 0.95rem !important;
}

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }

.warning-section {
  background: var(--peach); border: var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-top: 4px;
}

/* Disclaimer Box */
.disclaimer-box {
  background: var(--yellow); border: var(--border-thick); border-radius: var(--radius-lg);
  padding: 28px; text-align: center; margin-top: 8px; box-shadow: var(--shadow);
}
.disclaimer-icon { font-size: 2.8rem; margin-bottom: 14px; }
.disclaimer-box h4 { color: var(--text); margin-bottom: 12px; font-size: 1.05rem; font-weight: 700; }
.disclaimer-box p { color: var(--text-light); font-size: 0.9rem; line-height: 1.75; margin-bottom: 8px; }

/* Loading & No Results */
.loading { text-align: center; padding: 60px 0; }
.spinner {
  width: 52px; height: 52px; border: var(--border-thick); border-top-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite; margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--text-light); font-weight: 700; font-size: 1rem; }
.no-results { text-align: center; padding: 60px 0; }
.no-results-icon { font-size: 3.5rem; margin-bottom: 16px; }
.no-results h3 { margin-bottom: 10px; font-size: 1.2rem; }
.no-results p { color: var(--text-light); max-width: 500px; margin: 0 auto; }

/* Animations */
.animate-card { animation: slideUp 0.4s ease both; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* Footer */
.footer { text-align: center; padding: 32px 0; border-top: var(--border); margin-top: 40px; }
.footer p { color: var(--text-muted); font-size: 0.85rem; line-height: 1.8; font-weight: 500; }

/* ── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .hero { padding: 36px 0 20px; }
  .input-card { padding: 20px; }
  .card-header { flex-direction: column; align-items: flex-start; padding: 18px 20px; }
  .probability { align-self: flex-end; margin-top: -50px; }
  .card-body { padding: 20px; }
  .card-grid { grid-template-columns: 1fr; }
  .tabs { flex-direction: column; }
  .tab-btn { border-right: none; border-bottom: var(--border); }
  .tab-btn:last-child { border-bottom: none; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .floating-shapes { display: none; }
}