/* Чат сайта + портфолио / оплата (ТЗ №7–8) */

html.rr-chat-lock,
html.rr-chat-lock body {
  overflow: hidden;
  overscroll-behavior: none;
}

.rr-chat {
  --rr-kb: 0px;
  --rr-vvh: 100dvh;
  --rr-chat-safe: max(12px, env(safe-area-inset-bottom, 0px));
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--rr-chat-safe) + var(--rr-kb));
  left: auto;
  width: auto;
  z-index: 90;
  pointer-events: none;
}

.rr-chat > * {
  pointer-events: auto;
}

.rr-chat-scrim {
  position: fixed;
  inset: 0;
  background: rgba(29, 22, 49, .35);
  z-index: -1;
  border: 0;
}

.rr-chat-toggle {
  border: 0;
  border-radius: 999px;
  background: #8E2B87;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  min-height: 48px;
  min-width: 48px;
  padding: 12px 18px;
  box-shadow: 0 12px 30px rgba(142, 43, 135, .35);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.rr-chat-toggle[hidden],
.rr-chat-panel[hidden],
.rr-chat-scrim[hidden] {
  display: none !important;
}

.rr-chat-panel {
  display: none;
  width: min(380px, calc(100vw - 24px));
  height: min(520px, calc(var(--rr-vvh) - 24px - var(--rr-chat-safe)));
  max-height: calc(var(--rr-vvh) - 24px - var(--rr-chat-safe));
  background: #fff;
  color: #1D1631;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(29, 22, 49, .25);
  flex-direction: column;
  overflow: hidden;
  touch-action: manipulation;
}

.rr-chat.is-open .rr-chat-panel {
  display: flex !important;
}

.rr-chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  background: #221565;
  color: #fff;
  flex-shrink: 0;
}

.rr-chat-close {
  border: 0;
  background: #DCFA41;
  color: #221565;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.rr-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rr-chat-msg {
  max-width: 85%;
  padding: 8px 10px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.4;
}

.rr-chat-msg a {
  display: inline-block;
  margin-top: 4px;
  color: #8E2B87;
  font-weight: 600;
}

.rr-chat-msg.is-customer { margin-left: auto; background: #F3EEF8; }
.rr-chat-msg.is-admin,
.rr-chat-msg.is-system { margin-right: auto; background: #f4fbfb; }

.rr-chat-form {
  padding: 10px;
  border-top: 1px solid #E8E1F0;
  flex-shrink: 0;
  background: #fff;
}

.rr-chat-form textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #E8E1F0;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  resize: none;
  min-height: 52px;
  max-height: 120px;
}

.rr-chat-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.rr-chat-attach {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.rr-chat-clip {
  border: 1px solid #E8E1F0;
  background: #F3EEF8;
  color: #8E2B87;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
}

.rr-chat-fname {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  font-size: 12.5px;
  color: #625B78;
  background: #FAF8FC;
  border: 1px solid #E8E1F0;
  border-radius: 999px;
  padding: 4px 8px 4px 10px;
}

.rr-chat-fname span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.rr-chat-funset {
  border: 0;
  background: transparent;
  color: #8E2B87;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  touch-action: manipulation;
}

.rr-chat-send {
  border: 0;
  background: #DCFA41;
  color: #221565;
  border-radius: 999px;
  font-weight: 700;
  min-height: 44px;
  padding: 8px 16px;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
}

.rr-work-play { position: relative; display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; }
.rr-work-play img, .rr-work-fallback { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block; background: #221565; }
.rr-work-playico {
  position: absolute; right: 10px; bottom: 10px;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(29, 22, 49, .82); color: #DCFA41;
  font-size: 14px; line-height: 1; padding-left: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.rr-works figcaption b { display: block; color: #1D1631; }
.rr-works figcaption span { display: block; margin-top: 2px; }
.rr-player { border: 0; border-radius: 16px; padding: 12px; width: min(920px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.rr-player::backdrop { background: rgba(29, 22, 49, .72); }
.rr-player-frame { aspect-ratio: 16 / 9; background: #111; max-height: min(70dvh, 520px); }
.rr-player-frame iframe, .rr-player-frame video, .rr-player-frame img { width: 100%; height: 100%; border: 0; object-fit: contain; }
.rr-player-close { border: 0; background: transparent; font-size: 28px; cursor: pointer; }
.rr-pay-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.rr-pay-kicker { letter-spacing: .08em; text-transform: uppercase; color: #8E2B87; font-weight: 700; }
.rr-pay-details dl { display: grid; gap: 8px; }
.rr-pay-details dt { color: #625B78; font-size: 13px; }

@media (max-width: 640px) {
  .rr-chat {
    right: max(10px, env(safe-area-inset-right, 0px));
    left: auto;
    width: auto;
  }

  .rr-chat.is-open {
    left: max(10px, env(safe-area-inset-left, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    width: auto;
  }

  .rr-chat-panel {
    width: 100%;
    height: min(70dvh, calc(var(--rr-vvh) - 20px - var(--rr-chat-safe)));
    max-height: calc(var(--rr-vvh) - 20px - var(--rr-chat-safe));
    border-radius: 16px;
  }

  .rr-chat-toggle {
    margin-bottom: 0;
  }
}
