/* style.css - Interfaz moderna WhatsApp para INSECE con soporte de micro */
:root {
  --wa-bg: #eae6df;
  --wa-header: #075e54;
  --wa-teal: #128c7e;
  --wa-green: #25d366;
  --wa-chat-bg: #efeae2;
  --msg-user: #d9fdd3;
  --msg-bot: #ffffff;
  --text-primary: #111b21;
  --text-secondary: #667781;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body, html {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  background-color: #d1d7db;
}

.hidden {
  display: none !important;
}

/* PANTALLA LOGIN */
#login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #075e54 0%, #128c7e 100%);
  padding: 20px;
}

.login-card {
  background: white;
  width: 100%;
  max-width: 380px;
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  text-align: center;
}

.brand .logo-circle {
  width: 60px;
  height: 60px;
  background: #25d366;
  color: white;
  font-size: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.brand h1 {
  font-size: 22px;
  color: #111b21;
}

.brand p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.user-select-group {
  text-align: left;
  margin-bottom: 20px;
}

.user-select-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 8px;
}

.user-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.user-btn {
  background: #f0f2f5;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 12px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.2s;
}

.user-btn .avatar {
  font-size: 24px;
  margin-bottom: 4px;
}

.user-avatar-img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 6px;
  border: 3px solid #e2e8f0;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
  transition: transform 0.2s, border-color 0.2s;
}

.user-btn.active .user-avatar-img {
  border-color: var(--wa-teal);
  transform: scale(1.06);
}

.header-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.fwd-avatar-img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 12px;
}

.bubble-mini-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 4px;
}

.user-btn .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-btn.active {
  border-color: var(--wa-teal);
  background: #e8f5e9;
}

.input-group {
  text-align: left;
  margin-bottom: 24px;
}

.input-group label {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ced0d4;
  border-radius: 8px;
  font-size: 16px;
  text-align: center;
  letter-spacing: 4px;
}

.btn-primary {
  width: 100%;
  background: var(--wa-teal);
  color: white;
  border: none;
  border-radius: 25px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* APP PRINCIPAL */
#app-screen {
  display: flex;
  width: 100%;
  height: 100%;
  background: white;
}

/* PANEL LISTA CHATS */
#chat-list-panel {
  width: 360px;
  border-right: 1px solid #d1d7db;
  display: flex;
  flex-direction: column;
  background: white;
}

.panel-header {
  height: 60px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.my-avatar {
  width: 40px;
  height: 40px;
  background: var(--wa-teal);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  overflow: hidden;
}

.header-titles {
  flex: 1;
}

.header-titles h2 {
  font-size: 16px;
  color: var(--text-primary);
}

#current-user-badge {
  font-size: 12px;
  color: var(--wa-teal);
  font-weight: 600;
}

#btn-logout {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

.quick-chips {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid #f0f2f5;
}

.chip {
  background: #f0f2f5;
  border: none;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.chip.active {
  background: #d9fdd3;
  color: #008069;
  font-weight: 600;
}

.chats-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
}

.chat-item:hover, .chat-item.active {
  background: #f5f6f6;
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e9edef;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.chat-avatar.group {
  background: #d1e7dd;
}

.chat-avatar.bot {
  background: #cfe2ff;
}

.chat-info {
  flex: 1;
  min-width: 0;
}

.chat-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chat-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-time {
  font-size: 11px;
  color: var(--text-secondary);
}

.chat-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* PANEL CONVERSACIÓN */
#chat-conversation-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--wa-chat-bg);
  position: relative;
}

.conv-header {
  height: 60px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  border-bottom: 1px solid #d1d7db;
}

.mobile-only {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #d1e7dd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.conv-details h3 {
  font-size: 15px;
  color: var(--text-primary);
}

.conv-status {
  font-size: 11px;
  color: var(--wa-teal);
}

/* ÁREA MENSAJES */
.messages-container {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-row {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.message-row.me {
  align-self: flex-end;
}

.message-row.other {
  align-self: flex-start;
}

.message-bubble {
  padding: 8px 12px 6px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
  position: relative;
  word-break: break-word;
}

.message-row.me .message-bubble {
  background: var(--msg-user);
  border-top-right-radius: 0;
}

.message-row.other .message-bubble {
  background: var(--msg-bot);
  border-top-left-radius: 0;
}

.message-sender {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 3px;
  color: #128c7e;
}

.message-row.secretaria .message-sender {
  color: #075e54;
}

.message-text {
  color: var(--text-primary);
  white-space: pre-wrap;
}

.message-time {
  font-size: 10px;
  color: var(--text-secondary);
  float: right;
  margin-left: 10px;
  margin-top: 4px;
}

/* ACCESOS RÁPIDOS */
.action-shortcuts {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(240, 242, 245, 0.95);
  border-top: 1px solid #e9edef;
  white-space: nowrap;
}

.action-shortcuts::-webkit-scrollbar {
  display: none;
}

.shortcut-btn {
  background: white;
  border: 1px solid #d1d7db;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.shortcut-btn:hover {
  background: #f5f6f6;
  border-color: var(--wa-teal);
}

/* BARRA DE ENTRADA */
.input-bar {
  min-height: 60px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
}

#msg-input {
  flex: 1;
  background: white;
  border: none;
  border-radius: 20px;
  padding: 12px 18px;
  font-size: 14px;
  outline: none;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: white;
  color: var(--text-secondary);
  border: 1px solid #ced0d4;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-icon.recording {
  background: #e53935 !important;
  color: white !important;
  border-color: #d32f2f !important;
  box-shadow: 0 0 0 6px rgba(229, 57, 53, 0.3);
  animation: pulse-mic 1s infinite alternate;
}

@keyframes pulse-mic {
  0% { transform: scale(1); box-shadow: 0 0 0 4px rgba(229, 57, 53, 0.2); }
  100% { transform: scale(1.12); box-shadow: 0 0 0 10px rgba(229, 57, 53, 0.45); }
}

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--wa-teal);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-send:hover {
  background: #075e54;
}

/* RESPONSIVE MÓVIL */
@media (max-width: 768px) {
  #chat-list-panel {
    width: 100%;
    height: 100%;
    height: 100dvh;
  }
  
  #chat-conversation-panel {
    display: none;
    width: 100%;
    height: 100%;
    height: 100dvh;
  }

  body.in-conversation #chat-list-panel {
    display: none;
  }

  body.in-conversation #chat-conversation-panel {
    display: flex;
  }

  .mobile-only {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
  }

  .conv-header {
    padding-top: max(8px, env(safe-area-inset-top));
    height: auto;
    min-height: 56px;
  }

  .message-row {
    max-width: 92%;
  }

  .input-bar {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }

  .wa-action-bar {
    flex-wrap: wrap;
    gap: 6px;
  }

  .btn-wa-action {
    font-size: 11px;
    padding: 6px 9px;
  }

  .forward-card, .feedback-card {
    max-width: min(440px, 94vw);
    border-radius: 14px;
    margin: auto;
  }
}

/* ==============================================================
   ACCIONES DE MENSAJES Y ARCHIVOS (DESCARGAR Y REENVIAR)
   ============================================================== */
.wa-action-bar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

.wa-action-bar.text-only {
  justify-content: flex-end;
  border-top: none;
  margin-top: 4px;
}

.btn-wa-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid #d1d7db;
  background: #f0f2f5;
  color: #111b21;
  transition: all 0.2s ease;
}

.btn-wa-action:hover {
  background: #e9edef;
  border-color: #8696a0;
}

.btn-wa-action.download {
  color: #008069;
  border-color: #a7d7c5;
  background: #e7f7ef;
}

.btn-wa-action.download:hover {
  background: #d1f4e0;
}

.btn-wa-action.forward {
  color: #128c7e;
}

.btn-wa-action.text-btn {
  font-size: 11px;
  padding: 3px 8px;
  opacity: 0.8;
}

/* TARJETAS DE ENLACES Y MANUALES PDF */
.link-card {
  background: #f7f9fa;
  border: 1px solid #e1e4e8;
  border-left: 4px solid #008069;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
}

.link-title {
  font-size: 13px;
  color: #111b21;
  margin-bottom: 8px;
  line-height: 1.3;
}

.link-actions {
  display: flex;
  gap: 8px;
}

.btn-link-action {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid #008069;
  background: #008069;
  color: white;
  transition: background 0.2s;
}

.btn-link-action:hover {
  background: #075e54;
}

.btn-link-action.fwd-link {
  background: white;
  color: #008069;
}

.btn-link-action.fwd-link:hover {
  background: #e7f7ef;
}

/* ==============================================================
   MODAL DE REENVÍO ESTILO WHATSAPP
   ============================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.forward-card {
  background: white;
  width: 100%;
  max-width: 440px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(0,0,0,0.25);
  animation: slideUpModal 0.25s ease;
}

@keyframes slideUpModal {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

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

.btn-close-x {
  background: transparent;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

.forward-body {
  padding: 16px 20px;
  max-height: 80vh;
  overflow-y: auto;
}

.forward-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-weight: 500;
}

.forward-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fwd-opt-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.fwd-opt-btn:hover {
  background: #e7f7ef;
  border-color: #a7d7c5;
  transform: translateX(2px);
}

.fwd-icon {
  font-size: 24px;
}

.fwd-text strong {
  display: block;
  font-size: 14px;
  color: #111b21;
}

.fwd-text span {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==============================================================
   BOTÓN Y MODAL DE ENSEÑAR A SARA / ANTIGRAVITY
   ============================================================== */
.btn-wa-action.feedback-btn {
  color: #b45309;
  border-color: #fde68a;
  background: #fef3c7;
}

.btn-wa-action.feedback-btn:hover {
  background: #fde68a;
  border-color: #f59e0b;
}

.feedback-header {
  background: #0f766e;
}

.feedback-context-preview {
  background: #f1f5f9;
  border-left: 3px solid #0f766e;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: #475569;
  margin-bottom: 12px;
  max-height: 90px;
  overflow-y: auto;
}

.feedback-textarea {
  width: 100%;
  min-height: 100px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: #1e293b;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
  margin-bottom: 12px;
}

.feedback-textarea:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.feedback-submit-btn {
  width: 100%;
  padding: 12px;
  background: #0f766e;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.feedback-submit-btn:hover {
  background: #115e59;
}

