/* ═══════════════════════════════════════════════════════
   Legal Chat RODO – Widget v1.4
   ═══════════════════════════════════════════════════════ */

:root {
  --lc-bg:       #0c1628;
  --lc-surface:  #111f3a;
  --lc-surface2: #162545;
  --lc-border:   rgba(255,255,255,.07);
  --lc-gold:     #c9a84c;
  --lc-gold2:    #e6c96e;
  --lc-text:     #dde3f0;
  --lc-muted:    #6b7fa3;
  --lc-muted2:   #8a9abb;
  --lc-vis-bg:   #1a2e56;
  --lc-law-bg:   #0d1e3a;
  --lc-r:        16px;
  --lc-r-sm:     10px;
  --lc-z:        99999;
  --lc-font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ═══ FAB ═══════════════════════════════════════════════ */

#lcr-chat-root {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: var(--lc-z);
  font-family: var(--lc-font);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.lcr-fab-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Pulsujące pierścienie */
.lcr-fab-ring {
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--lc-gold);
  opacity: 0;
  pointer-events: none;
  animation: lcr-ring 2.6s ease-out infinite;
}
.lcr-fab-ring-2 { animation-delay: 1.3s; }
@keyframes lcr-ring {
  0%   { transform: scale(1);    opacity: .6; }
  100% { transform: scale(2.15); opacity: 0;  }
}

/* Przycisk FAB */
.lcr-fab {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none; cursor: pointer;
  position: relative; z-index: 2;
  background: linear-gradient(150deg, #1e3f80 0%, #0c1628 100%);
  box-shadow:
    0 0 0 2.5px var(--lc-gold),
    0 8px 28px rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.lcr-fab:hover {
  transform: scale(1.09);
  box-shadow: 0 0 0 3px var(--lc-gold2), 0 12px 36px rgba(0,0,0,.7);
}
.lcr-fab:active { transform: scale(.95); }

.lcr-fab-icon {
  width: 26px; height: 26px;
  position: relative; z-index: 1;
}

/* Badge */
.lcr-fab-badge {
  position: absolute; top: -1px; right: -1px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #e0453a;
  border: 2px solid #fff;
  font-size: 10px; color: #fff; font-weight: 700;
  font-family: sans-serif;
  display: flex; align-items: center; justify-content: center;
  z-index: 3;
  animation: lcr-pop .22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes lcr-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* Etykieta "Zapytaj radcy" */
.lcr-fab-label {
  background: var(--lc-surface);
  color: var(--lc-gold2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .05em;
  padding: 4px 11px;
  border-radius: 20px;
  white-space: nowrap;
  border: 1px solid rgba(201,168,76,.25);
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
  pointer-events: none;
  animation: lcr-float 3s ease-in-out infinite;
}
@keyframes lcr-float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-2px); }
}

/* ═══ OKNO CZATU ═══════════════════════════════════════ */

.lcr-window {
  position: fixed;
  bottom: 96px; right: 24px;
  width: 348px;
  max-width: calc(100vw - 36px);
  height: 520px;
  max-height: calc(100vh - 116px);
  background: var(--lc-bg);
  border-radius: var(--lc-r);
  box-shadow:
    0 24px 72px rgba(0,0,0,.8),
    0 0 0 1px rgba(201,168,76,.18);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(.97);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: var(--lc-z);
}
.lcr-window.lcr-open {
  opacity: 1; transform: none;
  pointer-events: all;
}

/* ── Header ── */
.lcr-header {
  background: linear-gradient(135deg, var(--lc-surface) 0%, var(--lc-surface2) 100%);
  border-bottom: 1px solid rgba(201,168,76,.14);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}

/* Avatar: SVG waga sądowa zamiast emoji */
.lcr-header-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--lc-gold) 0%, var(--lc-gold2) 100%);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(201,168,76,.35);
}
.lcr-header-avatar svg {
  width: 18px; height: 18px;
}

.lcr-header-info { flex: 1; min-width: 0; }
.lcr-header-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--lc-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lcr-header-sub {
  font-size: 11px; color: var(--lc-muted2);
  margin-top: 2px;
  display: flex; align-items: center; gap: 5px;
}
.lcr-online-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4caf7d;
  box-shadow: 0 0 0 2px rgba(76,175,125,.25);
  flex-shrink: 0;
}

.lcr-close {
  background: none; border: none;
  color: var(--lc-muted); cursor: pointer;
  padding: 5px; border-radius: 7px; line-height: 0;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.lcr-close:hover { color: var(--lc-text); background: rgba(255,255,255,.06); }

/* ── RODO banner — kompaktowy, jednoliniowy ── */
.lcr-rodo {
  background: rgba(201,168,76,.04);
  border-bottom: 1px solid rgba(201,168,76,.08);
  padding: 5px 14px;
  font-size: 10px;
  color: var(--lc-muted);
  line-height: 1.45;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

/* ── Sugestie tematów ── */
.lcr-suggestions {
  padding: 10px 14px 6px;
  flex-shrink: 0;
  transition: opacity .3s;
}
.lcr-sug-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--lc-muted);
  margin-bottom: 7px;
}
.lcr-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lcr-chip {
  background: rgba(201,168,76,.07);
  border: 1px solid rgba(201,168,76,.25);
  color: var(--lc-gold2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.lcr-chip:hover  { background: rgba(201,168,76,.15); border-color: rgba(201,168,76,.5); transform: translateY(-1px); }
.lcr-chip:active { transform: scale(.96); }
.lcr-chip:disabled { opacity: .4; cursor: default; transform: none; }

/* ── Wiadomości ── */
.lcr-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 7px;
  scroll-behavior: smooth;
}
.lcr-msgs::-webkit-scrollbar { width: 2px; }
.lcr-msgs::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 99px; }

.lcr-msg-wrap { display: flex; flex-direction: column; max-width: 80%; }
.lcr-msg-wrap.lcr-visitor { align-self: flex-end; align-items: flex-end; }
.lcr-msg-wrap.lcr-lawyer  { align-self: flex-start; align-items: flex-start; }

.lcr-bubble {
  padding: 9px 13px;
  border-radius: 13px;
  font-size: 13px; line-height: 1.55;
  color: var(--lc-text); word-break: break-word;
}
.lcr-visitor .lcr-bubble {
  background: linear-gradient(135deg, #1d3466 0%, #142240 100%);
  border-bottom-right-radius: 3px;
}
.lcr-lawyer .lcr-bubble {
  background: var(--lc-law-bg);
  border-bottom-left-radius: 3px;
  border-left: 2px solid var(--lc-gold);
}
.lcr-ts {
  font-size: 10px; color: var(--lc-muted);
  margin-top: 3px; padding: 0 2px;
}
.lcr-sysmsg {
  text-align: center; font-size: 11px;
  color: var(--lc-muted); font-style: italic; padding: 3px 0;
}

/* ═══ STOPKA: belki zgód + e-mail + input ═══════════════ */

/* ── Belka zgód (checkboxy) ── */
.lcr-prebar {
  flex-shrink: 0;
  background: rgba(10,18,36,.9);
  border-top: 1px solid rgba(201,168,76,.12);
  padding: 8px 14px 7px;
  overflow: hidden;
  max-height: 200px;
  transition: max-height .35s ease, opacity .28s ease, padding .3s ease;
}
.lcr-prebar.lcr-prebar--hidden {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}

/* E-mail row */
.lcr-email-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}
.lcr-email-icon-svg {
  width: 14px; height: 14px;
  flex-shrink: 0;
  color: var(--lc-muted);
  opacity: .7;
}
.lcr-email-input {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--lc-r-sm);
  padding: 7px 11px;
  color: var(--lc-text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, background .15s;
  -webkit-appearance: none;
}
.lcr-email-input:focus {
  border-color: rgba(201,168,76,.45);
  background: rgba(255,255,255,.07);
}
.lcr-email-input::placeholder { color: var(--lc-muted); font-size: 12px; }
.lcr-email-input.lcr-invalid  { border-color: rgba(224,69,58,.65); }

/* Checkboxy zgód */
.lcr-checks {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.lcr-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.lcr-check input[type="checkbox"] {
  width: 13px; height: 13px;
  flex-shrink: 0; margin-top: 2px;
  cursor: pointer;
  accent-color: var(--lc-gold);
}
.lcr-check-label {
  font-size: 11px;
  color: var(--lc-muted);
  line-height: 1.5;
}
.lcr-check-label a {
  color: rgba(230,201,110,.75);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.lcr-check:hover .lcr-check-label { color: var(--lc-muted2); }

/* Shake przy próbie wysłania bez zgód */
.lcr-check.lcr-shake { animation: lcr-shake .35s ease; }
@keyframes lcr-shake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-5px); }
  75%     { transform: translateX(5px); }
}

/* ── Wiersz z inputem i przyciskiem wyślij ── */
.lcr-input-row {
  display: flex;
  gap: 7px;
  align-items: flex-end;
  padding: 9px 11px;
  padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
  background: var(--lc-surface);
  border-top: 1px solid var(--lc-border);
  flex-shrink: 0;
}
.lcr-input {
  flex: 1;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--lc-r-sm);
  padding: 9px 12px;
  color: var(--lc-text);
  font-size: 16px; /* zapobiega zoom na iOS */
  font-family: inherit;
  resize: none; outline: none;
  min-height: 40px; max-height: 80px;
  line-height: 1.4;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.lcr-input:focus { border-color: rgba(201,168,76,.4); }
.lcr-input::placeholder { color: var(--lc-muted); }
.lcr-input:disabled {
  opacity: .3;
  cursor: not-allowed;
}
/* Zablokowany (zgody jeszcze nie zaakceptowane) */
.lcr-input--locked {
  opacity: .3;
  pointer-events: none;
}

.lcr-send {
  width: 40px; height: 40px;
  flex-shrink: 0;
  align-self: flex-end;
  border-radius: var(--lc-r-sm);
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--lc-gold) 0%, var(--lc-gold2) 100%);
  color: #12100a;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s, transform .12s;
  -webkit-tap-highlight-color: transparent;
}
.lcr-send:hover:not(:disabled):not(.lcr-send--locked) { opacity: .85; }
.lcr-send:active:not(:disabled):not(.lcr-send--locked) { transform: scale(.92); }
.lcr-send:disabled { opacity: .25; cursor: default; }
.lcr-send--locked  { opacity: .2; pointer-events: none; }

.lcr-closed-msg {
  text-align: center;
  padding: 12px 14px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  font-size: 12px; color: var(--lc-muted);
  background: var(--lc-surface);
  border-top: 1px solid var(--lc-border);
  flex-shrink: 0;
}

/* ═══ MOBILE ════════════════════════════════════════════ */
@media (max-width: 600px) {

  #lcr-chat-root { bottom: 16px; right: 16px; }

  .lcr-window {
    position: fixed;
    bottom: 0 !important; left: 0 !important; right: 0 !important; top: auto !important;
    width: 100% !important; max-width: 100% !important;
    height: 65vh; max-height: 65vh; min-height: 320px;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 40px rgba(0,0,0,.7), 0 0 0 1px rgba(201,168,76,.15);
  }

  .lcr-header         { padding: 11px 14px; flex-shrink: 0; }
  .lcr-header-avatar  { width: 32px; height: 32px; }
  .lcr-header-avatar svg { width: 16px; height: 16px; }
  .lcr-header-title   { font-size: 13px; }
  .lcr-rodo           { padding: 5px 14px; font-size: 10px; }
  .lcr-suggestions    { padding: 8px 12px 4px; }
  .lcr-chip           { padding: 5px 11px; font-size: 11.5px; }

  .lcr-msgs {
    flex: 1; min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
  }

  .lcr-prebar { padding: 7px 12px 6px; }

  .lcr-input-row {
    flex-shrink: 0;
    padding: 9px 11px;
    padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(0,0,0,.3);
  }
  .lcr-input {
    font-size: 16px;
    min-height: 42px; max-height: 42px;
    overflow-y: auto;
    padding: 10px 12px;
  }
  .lcr-send { width: 42px; height: 42px; align-self: center; }
  .lcr-send svg { width: 18px; height: 18px; }

  .lcr-fab       { width: 54px; height: 54px; }
  .lcr-fab-label { font-size: 11px; padding: 4px 10px; }
}

@media (max-width: 380px) {
  .lcr-window  { height: 70vh; max-height: 70vh; }
  .lcr-bubble  { font-size: 12.5px; }
}
