/* ============================================================
   Phone Chat Embed — Styles
   Lightweight iMessage-style conversation mockup in an iPhone frame
   ============================================================ */

/* --- Reset & Base --- */
.phone-chat-wrapper {
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Phone Frame --- */
.phone-frame {
  width: 375px;
  height: 812px;
  background: #fff;
  border-radius: 45px;
  border: 8px solid #1a1a1a;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* --- Status Bar --- */
.phone-status-bar {
  height: 54px;
  padding: 14px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  flex-shrink: 0;
}

.status-time {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #000;
}

.status-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Signal bars */
.status-signal {
  display: flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 12px;
}

.status-signal span {
  display: block;
  width: 3px;
  background: #000;
  border-radius: 1px;
}

.status-signal span:nth-child(1) { height: 4px; }
.status-signal span:nth-child(2) { height: 6px; }
.status-signal span:nth-child(3) { height: 9px; }
.status-signal span:nth-child(4) { height: 12px; }

/* WiFi icon (simplified) */
.status-wifi {
  font-size: 14px;
  line-height: 1;
  color: #000;
}

/* Battery */
.status-battery {
  display: flex;
  align-items: center;
  gap: 1px;
}

.status-battery-body {
  width: 22px;
  height: 11px;
  border: 1.5px solid #000;
  border-radius: 3px;
  padding: 1.5px;
  display: flex;
}

.status-battery-body::after {
  content: '';
  display: block;
  width: 100%;
  background: #000;
  border-radius: 1px;
}

.status-battery-tip {
  width: 2px;
  height: 5px;
  background: #000;
  border-radius: 0 1px 1px 0;
  align-self: center;
}

/* --- Contact Header --- */
.phone-contact-bar {
  padding: 6px 16px 10px;
  border-bottom: 0.5px solid #d1d1d6;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.contact-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #a0a0a8;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.contact-name {
  font-size: 17px;
  font-weight: 600;
  color: #000;
}

/* --- Messages Area --- */
.phone-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}

.phone-messages::-webkit-scrollbar {
  width: 3px;
}

.phone-messages::-webkit-scrollbar-track {
  background: transparent;
}

.phone-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

/* --- Message Bubbles --- */
.msg {
  display: flex;
  max-width: 78%;
  opacity: 0;
  transform: translateY(10px) scale(0.97);
}

.msg-received {
  align-self: flex-start;
}

.msg-sent {
  align-self: flex-end;
}

.msg-bubble {
  padding: 9px 14px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.38;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.msg-received .msg-bubble {
  background: #e9e9eb;
  color: #000;
  border-bottom-left-radius: 4px;
}

.msg-sent .msg-bubble {
  background: #007aff;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Message appear animation */
.msg.msg-visible {
  animation: msgAppear 0.35s ease-out forwards;
}

@keyframes msgAppear {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Static state after animation completes */
.phone-chat-done .msg {
  opacity: 1;
  transform: none;
  animation: none;
}

/* --- Typing Indicator --- */
.typing-indicator {
  align-self: flex-start;
  background: #e9e9eb;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: none;
  gap: 5px;
  align-items: center;
  width: 64px;
}

.typing-indicator.typing-visible {
  display: flex;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8e8e93;
  opacity: 0.4;
  animation: typingDot 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0%, 60%, 100% {
    opacity: 0.4;
    transform: scale(1);
  }
  30% {
    opacity: 1;
    transform: scale(1.25);
  }
}

/* --- Home Indicator Bar --- */
.phone-home-bar {
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  background: #fff;
}

.home-indicator {
  width: 134px;
  height: 5px;
  background: #000;
  border-radius: 3px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .phone-frame {
    width: min(90vw, 375px);
    height: min(85vh, 812px);
  }
}

@media (max-width: 420px) {
  .phone-frame {
    width: 92vw;
    height: 80vh;
    max-height: 812px;
    border-radius: 36px;
    border-width: 6px;
  }

  .phone-status-bar {
    padding: 12px 20px 0;
  }

  .msg-bubble {
    font-size: 15px;
    padding: 8px 12px;
  }
}

/* --- Graceful Degradation (JS not loaded) --- */
.phone-chat:not(.phone-chat-built) {
  max-width: 500px;
  margin: 24px auto;
  padding: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

.phone-chat:not(.phone-chat-built) .chat-msg {
  padding: 9px 14px;
  margin: 4px 0;
  border-radius: 18px;
  max-width: 80%;
  font-size: 16px;
  line-height: 1.38;
  word-wrap: break-word;
}

.phone-chat:not(.phone-chat-built) .chat-msg.received {
  background: #e9e9eb;
  color: #000;
  border-bottom-left-radius: 4px;
}

.phone-chat:not(.phone-chat-built) .chat-msg.sent {
  background: #007aff;
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
