/* Floating WhatsApp chat widget */

.ck-chat {
  --ck-chat-green: #25d366;
  --ck-chat-green-dark: #128c7e;
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: 99990;
  font-family: "Noto Sans", system-ui, sans-serif;
}

.ck-chat__status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
  flex-shrink: 0;
}

.ck-chat__fab {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 58px;
  padding: 0 0.35rem;
  border: none;
  border-radius: 999px;
  background: #fff;
  color: var(--ck-chat-green-dark);
  box-shadow: 0 8px 28px rgba(15, 39, 68, 0.18);
  border: 1px solid rgba(37, 211, 102, 0.35);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ck-chat__fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(15, 39, 68, 0.22);
}

.ck-chat__fab-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.65rem 0 0.35rem;
}

.ck-chat__fab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ck-chat-green);
  color: #fff;
  font-size: 1.55rem;
  line-height: 1;
}

.ck-chat__fab-online {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ck-chat-green-dark);
  letter-spacing: 0.02em;
}

.ck-chat.is-open .ck-chat__fab {
  display: none;
}

.ck-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(58px + 0.75rem);
  width: min(100vw - 2rem, 360px);
  max-width: calc(100vw - 2rem);
  max-height: min(78vh, 520px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(15, 39, 68, 0.22);
  border: 1px solid var(--ck-border, #e2e8f0);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  overflow: hidden;
  overflow-x: hidden;
  box-sizing: border-box;
}

.ck-chat.is-open .ck-chat__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
}

.ck-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.5rem 0.55rem 0.5rem 0.7rem;
  background: linear-gradient(135deg, var(--ck-chat-green-dark) 0%, var(--ck-chat-green) 100%);
  color: #fff;
  flex-shrink: 0;
}

.ck-chat__head-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
}

.ck-chat__title {
  margin: 0;
  font-family: "Roboto Serif", Georgia, serif;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.2;
  color: #fff !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.ck-chat__status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  opacity: 0.95;
  flex-shrink: 0;
  white-space: nowrap;
}

.ck-chat__close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.ck-chat__close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ck-chat__form {
  padding: 0.85rem 1rem 1rem;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc(min(78vh, 520px) - 72px);
  -webkit-overflow-scrolling: touch;
}

.ck-chat__field {
  margin-bottom: 0.65rem;
}

.ck-chat__label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #424242;
}

.ck-chat__req {
  color: var(--ck-brand, #7a3030);
}

.ck-chat__input,
.ck-chat__textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.65rem;
  border: 1px solid #d8d4cc;
  border-radius: 6px;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: #1a1a1a;
  background: #fafaf9;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ck-chat__textarea {
  resize: none;
  min-height: 3.25rem;
  max-height: 5rem;
}

.ck-chat__input:focus,
.ck-chat__textarea:focus {
  outline: none;
  border-color: var(--ck-chat-green-dark);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.18);
}

.ck-chat__hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  width: 0;
}

.ck-chat__submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--ck-chat-green);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.ck-chat__submit:hover:not(:disabled) {
  background: #20bd5a;
}

.ck-chat__submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.ck-chat__submit-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ck-chat-spin 0.7s linear infinite;
}

.ck-chat__submit.is-loading .ck-chat__submit-text,
.ck-chat__submit.is-loading .fab {
  opacity: 0.4;
}

.ck-chat__submit.is-loading .ck-chat__submit-spinner {
  display: inline-block;
}

@keyframes ck-chat-spin {
  to {
    transform: rotate(360deg);
  }
}

.ck-chat__feedback {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

.ck-chat__feedback:empty {
  display: none;
  margin: 0;
}

.ck-chat__feedback.is-success {
  color: var(--ck-chat-green-dark);
}

.ck-chat__feedback.is-error {
  color: var(--ck-error, #9f2e2e);
}

@media (max-width: 767px) {
  .ck-chat.is-open .ck-chat__panel {
    position: fixed;
    left: max(0.65rem, env(safe-area-inset-left, 0px));
    right: max(0.65rem, env(safe-area-inset-right, 0px));
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 1.25rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .ck-chat__form {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 0.55rem 0.75rem 0.7rem;
  }

  .ck-chat__field {
    margin-bottom: 0.4rem;
  }

  .ck-chat__input,
  .ck-chat__textarea {
    font-size: 16px;
  }

  .ck-chat__textarea {
    min-height: 2.75rem;
    max-height: 3.5rem;
  }

  .ck-chat__submit {
    margin-top: 0.2rem;
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
  }
}

@media (max-width: 767px) and (min-height: 680px) {
  .ck-chat__form {
    overflow-y: visible;
  }
}

body.ck-chat-open {
  overflow: hidden;
  overscroll-behavior: none;
}

@media (max-width: 380px) {
  .ck-chat.is-open .ck-chat__panel {
    left: max(0.5rem, env(safe-area-inset-left, 0px));
    right: max(0.5rem, env(safe-area-inset-right, 0px));
  }
}
