/* ==========================================================================
   Chatbot SLEP Talagante Ayuda - WhatsApp Style Stylesheet
   ========================================================================== */

:root {
  --wa-primary: #008069;
  --wa-primary-dark: #00a884;
  --wa-header-bg: #075e54;
  --wa-header-text: #ffffff;
  --wa-app-bg: #eae6df;
  --wa-chat-bg: #111b21;
  --wa-user-bubble: #d9fdd3;
  --wa-user-bubble-shadow: rgba(11, 20, 26, 0.13);
  --wa-bot-bubble: #ffffff;
  --wa-bot-bubble-shadow: rgba(11, 20, 26, 0.13);
  --wa-text-primary: #111b21;
  --wa-text-secondary: #667781;
  --wa-text-muted: #8696a0;
  --wa-meta-time: #667781;
  --wa-tick-blue: #53bdeb;
  --wa-tick-gray: #8696a0;
  --wa-input-bg: #ffffff;
  --wa-send-btn: #00a884;
  --wa-send-btn-hover: #008f6f;
  --wa-chip-bg: #ffffff;
  --wa-chip-border: #e2e8f0;
  --wa-chip-text: #008069;
}

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

html, body {
  height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #d1d7db;
  color: var(--wa-text-primary);
  overflow: hidden;
}

/* Background canvas for desktop view (WhatsApp Web feel) */
.app-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #00a884 0%, #00a884 127px, #eae6df 127px, #eae6df 100%);
}

/* Mobile-first / Centered Phone Frame */
.chat-window {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 500px;
  background-color: #efeae2;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.15);
}

@media (min-width: 640px) {
  .chat-window {
    height: 94vh;
    border-radius: 14px;
  }
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.chat-header {
  height: 62px;
  background-color: var(--wa-header-bg);
  color: var(--wa-header-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 20;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
}

.header-back-btn {
  background: transparent;
  border: none;
  color: var(--wa-header-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.15s;
}

.header-back-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.avatar-wrapper {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
  background-color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.online-badge {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background-color: #25d366;
  border: 2px solid var(--wa-header-bg);
  border-radius: 50%;
}

.header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}

.verified-icon {
  display: inline-flex;
  color: #1da1f2;
  flex-shrink: 0;
}

.header-status {
  font-size: 12px;
  color: #e0f2fe;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s ease;
}

.header-status.typing {
  color: #a7f3d0;
  font-weight: 500;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--wa-header-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.15s;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* --------------------------------------------------------------------------
   Menu desplegable
   -------------------------------------------------------------------------- */
.menu-dropdown {
  position: absolute;
  top: 55px;
  right: 12px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  min-width: 200px;
  z-index: 50;
  display: none;
  flex-direction: column;
  padding: 6px 0;
  animation: fadeInDown 0.15s ease-out;
}

.menu-dropdown.show {
  display: flex;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.menu-item {
  padding: 10px 16px;
  font-size: 14px;
  color: #111b21;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
}

.menu-item:hover {
  background-color: #f5f6f6;
}

.menu-divider {
  height: 1px;
  background-color: #e9edef;
  margin: 4px 0;
}

/* --------------------------------------------------------------------------
   Messages Body / Viewport
   -------------------------------------------------------------------------- */
.chat-body {
  flex: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  
  /* WhatsApp chat background using the official institutional image */
  background-image: url('assets/bg-chat.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Subtle overlay to ensure chat bubble text readability */
.chat-body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(14, 45, 74, 0.28);
  pointer-events: none;
}

.chat-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* System Banner / Disclaimer */
.system-banner {
  align-self: center;
  background-color: rgba(255, 255, 255, 0.95);
  color: #54656f;
  font-size: 12px;
  text-align: center;
  padding: 7px 14px;
  border-radius: 8px;
  max-width: 90%;
  margin: 6px auto 10px auto;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.35;
}

.system-banner svg {
  flex-shrink: 0;
  color: #008069;
}

/* Date Badge */
.date-badge {
  align-self: center;
  background-color: rgba(255, 255, 255, 0.9);
  color: #54656f;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  margin: 4px auto 8px auto;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  letter-spacing: 0.5px;
}

/* --------------------------------------------------------------------------
   Message Bubbles
   -------------------------------------------------------------------------- */
.message-row {
  display: flex;
  width: 100%;
  margin-bottom: 2px;
  animation: messageIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.bot {
  justify-content: flex-start;
}

.bubble {
  position: relative;
  max-width: 82%;
  padding: 8px 12px 6px 12px;
  border-radius: 8px;
  font-size: 14.2px;
  line-height: 1.42;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.bubble a {
  color: #027eb5;
  text-decoration: underline;
  word-break: break-all;
}

.bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12.5px;
}

.bubble ul, .bubble ol {
  margin: 6px 0 6px 18px;
}

.bubble li {
  margin-bottom: 3px;
}

.bubble strong, .bubble b {
  font-weight: 600;
}

/* Bot Bubble Styling */
.message-row.bot .bubble {
  background-color: var(--wa-bot-bubble);
  color: var(--wa-text-primary);
  border-top-left-radius: 0;
  box-shadow: 0 1px 2px var(--wa-bot-bubble-shadow);
}

/* Bot Tail */
.message-row.bot .bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 0px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 10px solid var(--wa-bot-bubble);
}

/* User Bubble Styling */
.message-row.user .bubble {
  background-color: var(--wa-user-bubble);
  color: var(--wa-text-primary);
  border-top-right-radius: 0;
  box-shadow: 0 1px 2px var(--wa-user-bubble-shadow);
}

/* User Tail */
.message-row.user .bubble::after {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 0;
  height: 0;
  border-top: 0px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 10px solid var(--wa-user-bubble);
}

/* Bubble Meta (Time & Status) */
.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 2px;
  margin-left: 14px;
  float: right;
  font-size: 10.5px;
  color: var(--wa-meta-time);
  user-select: none;
}

.tick-icon {
  display: inline-flex;
  margin-left: 1px;
}

.tick-icon.sent {
  color: var(--wa-tick-gray);
}

.tick-icon.read {
  color: var(--wa-tick-blue);
}

/* --------------------------------------------------------------------------
   Typing Indicator
   -------------------------------------------------------------------------- */
.typing-bubble {
  background-color: var(--wa-bot-bubble);
  border-top-left-radius: 0;
  padding: 10px 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 1px 2px var(--wa-bot-bubble-shadow);
  width: fit-content;
  position: relative;
}

.typing-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-bottom: 10px solid transparent;
  border-right: 10px solid var(--wa-bot-bubble);
}

.typing-dot {
  width: 7px;
  height: 7px;
  background-color: #8696a0;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.65);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
    background-color: #00a884;
  }
}

/* --------------------------------------------------------------------------
   Quick Suggestions / Action Chips
   -------------------------------------------------------------------------- */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 10px 0;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.quick-chip {
  background-color: rgba(255, 255, 255, 0.95);
  color: #056162;
  border: 1px solid rgba(0, 168, 132, 0.3);
  padding: 7px 12px;
  border-radius: 18px;
  font-size: 12.8px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.15s ease;
  user-select: none;
}

.quick-chip:hover {
  background-color: #008069;
  color: #ffffff;
  border-color: #008069;
  transform: translateY(-1px);
}

.quick-chip:active {
  transform: scale(0.96);
}

/* --------------------------------------------------------------------------
   Footer / Input Area (Text Only)
   -------------------------------------------------------------------------- */
.chat-footer {
  background-color: #f0f2f5;
  padding: 8px 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  z-index: 20;
  flex-shrink: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.input-box-wrapper {
  flex: 1;
  background-color: var(--wa-input-bg);
  border-radius: 22px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  min-height: 42px;
}

.chat-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 15px;
  line-height: 1.4;
  color: var(--wa-text-primary);
  background: transparent;
  resize: none;
  max-height: 120px;
  font-family: inherit;
  padding: 4px 0;
}

.chat-input::placeholder {
  color: var(--wa-text-muted);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--wa-send-btn);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
  transition: background-color 0.15s, transform 0.1s;
}

.send-btn:hover {
  background-color: var(--wa-send-btn-hover);
}

.send-btn:active {
  transform: scale(0.93);
}

.send-btn:disabled {
  background-color: #aebac1;
  cursor: not-allowed;
  transform: none;
}

/* --------------------------------------------------------------------------
   Modal / Info Dialog
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-overlay.show {
  display: flex;
}

.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 420px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  animation: modalScale 0.2s ease-out;
}

@keyframes modalScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  background-color: var(--wa-header-bg);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 20px;
  font-size: 14px;
  color: #3b4a54;
  line-height: 1.55;
}

.modal-body p {
  margin-bottom: 12px;
}

.modal-body ul {
  margin: 8px 0 16px 20px;
}

.modal-footer {
  padding: 12px 20px 16px 20px;
  display: flex;
  justify-content: flex-end;
}

.modal-btn {
  background-color: var(--wa-primary);
  color: #ffffff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

/* Scrollbar customization */
.chat-body::-webkit-scrollbar {
  width: 5px;
}

.chat-body::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}
