/* ================================================
   PIXEL-PERFECT WhatsApp Mobile Chat Clone
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html { height: 100%; }

body {
  height: 100%;
  width: 100%;
  font-family: 'Roboto', 'Segoe UI', Helvetica, Arial, sans-serif;
  background: #000;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ─────────────────────────────────────────────
   FULL-SCREEN CALL OVERLAY  (.llamada)
   Hidden by default — shown via JS (.llama)
───────────────────────────────────────────── */
a.llamada {
  display: none;          /* HIDDEN until .llama added */
  position: fixed;
  inset: 0;
  z-index: 9999;
  text-decoration: none;
  background-color: #1a1a2e;
  background-size: cover;
  background-position: center top;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

/* Dark overlay on bg photo */
a.llamada::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(7, 94, 84, 0.82) 0%,
    rgba(5, 40, 36, 0.95) 100%
  );
}

/* Show when JS adds .llama */
a.llamada.llama {
  display: flex;
  animation: callFadeIn 0.45s ease forwards;
}

@keyframes callFadeIn {
  from { opacity: 0; transform: scale(1.04); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Call overlay content ── */
.wsptit {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

/* Avatar ring shown in overlay */
.wsptit .call-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(255,255,255,0.3);
  box-shadow: 0 0 0 8px rgba(37,211,102,0.2), 0 0 40px rgba(0,0,0,0.5);
  animation: avatarPulse 1.6s ease-in-out infinite;
}

@keyframes avatarPulse {
  0%   { box-shadow: 0 0 0 8px rgba(37,211,102,0.2), 0 0 40px rgba(0,0,0,0.5); }
  50%  { box-shadow: 0 0 0 18px rgba(37,211,102,0.08), 0 0 40px rgba(0,0,0,0.5); }
  100% { box-shadow: 0 0 0 8px rgba(37,211,102,0.2), 0 0 40px rgba(0,0,0,0.5); }
}

.wsptit h1 {
  color: #fff;
  font-size: 26px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.3px;
}

.wsptit h1 img.wsp-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.wsptit h2 {
  color: rgba(255,255,255,0.75);
  font-size: 16px;
  font-weight: 400;
}

.wsptit h3 {
  color: #25d366;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: blinkText 1.1s ease-in-out infinite;
}

@keyframes blinkText {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* Accept / Decline buttons */
.call-actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 60px;
  margin-top: 40px;
}

.call-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
}

.call-btn-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.call-btn-circle.accept { background: #25d366; }
.call-btn-circle.decline { background: #f44336; }

/* ─────────────────────────────────────────────
   MAIN CHAT WRAPPER  (#general)
───────────────────────────────────────────── */
#general {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #efeae2;
}

/* ─────────────────────────────────────────────
   CHAT BACKGROUND IMAGE  (#chat-bg)
   img/12.webp fills the chat area only
───────────────────────────────────────────── */
#chat-bg {
  position: absolute;
  inset: 0;
  background-image: url('img/12.webp');
  background-size: cover;
  background-position: center;
  /* slight dim so bubbles stay readable */
  filter: brightness(0.88);
  z-index: 0;
  pointer-events: none;
}

/* header and input bar sit above the bg */
#cab      { position: relative; z-index: 2; }
#chat     { position: relative; z-index: 2; }
.escribir { position: relative; z-index: 2; }

/* ═══════════════════════════════════════════
   HEADER / CONTACT BAR  (#cab)
═══════════════════════════════════════════ */
#cab {
  background: #075e54;
  padding: 8px 12px 8px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Back arrow */
#cab::before {
  content: '‹';
  color: #fff;
  font-size: 28px;
  line-height: 1;
  font-weight: 300;
  flex-shrink: 0;
}

.avatar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

img#avatarimg {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #ccc;
}

.nombre {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.nombre h1 {
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: margin-top 0.3s ease;
}

.nombre h1.mt10 { margin-top: 10px; }

.nombre h2 {
  color: rgba(255,255,255,0.72);
  font-size: 12.5px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Three-dots icon */
#cab::after {
  content: '⋮';
  color: #fff;
  font-size: 22px;
  flex-shrink: 0;
  opacity: 0.85;
}

/* ═══════════════════════════════════════════
   CHAT AREA  (#chat)
═══════════════════════════════════════════ */
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scroll-behavior: smooth;
  background: transparent;
}

#chat::-webkit-scrollbar { width: 3px; }
#chat::-webkit-scrollbar-track { background: transparent; }
#chat::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}

/* ── Base bubble ── */
#chat p {
  position: relative;
  display: inline-block;
  max-width: 82%;
  padding: 6px 10px 20px 10px;
  border-radius: 7.5px;
  font-size: 14.5px;
  line-height: 1.45;
  word-wrap: break-word;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  animation: msgPop 0.18s ease-out forwards;
}

@keyframes msgPop {
  from { opacity: 0; transform: scale(0.93) translateY(5px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ── Received (left, white) ── */
#chat p.ella,
#chat p:not(.yo):not(.final) {
  background: #ffffff;
  color: #111;
  align-self: flex-start;
  border-top-left-radius: 0;
  margin-right: auto;
}

#chat p.ella::after,
#chat p:not(.yo):not(.final)::after {
  content: '';
  position: absolute;
  top: 0; left: -8px;
  width: 0; height: 0;
  border-top: 8px solid #ffffff;
  border-left: 8px solid transparent;
}

/* ── Sent (right, green) ── */
#chat p.yo {
  background: #d9fdd3;
  color: #111;
  align-self: flex-end;
  border-top-right-radius: 0;
  margin-left: auto;
}

#chat p.yo::after {
  content: '';
  position: absolute;
  top: 0; right: -8px; left: unset;
  width: 0; height: 0;
  border-top: 8px solid #d9fdd3;
  border-right: 8px solid transparent;
}

/* ── Final message (left, white) ── */
#chat p.final {
  background: #fff;
  color: #111;
  align-self: flex-start;
  border-top-left-radius: 0;
  margin-right: auto;
}

#chat p.final::after {
  content: '';
  position: absolute;
  top: 0; left: -8px;
  width: 0; height: 0;
  border-top: 8px solid #fff;
  border-left: 8px solid transparent;
}

/* ── Timestamp ── */
span.hora {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 10.5px;
  color: rgba(0,0,0,0.45);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
}

span.hora::after {
  content: '';
  display: inline-block;
  width: 14px; height: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 11'%3E%3Cpath d='M11.071.653L4.42 7.304 1.854 4.737.146 6.444l4.274 4.274 8.303-8.303z' fill='%23aaa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}

span.hora.visto::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 11'%3E%3Cpath d='M17.394.607L7.42 10.581 1.854 5.015.146 6.722l7.274 7.274 11.632-11.632z' fill='%23aaa'/%3E%3C/svg%3E");
}

span.hora.vistoc::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 11'%3E%3Cpath d='M17.394.607L7.42 10.581 1.854 5.015.146 6.722l7.274 7.274 11.632-11.632z' fill='%234fc3f7'/%3E%3C/svg%3E");
}

/* ═══════════════════════════════════════════
   VIDEO THUMBNAIL BUBBLE
═══════════════════════════════════════════ */
a.video {
  display: block;
  width: 210px;
  height: 148px;
  background-color: #222;
  background-size: cover;
  background-position: center;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  margin: -2px -2px 6px -2px;
}

a.video::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.28);
}

a.video::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 46px; height: 46px;
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.85);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z' fill='white'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 22px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.duracion {
  position: absolute;
  bottom: 7px; right: 9px;
  font-size: 11px;
  color: #fff;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  z-index: 1;
  letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════
   INPUT BAR (.escribir)
═══════════════════════════════════════════ */
.escribir {
  background: #f0f2f5;
  display: flex;
  align-items: center;
  padding: 7px 8px;
  gap: 8px;
  flex-shrink: 0;
  border-top: 1px solid #ddd;
}

.escribir > img:first-child {
  width: 26px; height: 26px;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.escribir > img:first-child:hover { opacity: 0.9; }

.escribir input[type="text"] {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: none;
  border-radius: 20px;
  padding: 0 16px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: #111;
  outline: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.escribir input[type="text"]::placeholder {
  color: #aaa;
  font-size: 14.5px;
}

.escribir button {
  width: 42px; height: 42px;
  min-width: 42px;
  background: #25d366;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37,211,102,0.35);
  transition: background 0.15s, transform 0.1s;
}

.escribir button:active {
  transform: scale(0.91);
  background: #1ea952;
}

.escribir button img {
  width: 20px; height: 20px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 380px) {
  #chat p { font-size: 13.5px; }
  .nombre h1 { font-size: 15px; }
}

@media (min-width: 431px) {
  body { background: #111b21; }
  #general {
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  }
}
