/* ============================================================
   Med Doctor Predictor — App Styles
   Modern medical UI with glassmorphism & smooth interactions
   ============================================================ */

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

/* ── Variables ───────────────────────────────────────────── */
:root {
  --bg-from:   #e8f4f8;
  --bg-mid:    #ddeef5;
  --bg-to:     #cce3ee;
  --surface:   rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --ink:       #0f1c2e;
  --muted:     #5a7288;
  --muted-2:   #8ea9bb;
  --accent:    #0b7a75;
  --accent-dk: #085c58;
  --accent-2:  #e07a5f;
  --accent-2dk:#b85d44;
  --line:      rgba(15, 28, 46, 0.08);
  --line-md:   rgba(15, 28, 46, 0.14);
  --shadow-sm: 0 2px 8px rgba(11, 122, 117, 0.08);
  --shadow:    0 8px 32px rgba(11, 122, 117, 0.12);
  --shadow-lg: 0 20px 60px rgba(11, 122, 117, 0.15);
  --radius:    1.25rem;
  --radius-sm: 0.75rem;
  --radius-xs: 0.5rem;
  --font:      'Inter', system-ui, sans-serif;
  --font-serif:'Playfair Display', Georgia, serif;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(11,122,117,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(224,122,95,0.15) 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-from) 0%, var(--bg-mid) 50%, var(--bg-to) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* ── Decorative Orbs ─────────────────────────────────────── */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.25;
  z-index: 0;
  pointer-events: none;
  animation: orb-drift 20s ease-in-out infinite alternate;
}
.orb-a { width: 32rem; height: 32rem; top: -10rem; right: -8rem; background: radial-gradient(circle, #5cc8be, #0b7a75); }
.orb-b { width: 26rem; height: 26rem; bottom: -10rem; left: -6rem; background: radial-gradient(circle, #f0b49a, #e07a5f); }

@keyframes orb-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(2rem, -2rem) scale(1.08); }
}

/* ── Layout Shell ────────────────────────────────────────── */
.site-shell {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 5rem;
}

/* ── Header ──────────────────────────────────────────────── */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 1.5rem;
  box-shadow: 0 4px 24px rgba(11, 122, 117, 0.08), 0 1px 0 rgba(255,255,255,0.8) inset;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--ink);
}
.brand strong { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.brand small  { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 1px; }

.brand-mark {
  width: 2.75rem;
  height: 2.75rem;
  display: inline-grid;
  place-items: center;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, var(--accent), #0d4a60);
  color: white;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 16px rgba(11, 122, 117, 0.35);
  flex-shrink: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.site-nav a {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  transition: background var(--transition), color var(--transition);
}
.site-nav a:hover { background: rgba(11,122,117,0.1); color: var(--accent); }

.nav-button {
  border: 0;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-2dk));
  color: white;
  font: 600 0.88rem/1 var(--font);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  box-shadow: 0 3px 12px rgba(224,122,95,0.3);
}
.nav-button:hover { opacity: 0.9; transform: translateY(-1px); }

/* ── Flash Messages ──────────────────────────────────────── */
.messages { display: grid; gap: 0.5rem; margin-bottom: 1.25rem; }

.message {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slide-in 0.3s ease;
}
.message.success { background: rgba(11,122,117,0.12); color: var(--accent-dk); border: 1px solid rgba(11,122,117,0.2); }
.message.error   { background: rgba(200,50,50,0.10); color: #8b1a1a; border: 1px solid rgba(200,50,50,0.18); }
.message.warning { background: rgba(224,160,50,0.12); color: #7a5a00; border: 1px solid rgba(224,160,50,0.2); }
.message::before { font-size: 1.1rem; }
.message.success::before { content: "✓"; }
.message.error::before   { content: "✕"; }
.message.warning::before { content: "⚠"; }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Panel (Card) ────────────────────────────────────────── */
.panel {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}

/* ── Typography ──────────────────────────────────────────── */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}
.eyebrow::before { content: ""; display: block; width: 1.5rem; height: 2px; background: var(--accent); border-radius: 2px; }

h1 { font: 700 2rem/1.2 var(--font-serif); letter-spacing: -0.02em; color: var(--ink); margin-bottom: 0.75rem; }
h2 { font: 600 1.4rem/1.25 var(--font-serif); color: var(--ink); margin-bottom: 0.6rem; }
h3 { font: 600 1rem/1.3 var(--font); color: var(--ink); margin-bottom: 0.4rem; }

.lead {
  color: var(--muted);
  font-size: 0.97rem;
  line-height: 1.75;
}

/* ── Hero Grid ───────────────────────────────────────────── */
.hero-grid,
.results-grid,
.history-top {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: start;
}

.hero-copy { padding: 2rem 2rem 1.75rem; }
.predictor-panel,
.result-hero,
.stat-panel,
.filter-panel,
.auth-panel { padding: 1.75rem; }

/* Hero decorative badge */
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  background: linear-gradient(135deg, rgba(11,122,117,0.12), rgba(11,122,117,0.06));
  border: 1px solid rgba(11,122,117,0.2);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1.25rem;
}
.hero-badge::before { content: "🏥"; }

/* Feature pills */
.hero-pills {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}
.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(15, 28, 46, 0.07);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
}

/* ── Predict Form ────────────────────────────────────────── */
.predict-form { display: grid; gap: 1rem; }

.predict-form label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.predict-form label::before { content: "✍"; font-size: 1rem; }

.form-field-wrap { position: relative; }

.predict-form textarea,
.predict-form input[type="text"],
.predict-form input[type="password"],
.filter-panel input[type="text"] {
  width: 100%;
  border: 1.5px solid var(--line-md);
  border-radius: var(--radius-sm);
  padding: 0.95rem 1.1rem;
  font: 0.9rem/1.6 var(--font);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.75);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}
.predict-form textarea:focus,
.predict-form input:focus,
.filter-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.12);
  background: rgba(255, 255, 255, 0.95);
}
.predict-form textarea {
  min-height: 10rem;
  resize: vertical;
}

/* char counter */
.char-counter {
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted-2);
  margin-top: -0.35rem;
}

.form-error {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #c0392b;
  font-size: 0.83rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  background: rgba(192, 57, 43, 0.07);
  border-radius: var(--radius-xs);
  border: 1px solid rgba(192, 57, 43, 0.15);
}
.form-error::before { content: "⚠"; }

/* ── Buttons ─────────────────────────────────────────────── */
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.95rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-dk));
  color: white;
  font: 600 0.92rem/1 var(--font);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-shadow: 0 6px 24px rgba(11, 122, 117, 0.28);
  letter-spacing: 0.01em;
}
.cta::after { content: "→"; transition: transform var(--transition); }
.cta:hover  { transform: translateY(-2px); box-shadow: 0 10px 32px rgba(11, 122, 117, 0.35); }
.cta:hover::after { transform: translateX(3px); }
.cta:active { transform: translateY(0); }

.cta.secondary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent-2dk));
  box-shadow: 0 6px 24px rgba(224, 122, 95, 0.28);
}
.cta.secondary:hover { box-shadow: 0 10px 32px rgba(224, 122, 95, 0.35); }
.cta.secondary::after { content: ""; }

/* Loading state */
.cta.loading { opacity: 0.7; pointer-events: none; }
.cta.loading::after { content: ""; width: 1rem; height: 1rem; border: 2px solid rgba(255,255,255,0.4); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hint {
  font-size: 0.8rem;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.hint::before { content: "ℹ"; color: var(--muted); }

/* ── Result Section ──────────────────────────────────────── */
.result-hero { position: relative; overflow: hidden; }
.result-hero::before {
  content: "";
  position: absolute;
  top: -3rem; right: -3rem;
  width: 10rem; height: 10rem;
  background: radial-gradient(circle, rgba(11,122,117,0.1), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.result-hero h2 {
  font-size: 1.55rem;
  color: var(--ink);
  margin: 0.5rem 0 0.75rem;
}

/* ── Candidate Bars ──────────────────────────────────────── */
.candidate-list {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.candidate-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(120px, 3fr) 3.5rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.45);
  border: 1px solid var(--line);
  transition: background var(--transition);
}
.candidate-row:first-child { background: rgba(11,122,117,0.07); border-color: rgba(11,122,117,0.18); }
.candidate-row:hover { background: rgba(255,255,255,0.7); }

.candidate-meta strong {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.candidate-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.candidate-bar {
  width: 100%;
  height: 0.55rem;
  background: rgba(15, 28, 46, 0.07);
  border-radius: 999px;
  overflow: hidden;
}
.candidate-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.candidate-row:first-child .candidate-fill { box-shadow: 0 0 8px rgba(11,122,117,0.4); }

.candidate-score {
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-dk);
  min-width: 3rem;
}
.candidate-row:first-child .candidate-score { color: var(--accent); }

/* ── Text Cards ──────────────────────────────────────────── */
.text-card {
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  margin-top: 0.85rem;
}
.text-card h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.text-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

/* ── Section Head ────────────────────────────────────────── */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 1.75rem 1.75rem 0;
}

.subtle-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(11,122,117,0.2);
  background: rgba(11,122,117,0.06);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.subtle-link:hover { background: rgba(11,122,117,0.14); }

/* ── History Preview Cards ───────────────────────────────── */
.history-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1.25rem 1.75rem 1.75rem;
}

.history-card {
  padding: 1.1rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.history-card:hover { background: rgba(255,255,255,0.85); transform: translateY(-2px); box-shadow: var(--shadow); }

.history-card h3 { font-size: 0.93rem; font-weight: 700; margin: 0; }
.history-card p  { font-size: 0.82rem; color: var(--muted); line-height: 1.5; flex: 1; }
.history-card small { font-size: 0.73rem; color: var(--muted-2); margin-top: auto; }

/* ── History Label Badge ─────────────────────────────────── */
.history-label {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(11,122,117,0.12), rgba(11,122,117,0.06));
  border: 1px solid rgba(11,122,117,0.2);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-dk);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-top: 1.25rem;
}

.stat-card {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.5);
  border: 1px solid var(--line);
  text-align: center;
}
.stat-icon  { font-size: 1.4rem; margin-bottom: 0.4rem; }
.stat-number {
  display: block;
  font: 700 1.65rem/1 var(--font-serif);
  color: var(--accent-dk);
  margin-bottom: 0.25rem;
}
.stat-card small { font-size: 0.73rem; color: var(--muted); font-weight: 500; }

/* ── Filter Panel ────────────────────────────────────────── */
.filter-panel {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}
.filter-panel label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
}

/* ── History Stack ───────────────────────────────────────── */
.history-stack { display: grid; gap: 1.1rem; }

.history-item {
  padding: 1.5rem;
  transition: box-shadow var(--transition), transform var(--transition);
}
.history-item:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }

.history-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}
.history-item-head small {
  font-size: 0.78rem;
  color: var(--muted-2);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin: 0.5rem 0 1.1rem;
}
.history-columns > div {
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.45);
  border: 1px solid var(--line);
}
.history-columns h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.history-columns p { font-size: 0.87rem; color: var(--muted); }

.compact .candidate-row {
  grid-template-columns: minmax(0, 1.5fr) minmax(80px, 2fr) 3rem;
  padding: 0.45rem 0.65rem;
}

/* ── Auth / Login ────────────────────────────────────────── */
.auth-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 10rem);
  padding: 1rem;
}

.auth-panel {
  width: min(480px, 100%);
  padding: 2.25rem;
}

.auth-panel h1 { text-align: center; margin-bottom: 0.25rem; }
.auth-panel .eyebrow { display: flex; justify-content: center; }

.auth-icon {
  display: flex;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

/* Django's form.as_p styling */
.predict-form p { display: grid; gap: 0.35rem; }
.predict-form p label { font-weight: 600; font-size: 0.88rem; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-panel {
  padding: 3.5rem 2rem;
  text-align: center;
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; display: block; }
.empty-panel h2 { color: var(--muted); font-size: 1.2rem; }
.empty-panel p  { color: var(--muted-2); font-size: 0.9rem; margin-top: 0.4rem; }
.empty-panel a  {
  display: inline-block;
  margin-top: 1.25rem;
  padding: 0.65rem 1.4rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-dk));
  color: white;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: opacity var(--transition), transform var(--transition);
}
.empty-panel a:hover { opacity: 0.9; transform: translateY(-1px); }

/* ── Inline Note ─────────────────────────────────────────── */
.inline-note {
  display: inline;
  color: var(--accent-dk);
  font-weight: 500;
}

/* ── Pagination / utility ────────────────────────────────── */
.page-info {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted-2);
  padding: 0.5rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .hero-grid,
  .results-grid,
  .history-top { grid-template-columns: 1fr; }

  .history-columns,
  .stats-grid { grid-template-columns: 1fr 1fr; }

  .candidate-row { grid-template-columns: 1fr auto auto; }

  .site-header { border-radius: var(--radius-sm); }
}

@media (max-width: 600px) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .stats-grid  { grid-template-columns: 1fr; }
  .history-columns { grid-template-columns: 1fr; }
  .candidate-row { grid-template-columns: 1fr; gap: 0.4rem; }
  .candidate-score { text-align: left; }
  h1 { font-size: 1.6rem; }
  .hero-copy, .predictor-panel, .result-hero, .stat-panel, .filter-panel, .auth-panel { padding: 1.25rem; }
  .section-head { flex-direction: column; align-items: flex-start; padding: 1.25rem 1.25rem 0; }
  .history-preview { padding: 1rem 1.25rem 1.25rem; }
  .history-item { padding: 1.1rem; }
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.panel { animation: fade-up 0.4s ease both; }
.hero-grid .panel:nth-child(2)    { animation-delay: 0.07s; }
.results-grid .panel:nth-child(2) { animation-delay: 0.07s; }
.history-stack .panel             { animation: fade-up 0.35s ease both; }
.history-stack .panel:nth-child(2){ animation-delay: 0.05s; }
.history-stack .panel:nth-child(3){ animation-delay: 0.10s; }
.history-stack .panel:nth-child(4){ animation-delay: 0.15s; }
.history-stack .panel:nth-child(5){ animation-delay: 0.20s; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(11,122,117,0.3); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(11,122,117,0.5); }
