/* =========================================
   COSMO CLINIC — Chat Funnel
   ========================================= */

/* ── Overlay ── */
.cf {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: none;
}
.cf[hidden] { display: none !important; }

.cf__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 10, 6, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: cf-fade-in 0.25s ease both;
  pointer-events: all;
}

/* ── Panel ── */
.cf__panel {
  position: relative;
  width: min(420px, 100%);
  max-height: min(620px, 94svh);
  background: #FAF7F4;
  border-radius: 22px;
  box-shadow: 0 32px 96px rgba(0,0,0,0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: all;
  animation: cf-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Header ── */
.cf__header {
  background: var(--color-dark);
  padding: 1.1rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.cf__agent {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.cf__avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
}
.cf__agent-name {
  color: white;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.cf__agent-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: rgba(255,255,255,0.55);
  font-size: 0.72rem;
  margin-top: 0.18rem;
}
.cf__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  flex-shrink: 0;
  animation: cf-pulse 2.4s ease-in-out infinite;
}
.cf__close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.cf__close:hover { color: white; background: rgba(255,255,255,0.1); }

/* ── Messages ── */
.cf__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  scroll-behavior: smooth;
  min-height: 0;
}
.cf__messages::-webkit-scrollbar { width: 3px; }
.cf__messages::-webkit-scrollbar-track { background: transparent; }
.cf__messages::-webkit-scrollbar-thumb { background: rgba(201,149,106,0.3); border-radius: 2px; }

/* Agent bubble */
.cf__bubble {
  background: white;
  color: var(--color-dark);
  border-radius: 4px 16px 16px 16px;
  padding: 0.75rem 1.05rem;
  font-size: 0.875rem;
  line-height: 1.58;
  max-width: 88%;
  align-self: flex-end;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  animation: cf-bubble-in 0.28s ease both;
}

/* User selection bubble */
.cf__user-bubble {
  background: var(--color-primary);
  color: white;
  border-radius: 16px 4px 16px 16px;
  padding: 0.6rem 1.05rem;
  font-size: 0.85rem;
  font-weight: 500;
  align-self: flex-start;
  box-shadow: 0 2px 10px rgba(201,149,106,0.3);
  animation: cf-bubble-in 0.28s ease both;
}

/* Typing indicator */
.cf__typing {
  background: white;
  border-radius: 4px 16px 16px 16px;
  padding: 0.8rem 1.05rem;
  align-self: flex-end;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  width: fit-content;
}
.cf__typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
  display: block;
  animation: cf-dot-bounce 1.3s ease-in-out infinite;
}
.cf__typing span:nth-child(2) { animation-delay: 0.18s; }
.cf__typing span:nth-child(3) { animation-delay: 0.36s; }

/* ── Quick replies ── */
.cf__quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem 0.85rem;
  justify-content: flex-end;
  flex-shrink: 0;
}
.cf__quick-replies:empty { padding: 0; }

.cf__option {
  background: white;
  border: 1.5px solid rgba(201,149,106,0.4);
  color: var(--color-dark);
  border-radius: 100px;
  padding: 0.45rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.15s;
  animation: cf-fade-in 0.3s ease both;
}
.cf__option:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  transform: translateY(-1px);
}
.cf__option:active { transform: translateY(0); }

/* ── Contact form ── */
.cf__form {
  padding: 0.85rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  border-top: 1px solid rgba(201,149,106,0.15);
  flex-shrink: 0;
  animation: cf-fade-in 0.35s ease both;
}
.cf__form[hidden] { display: none !important; }

.cf__input {
  background: white;
  border: 1.5px solid rgba(201,149,106,0.28);
  border-radius: 11px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: var(--color-dark);
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  text-align: right;
}
.cf__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(201,149,106,0.12);
}
.cf__input.error { border-color: #ef4444; }
.cf__input::placeholder { color: rgba(28,28,28,0.38); }

.cf__send {
  width: 100%;
  justify-content: center;
  text-align: center;
}

/* ── WhatsApp final CTA ── */
.cf__wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  background: #25D366;
  color: white;
  border-radius: 12px;
  padding: 0.9rem 1.5rem;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: var(--font-body);
  text-decoration: none;
  margin: 0 1.25rem 1.25rem;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 4px 16px rgba(37,211,102,0.3);
  animation: cf-fade-in 0.4s ease both;
}
.cf__wa-btn:hover { background: #1eb859; color: white; transform: translateY(-1px); }
.cf__wa-btn:active { transform: translateY(0); }

/* ── Keyframes ── */
@keyframes cf-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes cf-slide-up {
  from { opacity: 0; transform: translateY(28px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
@keyframes cf-bubble-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0);   }
}
@keyframes cf-dot-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.35; }
  30%           { transform: translateY(-5px); opacity: 1;    }
}
@keyframes cf-pulse {
  0%, 100% { opacity: 1;   }
  50%      { opacity: 0.4; }
}

/* =========================================
   SMART NUDGE POPUP
   ========================================= */

.cn {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 2500;
  pointer-events: none;
}
.cn[hidden] { display: none !important; }

.cn__card {
  width: 320px;
  background: var(--color-white, #fff);
  border: 1px solid rgba(201,149,106,0.15);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 12px 48px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  pointer-events: all;
  animation: cn-slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  position: relative;
  text-align: right;
}

.cn__close {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  background: none;
  border: none;
  color: rgba(28,28,28,0.3);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.cn__close:hover { color: var(--color-dark); background: rgba(28,28,28,0.05); }

.cn__icon {
  color: var(--color-primary);
  font-size: 1.3rem;
  margin-bottom: 0.6rem;
}

.cn__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--color-dark);
  margin-bottom: 0.5rem;
}

.cn__text {
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--color-mid, #888);
  margin-bottom: 1.25rem;
}

.cn__cta {
  display: block;
  width: 100%;
  padding: 0.7rem 1.25rem;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  margin-bottom: 0.6rem;
}
.cn__cta:hover { background: #b8865e; transform: translateY(-1px); }
.cn__cta:active { transform: translateY(0); }

.cn__dismiss {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: rgba(28,28,28,0.35);
  font-family: var(--font-body);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.3rem;
  transition: color 0.2s;
}
.cn__dismiss:hover { color: var(--color-mid, #888); }

/* Nudge exit animation */
.cn--hiding .cn__card {
  animation: cn-slide-down 0.3s ease both;
}

@keyframes cn-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cn-slide-down {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(20px) scale(0.97); }
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .cf { padding: 1rem; align-items: center; }
  .cf__panel {
    width: 100%;
    max-height: 88svh;
    border-radius: 22px;
  }
  .cf__quick-replies { justify-content: flex-start; }

  .cn {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 5.5rem;
  }
  .cn__card { width: auto; }
}
