/* ============================================================
   MamaWell — Global Styles
   Palette:
     --green-dark    : #1B5E3B  (header, buttons, user bubbles)
     --green-medium  : #2D7A53  (links, accents)
     --green-light   : #40916C  (hover states)
     --green-pale    : #A7F3C9  (subtle highlights)
     --bg            : #F0FAF4  (page background)
     --surface       : #FFFFFF  (cards, bot bubbles)
   ============================================================ */

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

:root {
  --green-dark   : #1B5E3B;
  --green-medium : #2D7A53;
  --green-light  : #40916C;
  --green-pale   : #A7F3C9;
  --bg           : #F0FAF4;
  --surface      : #FFFFFF;
  --text-dark    : #1A2E23;
  --text-mid     : #4A6558;
  --text-light   : #8AA898;
  --shadow-sm    : 0 1px 4px rgba(0,0,0,.08);
  --shadow-md    : 0 4px 16px rgba(0,0,0,.12);
  --radius-lg    : 18px;
  --radius-sm    : 10px;
  font-family    : 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body { background: var(--bg); color: var(--text-dark); line-height: 1.55; }

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

button { cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 1rem; outline: none; }

/* ── Auth pages ───────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 32px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

/* Logo */
.logo-wrap { margin-bottom: 12px; }
.logo-circle {
  width: 56px; height: 56px;
  margin: 0 auto;
}
.logo-circle img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

/* Brand heading */
.brand-title { font-size: 1.9rem; margin-bottom: 4px; letter-spacing: -0.3px; }
.brand-bold  { color: var(--green-dark); font-weight: 800; }
.brand-light { color: var(--green-medium); font-weight: 500; }

.brand-sub {
  color: var(--text-mid);
  font-size: 0.875rem;
  margin-bottom: 28px;
}

/* Form */
.auth-form { display: flex; flex-direction: column; gap: 14px; }

.field-group input,
.select-field {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid #D6EDE0;
  border-radius: var(--radius-sm);
  background: #FAFFFE;
  color: var(--text-dark);
  transition: border-color .2s;
}
.field-group input:focus,
.select-field:focus { border-color: var(--green-light); }

.select-label {
  display: block;
  text-align: left;
  font-size: 0.8rem;
  color: var(--text-mid);
  margin-bottom: 4px;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 5px;
  text-align: left;
}

/* Password visibility toggle */
.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrap input {
  width: 100%;
  padding-right: 44px !important;
}
.pw-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  display: flex;
  align-items: center;
  padding: 0;
  line-height: 1;
}
.pw-toggle:hover { color: var(--green-medium); }
.pw-toggle svg { width: 18px; height: 18px; }

.forgot-row {
  text-align: right;
  margin-top: -6px;
}

.link-green { color: var(--green-medium); font-size: 0.875rem; }
.link-green:hover { color: var(--green-dark); }

.font-semibold { font-weight: 600; }

/* User-type radio card grid */
.user-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 1.5px solid #D6EDE0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #FAFFFE;
  transition: border-color .2s, background .2s;
  user-select: none;
}
.type-card:hover {
  border-color: var(--green-light);
  background: var(--bg);
}
.type-card input[type="radio"] {
  display: none;
}
.type-card:has(input:checked) {
  border-color: var(--green-dark);
  background: #E8F5EE;
}
.type-icon  { font-size: 1.6rem; line-height: 1; }
.type-label { font-size: 0.8rem; font-weight: 500; color: var(--text-dark); text-align: center; }

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--green-dark);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  transition: background .2s, transform .1s;
  letter-spacing: 0.3px;
}
.btn-primary:hover { background: var(--green-light); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-ghost {
  padding: 10px 20px;
  border: 1.5px solid var(--green-dark);
  border-radius: var(--radius-sm);
  color: var(--green-dark);
  font-weight: 600;
  transition: background .2s;
}
.btn-ghost:hover { background: var(--bg); }

/* Error message */
.error-msg {
  background: #FEE2E2;
  color: #B91C1C;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.875rem;
  text-align: left;
}
.hidden { display: none !important; }

.auth-switch { margin-top: 20px; font-size: 0.9rem; color: var(--text-mid); }

.powered-by {
  margin-top: 24px;
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--text-light);
}

/* ── Chat layout ──────────────────────────────────────────── */
.chat-body { height: 100dvh; overflow: hidden; background: var(--bg); }

.chat-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--green-dark);
  color: white;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.menu-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
}
.menu-btn span {
  display: block;
  width: 20px; height: 2px;
  background: white;
  border-radius: 2px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}
.header-logo {
  width: 32px; height: 32px;
  flex-shrink: 0;
}
.header-logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.header-title { font-size: 1rem; font-weight: 600; color: white; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bell-btn {
  position: relative;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
}
.bell-btn svg { width: 20px; height: 20px; }
.bell-badge {
  position: absolute;
  top: -2px; right: -2px;
  background: #EF4444;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}
.heart-icon { font-size: 1.2rem; }

/* Notification dropdown */
.notif-dropdown {
  position: absolute;
  top: 64px; right: 8px;
  width: 290px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 200;
  overflow: hidden;
}
.notif-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--green-dark);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
}
.notif-list { max-height: 300px; overflow-y: auto; }
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid #E8F5E9;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-dark);
}
.notif-item:last-child { border-bottom: none; }
.notif-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-light);
  font-size: 0.875rem;
}

/* Toast notification */
.notif-toast {
  position: fixed;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  max-width: 340px; width: 90%;
  background: var(--surface);
  border-left: 4px solid var(--green-dark);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  z-index: 1000;
  animation: slideDown .35s ease;
}
.notif-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green-dark);
  flex-shrink: 0;
  margin-top: 4px;
}
.notif-toast p { flex: 1; font-size: 0.875rem; line-height: 1.5; color: var(--text-dark); }
.notif-close {
  font-size: 0.75rem;
  color: var(--text-light);
  flex-shrink: 0;
  padding: 2px 4px;
}
.notif-close:hover { color: var(--text-dark); }

@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Side menu */
.side-menu {
  position: absolute;
  top: 0; left: 0;
  width: 280px; height: 100%;
  background: var(--surface);
  z-index: 300;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 16px rgba(0,0,0,.15);
  transform: translateX(0);
}
.side-menu.hidden { display: none; }

.menu-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 299;
}
.menu-overlay.hidden { display: none; }

.side-menu-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  background: var(--green-dark);
  color: white;
}
.side-user { display: flex; align-items: center; gap: 10px; }
.side-avatar { font-size: 1.8rem; }
.side-name  { font-weight: 600; font-size: 0.95rem; color: white; }
.side-email { font-size: 0.75rem; color: rgba(255,255,255,.7); }
.side-close { color: white; font-size: 1.1rem; padding: 4px; }

.side-links {
  list-style: none;
  padding: 16px 0;
  flex: 1;
  overflow-y: auto;
}
.side-section {
  padding: 8px 16px 4px;
  font-size: 0.7rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-light);
}
.side-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 20px;
  font-size: 0.9rem;
  color: var(--text-dark);
  border-radius: 0;
  transition: background .15s;
}
.side-link:hover { background: var(--bg); }

.lang-select {
  display: block;
  width: calc(100% - 40px);
  margin: 0 20px;
  padding: 10px 12px;
  border: 1.5px solid #D6EDE0;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-dark);
  font-size: 0.9rem;
}

.doc-list-wrap { padding: 0 20px 8px; font-size: 0.8rem; color: var(--text-mid); }

.side-logout {
  margin: 12px 16px 24px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #FECACA;
  color: #B91C1C;
  font-size: 0.9rem;
  font-weight: 600;
  width: calc(100% - 32px);
  text-align: center;
  transition: background .2s;
}
.side-logout:hover { background: #FEF2F2; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}
.modal-card h3 { font-size: 1.1rem; color: var(--green-dark); margin-bottom: 8px; }
.modal-sub { font-size: 0.875rem; color: var(--text-mid); margin-bottom: 20px; line-height: 1.5; }

.file-input { display: none; }
.file-label {
  display: block;
  padding: 14px 16px;
  border: 2px dashed #B2DEC7;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-mid);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 20px;
}
.file-label:hover { border-color: var(--green-light); background: var(--bg); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.upload-msg { font-size: 0.875rem; margin-top: 10px; }

/* ── Chat messages ────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

/* Message rows */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: fadeInUp .2s ease;
}
.msg-row.user  { flex-direction: row-reverse; }
.msg-row.bot   { flex-direction: row; }

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

.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--green-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green-dark);
  flex-shrink: 0;
  overflow: hidden;
}
.msg-avatar.bot-avatar {
  background: transparent;
}
.msg-avatar img {
  width: 80%; height: 80%;
  object-fit: contain;
  border-radius: 0;
}

.msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.925rem;
  line-height: 1.55;
  word-break: break-word;
}
.msg-row.bot  .msg-bubble {
  background: var(--surface);
  color: var(--text-dark);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.msg-row.user .msg-bubble {
  background: var(--green-dark);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 3px;
  padding: 0 2px;
}
.msg-row.user .msg-actions { justify-content: flex-end; }
.msg-row.bot  .msg-actions { justify-content: flex-start; }

.msg-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 6px;
  color: var(--text-light);
  transition: color .2s, background .2s;
}
.msg-action-btn:hover { color: var(--green-medium); background: rgba(0,0,0,.05); }
.msg-action-btn svg   { width: 13px; height: 13px; }

.msg-time {
  font-size: 0.68rem;
  color: var(--text-light);
  margin-top: 3px;
  padding: 0 4px;
}

/* Typing indicator */
.typing-dots {
  display: flex; gap: 4px; align-items: center;
  padding: 12px 16px;
}
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green-pale);
  animation: dot-bounce .9s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .5; }
  40%           { transform: scale(1);  opacity: 1;  }
}

/* Clickable phone numbers */
.phone-link {
  color: var(--green-medium);
  font-weight: 600;
  text-decoration: underline;
  white-space: nowrap;
}
.phone-link:hover { color: var(--green-dark); }

/* Markdown-ish formatting in bot bubbles */
.msg-bubble ul, .msg-bubble ol {
  padding-left: 18px;
  margin-top: 6px;
}
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; }

/* ── Input bar ────────────────────────────────────────────── */
.chat-input-bar {
  padding: 10px 12px 12px;
  background: var(--surface);
  border-top: 1px solid #E0F0E6;
  flex-shrink: 0;
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid #C8E6C9;
  border-radius: 22px;
  padding: 8px 8px 8px 16px;
  transition: border-color .2s;
}
.input-wrap:focus-within { border-color: var(--green-light); }

.input-wrap textarea {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  max-height: 120px;
  font-size: 0.95rem;
  color: var(--text-dark);
  line-height: 1.5;
  padding: 2px 0;
}
.input-wrap textarea::placeholder { color: var(--text-light); }

.send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--green-dark);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .1s;
}
.send-btn:hover  { background: var(--green-light); }
.send-btn:active { transform: scale(.93); }
.send-btn:disabled { opacity: .5; cursor: not-allowed; }
.send-btn svg { width: 18px; height: 18px; }

.disclaimer {
  font-size: 0.68rem;
  color: var(--text-light);
  text-align: center;
  margin-top: 6px;
}

/* ── Scrollbar ────────────────────────────────────────────── */
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--green-pale);
  border-radius: 2px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (min-width: 640px) {
  .chat-shell {
    border-left: 1px solid #D6EDE0;
    border-right: 1px solid #D6EDE0;
    box-shadow: var(--shadow-md);
  }
}

/* ── Forgot-password modal ────────────────────────────────── */
.fp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 16px;
}
.fp-modal-overlay.hidden { display: none; }

.fp-modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 28px 28px;
  width: 100%;
  max-width: 380px;
  position: relative;
  box-shadow: var(--shadow-md);
}

.fp-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-mid);
  cursor: pointer;
  line-height: 1;
}
.fp-close:hover { color: var(--green-dark); }

.fp-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 8px;
}

.fp-sub {
  font-size: 0.88rem;
  color: var(--text-mid);
  margin-bottom: 20px;
  line-height: 1.5;
}

.fp-resend {
  font-size: 0.82rem;
  color: var(--text-mid);
  text-align: center;
  margin-top: 14px;
}
