/* =========================================================
   Sprout3D — Shared Stylesheet
   Brand: SureStep / Hanger
   ========================================================= */

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

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

:root {
  --green-primary:  #3B6D11;
  --green-mid:      #639922;
  --green-light:    #EAF3DE;
  --teal:           #0F6E56;
  --teal-light:     #E1F5EE;
  --bg:             #f8f7f4;
  --white:          #ffffff;
  --text:           #1a2e0a;
  --text-muted:     #6b7a5e;
  --border:         #d8e8c4;
  --shadow-sm:      0 1px 4px rgba(0,0,0,.06);
  --shadow-md:      0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.10);
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      20px;
  --radius-xl:      28px;
  --font-heading:   'DM Serif Display', serif;
  --font-body:      'DM Sans', sans-serif;
  --transition:     .18s ease;
}

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-heading); line-height: 1.2; }

a { color: var(--green-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, .btn {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--transition);
}

/* ── Utility ──────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* ── Status Badges ─────────────────────────────────────  */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.badge-created        { background: #f0f0f0; color: #555; }
.badge-sent_to_clinic { background: #EAF3DE; color: #3B6D11; }
.badge-contacted      { background: #dbeafe; color: #1e40af; }
.badge-scheduled      { background: #fef3c7; color: #92400e; }
.badge-completed      { background: #d1fae5; color: #065f46; }

/* Severity */
.badge-mild         { background: #d1fae5; color: #065f46; }
.badge-moderate     { background: #fef3c7; color: #92400e; }
.badge-significant  { background: #fee2e2; color: #991b1b; }

/* ── Logo / Wordmark ───────────────────────────────────  */
.logo {
  font-family: var(--font-heading);
  font-size: 22px;
  color: var(--green-primary);
  display: flex;
  align-items: center;
  gap: 2px;
}
.logo .three { color: var(--green-mid); }
.logo-sub { font-family: var(--font-body); font-size: 11px; color: var(--text-muted); margin-top: -2px; }

/* ── Primary Button ────────────────────────────────────  */
.btn-primary {
  background: var(--green-primary);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary:hover { background: #2d5509; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--white);
  color: var(--green-primary);
  border: 1.5px solid var(--border);
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-secondary:hover { background: var(--green-light); border-color: var(--green-mid); }

.btn-teal {
  background: var(--teal);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-teal:hover { background: #0a5241; }

.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
  border-radius: var(--radius-md);
  width: 100%;
  justify-content: center;
}

/* ── Card ──────────────────────────────────────────────  */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

/* ── Form elements ─────────────────────────────────────  */
input, select, textarea {
  font-family: var(--font-body);
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  background: var(--white);
  color: var(--text);
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(99,153,34,.12);
}

/* =========================================================
   CHATBOT PAGE
   ========================================================= */
.chat-layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  max-width: 700px;
  margin: 0 auto;
}

/* Header */
.chat-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.chat-avatar {
  width: 40px; height: 40px;
  background: var(--green-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-name { font-weight: 600; font-size: 15px; }
.chat-header-sub { font-size: 12px; color: var(--text-muted); }

/* Progress bar */
.progress-bar {
  height: 3px;
  background: var(--border);
  margin: 0;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-primary), var(--green-mid));
  transition: width .4s ease;
  width: 0%;
}

/* Messages area */
.chat-messages {
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Bubbles */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 85%;
  animation: fadeUp .2s ease both;
}
.msg.ai { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }

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

.msg-avatar {
  width: 30px; height: 30px;
  background: var(--green-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
}
.msg.ai .msg-bubble {
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.msg.user .msg-bubble {
  background: var(--green-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
  display: flex; gap: 4px; align-items: center;
  padding: 12px 14px;
}
.typing-indicator span {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce .8s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Photo preview chips */
.photo-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 0;
}
.photo-chip {
  position: relative;
  width: 64px; height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.photo-chip img { width: 100%; height: 100%; object-fit: cover; }
.photo-chip .remove-photo {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,.5);
  color: #fff; border: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Input area */
.chat-input-area {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 14px;
}
.chat-input-row textarea {
  border: none;
  background: transparent;
  padding: 4px 0;
  resize: none;
  font-size: 15px;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  flex: 1;
}
.chat-input-row textarea:focus { box-shadow: none; }

.btn-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.btn-send {
  background: var(--green-primary);
  color: #fff;
}
.btn-send:hover { background: #2d5509; }
.btn-send:disabled { background: var(--border); cursor: not-allowed; }

.btn-attach {
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
}
.btn-attach:hover { color: var(--green-primary); }

/* Report card inside chat */
.report-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  max-width: 380px;
}
.report-card h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  color: var(--green-primary);
  margin-bottom: 12px;
}
.report-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

/* =========================================================
   CASE PAGE
   ========================================================= */
.case-layout {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.case-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.case-section {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 20px;
  margin-top: 16px;
}
.case-section h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.case-field { margin-bottom: 12px; }
.case-field label { font-size: 12px; color: var(--text-muted); font-weight: 500; display: block; margin-bottom: 2px; }
.case-field p { font-size: 15px; }

.status-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.status-event {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green-mid);
  flex-shrink: 0;
}

/* Status action buttons */
.status-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}
.status-actions .btn-status {
  padding: 18px 24px;
  border-radius: var(--radius-md);
  font-size: 17px;
  font-weight: 600;
  width: 100%;
  text-align: center;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}
.btn-status-primary { background: var(--green-primary); color: #fff; }
.btn-status-primary:hover { background: #2d5509; }
.btn-status-secondary { background: var(--white); color: var(--teal); border: 2px solid var(--teal) !important; }
.btn-status-secondary:hover { background: var(--teal-light); }
.btn-status-done { background: var(--green-light); color: var(--green-primary); cursor: default; }
.btn-status-completed { background: var(--teal); color: #fff; }
.btn-status-completed:hover { background: #0a5241; }

/* Photos grid */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.photos-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: zoom-in;
}

/* Lightbox */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 4px; }
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  color: #fff; font-size: 28px; cursor: pointer;
  background: none; border: none;
}

/* =========================================================
   ADMIN DASHBOARD
   ========================================================= */
.admin-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

.admin-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

/* Login gate */
.login-gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card p { color: var(--text-muted); margin-bottom: 24px; }

/* Filters */
.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
  align-items: center;
}
.admin-filters input,
.admin-filters select {
  width: auto;
  min-width: 160px;
  padding: 8px 12px;
  font-size: 14px;
}

/* Stats bar */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  flex: 1;
  min-width: 120px;
  text-align: center;
}
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--green-primary); }
.stat-card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }

/* Case table */
.cases-table-wrap { overflow-x: auto; }
.cases-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.cases-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--green-light);
  color: var(--green-primary);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.cases-table th:hover { background: #d8eac0; }
.cases-table td {
  padding: 12px;
  border-bottom: 1px solid #f0f0e8;
  vertical-align: middle;
}
.cases-table tr:last-child td { border-bottom: none; }
.cases-table tr:hover td { background: #fafaf7; cursor: pointer; }

/* Detail modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-md);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--white);
}
.modal-body { padding: 24px; }
.modal-close {
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: var(--text-muted);
}
.modal-close:hover { color: var(--text); }

/* Admin status override dropdown */
.admin-status-select {
  width: auto;
  display: inline-block;
  font-size: 14px;
  padding: 6px 10px;
}

/* Responsive tweaks */
@media (max-width: 600px) {
  .chat-layout { max-width: 100%; }
  .case-layout { padding: 16px 12px 80px; }
  .admin-layout { padding: 0 12px 64px; }
  .cases-table th, .cases-table td { padding: 8px; }
}
