/* Nutri Coach — floating chatbot widget
   Button stacked above Quick-Tools FAB (#qt-fab) on bottom-right.
   Uses FytFree design system: --dark #0D2B1E, --gold #C9941A, --bg #FBF8F3 */

#nc-btn {
  position: fixed;
  bottom: 5rem;
  right: 1.25rem;
  z-index: 9001;
  background: #C9941A;
  color: #fff;
  border: none;
  border-radius: 26px;
  padding: 10px 16px 10px 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.22);
  transition: transform .2s, box-shadow .2s, opacity .2s;
  line-height: 1;
}
#nc-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 26px rgba(0,0,0,0.3);
}
#nc-btn svg {
  stroke: #fff;
  flex-shrink: 0;
}
#nc-btn.nc-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}

#nc-win {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9002;
  /* square panel, never larger than viewport */
  width: min(400px, calc(100vw - 2.5rem), calc(100vh - 2.5rem));
  height: min(400px, calc(100vw - 2.5rem), calc(100vh - 2.5rem));
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 44px rgba(0,0,0,0.28);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  border: 1px solid rgba(0,0,0,0.06);
}
#nc-win.nc-open {
  display: flex;
  animation: nc-slide-in .22s ease-out;
}
@keyframes nc-slide-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

#nc-header {
  background: #0D2B1E;
  color: #fff;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
#nc-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
#nc-avatar {
  width: 26px;
  height: 26px;
  background: #C9941A;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
#nc-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.1;
}
#nc-subtitle {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  line-height: 1.1;
  margin-top: 2px;
}
#nc-actions {
  display: flex;
  gap: 4px;
}
#nc-actions button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  font-family: inherit;
  transition: background .15s, color .15s;
}
#nc-actions button:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

#nc-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  background: #FBF8F3;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
#nc-body::-webkit-scrollbar {
  width: 6px;
}
#nc-body::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}

.nc-msg {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #1A1714;
}
.nc-msg-user {
  align-self: flex-end;
  background: #C9941A;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.nc-msg-assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.07);
  border-bottom-left-radius: 4px;
}
.nc-msg em, .nc-msg i {
  color: #6B6357;
  font-size: 12px;
  display: inline-block;
  margin-top: 4px;
}

.nc-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 12px 16px !important;
}
.nc-typing span {
  width: 6px;
  height: 6px;
  background: #6B6357;
  border-radius: 50%;
  animation: nc-bounce 1.2s infinite ease-in-out;
}
.nc-typing span:nth-child(2) { animation-delay: .15s; }
.nc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes nc-bounce {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}

#nc-input-wrap {
  border-top: 1px solid rgba(0,0,0,0.07);
  padding: 8px 10px;
  display: flex;
  gap: 6px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}
#nc-input {
  flex: 1;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 16px;
  padding: 7px 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 12.5px;
  resize: none;
  outline: none;
  max-height: 80px;
  line-height: 1.4;
  color: #1A1714;
  background: #fff;
}
#nc-input:focus {
  border-color: #C9941A;
}
#nc-send {
  background: #C9941A;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .15s;
}
#nc-send:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}
#nc-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#nc-disclaimer {
  background: #fff;
  padding: 5px 10px 7px;
  font-size: 9.5px;
  color: #6B6357;
  text-align: center;
  border-top: 1px solid rgba(0,0,0,0.05);
  line-height: 1.35;
  flex-shrink: 0;
}

/* Minimized state — only the header bar shows, like a chat head dock */
#nc-win.nc-minimized {
  width: auto;
  height: auto;
  max-width: 240px;
}
#nc-win.nc-minimized #nc-body,
#nc-win.nc-minimized #nc-input-wrap,
#nc-win.nc-minimized #nc-disclaimer {
  display: none;
}
#nc-win.nc-minimized #nc-header {
  cursor: pointer;
  border-radius: 14px;
}
#nc-win.nc-minimized #nc-min {
  display: none;
}

/* Tablet (≤768px) — square panel still bottom-right, just smaller; bigger tap targets */
@media (max-width: 768px) {
  #nc-win {
    width: min(360px, calc(100vw - 1.5rem), calc(100vh - 1.5rem));
    height: min(360px, calc(100vw - 1.5rem), calc(100vh - 1.5rem));
    bottom: 0.75rem;
    right: 0.75rem;
    border-radius: 12px;
  }
  #nc-actions {
    gap: 4px;
  }
  #nc-actions button {
    font-size: 18px;
    padding: 6px 8px;
    min-width: 36px;
    min-height: 36px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    -webkit-tap-highlight-color: rgba(255,255,255,0.3);
  }
  #nc-actions button:active {
    background: rgba(255,255,255,0.25);
  }
}

/* Mobile (≤600px) — rectangle panel CENTERED when open; docked bottom-right when minimized */
@media (max-width: 600px) {
  /* Open & not minimized: centered rectangle */
  #nc-win:not(.nc-minimized) {
    width: min(360px, calc(100vw - 1rem));
    height: min(540px, calc(100dvh - 1rem));
    max-height: calc(100dvh - 1rem);
    top: 50%;
    left: 50%;
    bottom: auto;
    right: auto;
    transform: translate(-50%, -50%);
  }
  #nc-win.nc-open:not(.nc-minimized) {
    animation: nc-fade-in .22s ease-out;
  }
  @keyframes nc-fade-in {
    from { opacity: 0; transform: translate(-50%, -48%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
  }
  /* Minimized on mobile: dock to bottom-right as a small chat head */
  #nc-win.nc-minimized {
    top: auto !important;
    left: auto !important;
    bottom: 1rem !important;
    right: 1rem !important;
    transform: none !important;
    width: auto !important;
    height: auto !important;
    max-width: 220px;
    max-height: none !important;
    min-width: 180px;
    animation: none !important;
  }
  #nc-btn {
    bottom: 4.5rem;
    right: 1rem;
    padding: 9px 13px 9px 11px;
    font-size: 12.5px;
    border-radius: 22px;
  }
  #nc-btn svg {
    width: 17px;
    height: 17px;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  #nc-btn span {
    display: none;
  }
  #nc-btn {
    padding: 10px;
    border-radius: 50%;
  }
}
