/* ============================================================
   Nowy Balans – Chat AI styles
   ============================================================ */

:root {
  --nbc-green:       #3a8a5c;
  --nbc-green-dark:  #2e6e49;
  --nbc-green-light: #e8f5ee;
  --nbc-bg:          #ffffff;
  --nbc-border:      #d4e6db;
  --nbc-text:        #1a2b22;
  --nbc-muted:       #6b7c72;
  --nbc-user-bg:     #3a8a5c;
  --nbc-user-text:   #ffffff;
  --nbc-bot-bg:      #f0f8f3;
  --nbc-bot-text:    #1a2b22;
  --nbc-shadow:      0 4px 24px rgba(58,138,92,.18);
  --nbc-radius:      16px;
  --nbc-font:        'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

/* ── Wrapper ─────────────────────────────────────────────── */
.nbc-chat-wrapper {
  font-family: var(--nbc-font);
  max-width: 680px;
  margin: 2rem auto;
  border-radius: var(--nbc-radius);
  box-shadow: var(--nbc-shadow);
  border: 1px solid var(--nbc-border);
  overflow: hidden;
  background: var(--nbc-bg);
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────── */
.nbc-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--nbc-green) 0%, var(--nbc-green-dark) 100%);
  color: #fff;
}

.nbc-avatar {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}

.nbc-header-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.nbc-header-text strong {
  font-size: 1rem;
  font-weight: 700;
}

.nbc-subtitle {
  font-size: .75rem;
  opacity: .85;
}

.nbc-toggle-btn {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s;
}
.nbc-toggle-btn:hover {
  background: rgba(255,255,255,.35);
}

/* ── Chat body ───────────────────────────────────────────── */
.nbc-chat-body {
  display: flex;
  flex-direction: column;
  max-height: 520px;
  transition: max-height .3s ease;
  overflow: hidden;
}

.nbc-chat-body.nbc-collapsed {
  max-height: 0;
}

/* ── Messages list ───────────────────────────────────────── */
.nbc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 380px;
  scroll-behavior: smooth;
}

.nbc-messages::-webkit-scrollbar {
  width: 5px;
}
.nbc-messages::-webkit-scrollbar-track {
  background: var(--nbc-green-light);
}
.nbc-messages::-webkit-scrollbar-thumb {
  background: var(--nbc-border);
  border-radius: 4px;
}

/* ── Individual message ──────────────────────────────────── */
.nbc-msg {
  display: flex;
  gap: 8px;
  animation: nbcFadeIn .25s ease;
}

.nbc-msg--user {
  flex-direction: row-reverse;
}

.nbc-msg-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--nbc-green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.nbc-msg--user .nbc-msg-icon {
  background: var(--nbc-green);
}

.nbc-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: .92rem;
  line-height: 1.55;
  word-break: break-word;
}

.nbc-msg--bot .nbc-bubble {
  background: var(--nbc-bot-bg);
  color: var(--nbc-bot-text);
  border-bottom-left-radius: 4px;
}

.nbc-msg--user .nbc-bubble {
  background: var(--nbc-user-bg);
  color: var(--nbc-user-text);
  border-bottom-right-radius: 4px;
}

/* Markdown-like formatting inside bot bubble */
.nbc-bubble strong { font-weight: 700; }
.nbc-bubble em     { font-style: italic; }
.nbc-bubble p      { margin: 0 0 .5em; }
.nbc-bubble p:last-child { margin-bottom: 0; }
.nbc-bubble ul, .nbc-bubble ol {
  margin: .4em 0 .4em 1.2em;
  padding: 0;
}
.nbc-bubble li { margin-bottom: .2em; }
.nbc-bubble code {
  background: rgba(0,0,0,.07);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .85em;
}

/* ── Typing indicator ────────────────────────────────────── */
.nbc-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--nbc-bot-bg);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.nbc-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nbc-green);
  display: inline-block;
  animation: nbcBounce 1.2s infinite ease-in-out;
}
.nbc-typing span:nth-child(2) { animation-delay: .2s; }
.nbc-typing span:nth-child(3) { animation-delay: .4s; }

/* ── Input area ──────────────────────────────────────────── */
.nbc-input-area {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 14px 6px;
  border-top: 1px solid var(--nbc-border);
  background: #fff;
}

.nbc-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--nbc-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: .93rem;
  font-family: var(--nbc-font);
  color: var(--nbc-text);
  background: var(--nbc-green-light);
  outline: none;
  transition: border-color .2s, background .2s;
  line-height: 1.45;
  max-height: 120px;
  overflow-y: auto;
}
.nbc-input:focus {
  border-color: var(--nbc-green);
  background: #fff;
}
.nbc-input::placeholder {
  color: var(--nbc-muted);
}

.nbc-send-btn {
  background: var(--nbc-green);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .1s;
}
.nbc-send-btn:hover:not(:disabled) {
  background: var(--nbc-green-dark);
}
.nbc-send-btn:active:not(:disabled) {
  transform: scale(.93);
}
.nbc-send-btn:disabled {
  background: var(--nbc-border);
  cursor: not-allowed;
}

/* ── Disclaimer ──────────────────────────────────────────── */
.nbc-disclaimer {
  margin: 0;
  padding: 4px 16px 10px;
  font-size: .72rem;
  color: var(--nbc-muted);
  text-align: center;
  background: #fff;
}

/* ── Error message ───────────────────────────────────────── */
.nbc-error .nbc-bubble {
  background: #fff0f0;
  color: #c0392b;
  border: 1px solid #f5c6cb;
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes nbcFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes nbcBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: .5; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .nbc-chat-wrapper {
    margin: 1rem;
    border-radius: 12px;
  }
  .nbc-bubble {
    max-width: 90%;
    font-size: .88rem;
  }
  .nbc-chat-body {
    max-height: 460px;
  }
}
