/* ---------------------------------------------------------------
   LIVE SUPPORT CHAT (farmer side) - panel above the green chat button.
   Uses the app's theme colours so it follows light / dark mode.
--------------------------------------------------------------- */
.support-fab { position: fixed; }                       /* (the button itself is styled in app.css) */
.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #d32f2f;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--patusi-surface, #fff);
}

.chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 5.6rem;
  width: min(380px, calc(100vw - 1.5rem));
  height: min(520px, calc(100vh - 8rem));
  display: flex;
  flex-direction: column;
  background: var(--patusi-surface, #fff);
  color: var(--patusi-text, #212529);
  border: 1px solid var(--patusi-border, #ccc);
  border-radius: 1rem;
  box-shadow: 0 12px 34px var(--patusi-shadow, rgba(0, 0, 0, 0.25));
  z-index: 1060;
  overflow: hidden;
}
.chat-panel.d-none { display: none !important; }
@media (max-width: 480px) {
  .chat-panel { right: 0.75rem; bottom: 5.4rem; width: calc(100vw - 1.5rem); height: min(72vh, calc(100vh - 7rem)); }
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--patusi-primary, #1B5E20);
  color: #fff;
}
.chat-title { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.chat-sub { font-size: 0.78rem; opacity: 0.9; }
.chat-close {
  background: transparent;
  border: 0;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.chat-close:hover { background: rgba(255, 255, 255, 0.18); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: var(--patusi-bg, #f6f7f6);
  -webkit-overflow-scrolling: touch;
}
.chat-msg { display: flex; flex-direction: column; max-width: 86%; }
.chat-msg-user { align-self: flex-end; align-items: flex-end; }
.chat-msg-admin, .chat-msg-note { align-self: flex-start; align-items: flex-start; }
.chat-bubble {
  padding: 0.5rem 0.75rem;
  border-radius: 0.9rem;
  font-size: 0.92rem;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-msg-user .chat-bubble { background: var(--patusi-secondary, #2E7D32); color: #fff; border-bottom-right-radius: 0.25rem; }
.chat-msg-admin .chat-bubble { background: var(--patusi-surface, #fff); color: var(--patusi-text, #212529); border: 1px solid var(--patusi-border, #ccc); border-bottom-left-radius: 0.25rem; }
.chat-msg-note .chat-bubble { background: transparent; border: 1px dashed var(--patusi-border, #ccc); color: var(--patusi-text-muted, #666); }
.chat-meta { font-size: 0.7rem; color: var(--patusi-text-muted, #777); margin-top: 0.15rem; }
.chat-msg-note .chat-bubble a { color: inherit; font-weight: 600; }

.chat-status { min-height: 1.2rem; padding: 0 0.85rem; font-size: 0.78rem; color: #c62828; background: var(--patusi-surface, #fff); }
.chat-status:empty { display: none; }

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--patusi-border, #ccc);
  background: var(--patusi-surface, #fff);
}
.chat-form.d-none { display: none !important; }
.chat-input {
  flex: 1;
  resize: none;
  max-height: 7.5rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--patusi-border, #ccc);
  border-radius: 0.75rem;
  background: var(--patusi-bg, #fff);
  color: var(--patusi-text, #212529);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.35;
}
.chat-input:focus { outline: 2px solid var(--patusi-secondary, #2E7D32); outline-offset: 0; }
.chat-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--patusi-primary, #1B5E20);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.chat-send:disabled { opacity: 0.5; cursor: default; }

@media print {
  .chat-panel, .chat-badge { display: none !important; }
}
