/* Bazowe zmienne (noc jako domyślna) */
:root{
  --bg: #0b0d12;
  --card: #121725;
  --muted: #94a3b8;
  --text: #e6eefc;
  --primary: #4f8cff;
  --primary-2: #235dff;
  --accent: #10b981;
  --danger: #ef4444;
  --bubble-bot: #1a2236;
  --bubble-user: #1d2b50;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 16px;
}

/* Dzień: jaśniejsza paleta i cieplejsze akcenty */
body.day{
  --bg:#eef2f7;
  --card:#ffffff;
  --muted:#475569;
  --text:#0f172a;
  --primary:#3b82f6;
  --primary-2:#2563eb;
  --accent:#0ea5e9;
  --bubble-bot:#f7fafc;
  --bubble-user:#e9eef9;
  --shadow:0 10px 25px rgba(2,6,23,.08);
}

/* Noc: ciemniejsza paleta (domyślna) */
body.night{
  --bg:#0b0d12;
  --card:#121725;
  --muted:#94a3b8;
  --text:#e6eefc;
  --primary:#4f8cff;
  --primary-2:#235dff;
  --accent:#10b981;
  --bubble-bot:#1a2236;
  --bubble-user:#1d2b50;
  --shadow:0 10px 30px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
html,body{height:100%}

/* Tła globalne */
body{
  margin:0;
  color:var(--text);
  font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  display:flex; align-items:center; justify-content:center; padding:12px;
  background:
    radial-gradient(1200px 800px at 80% -10%, rgba(79,140,255,.25), transparent 60%),
    radial-gradient(800px 600px at -10% 100%, rgba(16,185,129,.25), transparent 60%),
    var(--bg);
}
body.day{
  background:
    radial-gradient(1200px 800px at 80% -10%, rgba(250,204,21,.28), transparent 55%),
    radial-gradient(900px 700px at -10% 100%, rgba(59,130,246,.18), transparent 60%),
    var(--bg);
}
body.night{
  background:
    radial-gradient(1200px 800px at 80% -10%, rgba(79,140,255,.25), transparent 60%),
    radial-gradient(800px 600px at -10% 100%, rgba(16,185,129,.20), transparent 60%),
    var(--bg);
}

.chat{
  width:100%; max-width:780px; height:100dvh; max-height:860px; display:flex; flex-direction:column;
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0)) , var(--card);
  border:1px solid rgba(255,255,255,.08); border-radius:24px; box-shadow: var(--shadow); overflow:hidden;
}
body.day .chat{
  border-color: rgba(15,23,42,.06);
  background:linear-gradient(180deg, rgba(2,6,23,.03), rgba(2,6,23,0)), var(--card);
}

.chat-header{
  display:flex; align-items:center; gap:12px; padding:16px 18px; border-bottom:1px solid rgba(255,255,255,.06);
  backdrop-filter: blur(8px);
}
body.day .chat-header{ border-bottom-color: rgba(15,23,42,.06); }

.logo{width:36px;height:36px;border-radius:12px;background:linear-gradient(135deg,var(--primary),var(--accent)); display:grid; place-items:center; color:white; box-shadow:0 6px 18px rgba(79,140,255,.4)}
.logo svg{width:22px;height:22px}
.title{display:flex; flex-direction:column}
.title b{font-size:16px}
.status{display:flex; align-items:center; gap:8px; color:var(--muted); font-size:13px}
.dot{width:8px;height:8px;border-radius:999px;background:var(--accent); box-shadow:0 0 0 6px rgba(16,185,129,.15)}
body.day .dot{box-shadow:0 0 0 6px rgba(14,165,233,.18)}

.chat-body{
  flex:1; overflow:auto; padding:18px; scroll-behavior:smooth;
  background:
    radial-gradient(600px 400px at 20% 0%, rgba(35,93,255,.08), transparent 70%),
    radial-gradient(500px 300px at 100% 100%, rgba(16,185,129,.08), transparent 65%);
}
body.day .chat-body{
  background:
    radial-gradient(600px 400px at 20% 0%, rgba(59,130,246,.10), transparent 70%),
    radial-gradient(500px 300px at 100% 100%, rgba(250,204,21,.10), transparent 65%);
}

.msg{display:flex; gap:10px; margin:10px 0; align-items:flex-end; animation: fadeIn .25s ease both}
@keyframes fadeIn{from{opacity:0; transform: translateY(6px)} to{opacity:1; transform:none}}
.avatar{flex:0 0 32px; width:32px; height:32px; border-radius:10px; display:grid; place-items:center}
.avatar.bot{background:var(--bubble-bot)}
.avatar.user{background:var(--bubble-user)}
/* ikony w avatarach */
.avatar svg{display:block}

.bubble{
  max-width: 90%;
  padding:12px 14px; border-radius:16px; font-size:15px; line-height:1.35;
  border:1px solid rgba(255,255,255,.07);
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
body.day .bubble{
  border-color: rgba(15,23,42,.06);
  box-shadow: 0 6px 18px rgba(2,6,23,.06);
}
.bot .bubble{background:var(--bubble-bot); border-top-left-radius:6px}
.user .bubble{background:var(--bubble-user); border-top-right-radius:6px}

/* Linki w treści bąbla */
.bubble a{
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
}
.bubble a:hover{ opacity:.9 }

/* Przyciski wyboru */
.choices{display:flex; flex-wrap:wrap; gap:10px; margin-top:8px}
.choice{
  padding:10px 14px; border-radius:999px; border:1px solid rgba(255,255,255,.09);
  background:transparent; color:var(--text); cursor:pointer; font-size:14px;
  transition: .15s transform ease, .15s background ease, .15s color ease, .15s opacity ease;
  -webkit-tap-highlight-color: transparent;
}
body.day .choice{ border-color: rgba(15,23,42,.10); }
.choice:hover{transform:translateY(-1px)}
.choice:focus-visible{ outline:2px solid var(--primary); outline-offset:2px }
body.day .choice:focus-visible{ outline-color: var(--primary-2); }

/* aktywny wybór */
.choice.primary{
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  border-color:transparent;
  color:#fff; /* zawsze biały tekst na gradiencie */
}

/* neutralny wybór */
.choice.ghost{background:transparent}

/* --- FIX: po kliknięciu/disabled nic nie znika i widać zaznaczenie w obu motywach --- */
.choice:disabled{
  opacity:.9;             /* nie przyciemniaj za bardzo (żeby tekst był czytelny) */
  cursor:default;
}
.choice.primary:disabled{
  opacity:1;              /* aktywny wybór zostaje w 100% widoczny */
  color:#fff;             /* biały tekst na gradiencie wciąż czytelny */
}
body.day .choice.ghost:disabled{
  color: var(--muted);
}
body.night .choice.ghost:disabled{
  color: #cbd5e1;         /* jaśniejszy szary w nocy */
}
/* brak białego „selection highlight” na przyciskach */
.choice::selection{ background: transparent; color: inherit; }
.choice *::selection{ background: transparent; color: inherit; }

/* Pola wejściowe */
.field{ display:flex; gap:10px; margin-top:10px; align-items:center; flex-wrap:wrap }
.input, .textarea{
  width:100%; border:1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.04);
  color:var(--text); padding:12px 14px; border-radius:12px; outline:none; font-size:15px;
}
body.day .input, body.day .textarea{ border-color: rgba(15,23,42,.10); background: #f8fafc; }
.textarea{min-height:90px; resize:vertical}

/* Formularz telefonu: przycisk OK w polu */
.formline{ position: relative; width:100%; }
.input-wrap{ position: relative; width: 100%; }
.input-wrap .input{ padding-right: 44px; } /* miejsce na ikonę OK */
.btn.icon.ok-in-input{
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px; height: 34px; min-width:34px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn.icon.ok-in-input.hidden{ display:none; }

/* Maskowanie cyfr telefonu (wygląda jak hasło) */
.input.masked{
  -webkit-text-security: disc;
  text-security: disc;
}

.btn{
  padding:10px 16px; border-radius:10px; border:1px solid rgba(255,255,255,.12); cursor:pointer; background:var(--bubble-bot); color:var(--text);
}
body.day .btn{ border-color: rgba(15,23,42,.12); background:#eff6ff; color:#0f172a; }
.btn.primary{background:linear-gradient(135deg,var(--primary),var(--primary-2)); border-color:transparent; color:white}
.btn.secondary{background:transparent}
.btn.danger{background: linear-gradient(135deg,#ef4444,#dc2626); color:white; border-color:transparent}

.typing{display:inline-flex; gap:4px; align-items:center}
.dot3{width:6px;height:6px;border-radius:999px;background:rgba(255,255,255,.6); animation: blink 1s infinite ease-in-out}
body.day .dot3{background:rgba(15,23,42,.45)}
.dot3:nth-child(2){animation-delay:.2s}
.dot3:nth-child(3){animation-delay:.4s}
@keyframes blink{0%,80%,100%{opacity:.25; transform: translateY(0)} 40%{opacity:1; transform: translateY(-2px)}}

/* Karta podsumowania / karty z danymi */
.summary{
  border:1px dashed rgba(255,255,255,.18); border-radius:14px; padding:12px; margin-top:10px; background: rgba(255,255,255,.03)
}
body.day .summary{ border-color: rgba(15,23,42,.15); background:#f8fafc; }
.summary dl{
  margin:0;
  display:grid;
  grid-template-columns: 130px 1fr;
  gap:8px 14px;
  font-size:14px;
}
.summary dt{color:var(--muted)}
.summary dd{ margin:0; text-align:left; word-break: break-word; }
.summary dd.full{ grid-column: 1 / -1; }
.summary .nrb{ font-size:14px; }

/* mały wariant standardowego przycisku */
.btn.small{ padding:6px 10px; font-size:14px; border-radius:999px; }

/* Stopka */
.footer{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:10px 12px; border-top:1px solid rgba(255,255,255,.06); background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
}
body.day .footer{ border-top-color: rgba(15,23,42,.08); background: linear-gradient(180deg, rgba(2,6,23,.02), transparent); }

.restart{display:inline-flex; align-items:center; gap:8px; color:var(--muted); font-size:13px; cursor:pointer}
.restart svg{width:16px;height:16px}
.copy{font-size:12px; padding:6px 10px; border-radius:999px; border:1px solid rgba(255,255,255,.12); background:transparent; color:var(--text); cursor:pointer}
body.day .copy{border-color: rgba(15,23,42,.12)}

.hidden{display:none !important}
.hint{font-size:13px; color:var(--muted); width:100%}
.hint.error{color:var(--danger)}
.error{color:var(--danger)}
.muted{color:var(--muted); font-size:12px; margin:10px 0 0}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.shake{ animation: shake .4s; }

/* Responsywność */
@media (max-width: 640px){
  .chat{height:100dvh; max-height:100dvh; border-radius:16px}
  .bubble{max-width: 85%}
  .summary dl{ grid-template-columns: 110px 1fr; }
}


/* Plugin-aware node styling */
.node[data-plugin] rect {
  /* stroke color comes from JS inline, but ensure visible by default */
  stroke-width: 2;
}

/* Ports styling */
.port {
  cursor: pointer;
}
.port.port-out:hover,
.port.port-in:hover {
  opacity: 0.85;
}

/* Context menu separator */
#ctx hr {
  border: 0;
  border-top: 1px solid rgba(148,163,184,.4);
  margin: 4px 0;
}
/* Panel pluginów */
.plugin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}

.plugin-left {
  flex: 1;
  min-width: 0; /* pozwala na ellipsis */
}

.plugin-name,
.plugin-file {
  max-width: 260px;      /* możesz dopasować */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plugin-name {
  font-weight: 500;
}

.plugin-file {
  font-size: 11px;
  color: var(--muted);
}

.plugin-right {
  white-space: nowrap;   /* przyciski w jednej linii */
  display: flex;
  align-items: center;
  gap: 8px;
}
/* chat plugin inline form – wygląda jak część bąbelka */
.msg.bot .bubble .chat-form{
  display:flex;
  gap:10px;
  align-items:center;
  margin-top:10px;
}

.msg.bot .bubble .chat-input{
  flex:1;
  min-width: 180px;
  border:1px solid rgba(15,23,42,.18);
  background: rgba(255,255,255,.85);
  color: #0f172a;
  padding:10px 12px;
  border-radius:12px;
  outline:none;
  font-size:14px;
}

.msg.bot .bubble .chat-input::placeholder{
  color: rgba(100,116,139,.9);
}

.msg.bot .bubble .chat-input:focus{
  border-color: rgba(59,130,246,.55);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.msg.bot .bubble .chat-send{
  padding:10px 14px;
  border-radius:999px;
  border:1px solid rgba(59,130,246,.35);
  background: rgba(59,130,246,.12);
  color: #0f172a;
  cursor:pointer;
  font-size:13px;
  white-space:nowrap;
}

.msg.bot .bubble .chat-send:hover{
  background: rgba(59,130,246,.18);
}

.msg.bot .bubble .chat-skip{
  padding:10px 12px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,.12);
  background: transparent;
  color: #0f172a;
  cursor:pointer;
  font-size:13px;
  white-space:nowrap;
}

.msg.bot .bubble .chat-skip:hover{
  background: rgba(15,23,42,.06);
}
.msg.bot .bubble .chat-textarea{
  flex:1;
  min-width: 220px;
  border:1px solid rgba(15,23,42,.18);
  background: rgba(255,255,255,.85);
  color: #0f172a;
  padding:10px 12px;
  border-radius:12px;
  outline:none;
  font-size:14px;

  resize: vertical;          /* user może powiększyć */
  line-height: 1.35;
  max-height: 220px;         /* żeby nie zjadło całego czatu */
  overflow: auto;
}

.msg.bot .bubble .chat-textarea:focus{
  border-color: rgba(59,130,246,.55);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
/* Ticket collect: textarea do długich opisów */
.chat-form .chat-textarea{
  flex: 1;
  min-width: 220px;
  border: 1px solid rgba(15,23,42,.18);
  background: rgba(255,255,255,.85);
  color: #0f172a;
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
  font-size: 14px;

  resize: vertical;
  line-height: 1.35;
  max-height: 220px;
  overflow: auto;
}

.chat-form .chat-textarea:focus{
  border-color: rgba(59,130,246,.55);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.choices-list{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-top:10px;
}

.choice-row{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;

  padding:12px 14px;
  border-radius:14px;

  border:1px solid rgba(148,163,184,.35);
  background:rgba(255,255,255,.75);
  backdrop-filter: blur(6px);

  cursor:pointer;
  text-align:left;
}

.choice-row:hover{
  background:rgba(255,255,255,.9);
  border-color: rgba(148,163,184,.55);
}

.choice-row:disabled{
  opacity:.55;
  cursor:not-allowed;
}

.choice-title{
  font-size:14px;
  line-height:1.2;
  color:#0f172a;
  font-weight:500;
}

.choice-chevron{
  font-size:20px;
  line-height:1;
  color:rgba(15,23,42,.55);
  transform: translateY(-1px);
}
