/* ============================================================
   Vio Bosco
   Desarrollado por: Ing. Miguel Angel Montecinos Flores   
   Paleta de colores: Amarillo #F5C518 | Azul Marino #0D1B3E | Naranja #FF6B2B | Blanco #FFFFFF | Negro #0A0A0A
   ============================================================ */

:root {
  --amarillo:     #F5C518;
  --amarillo-dark:#D4A800;
  --azul-marino:  #0D1B3E;
  --azul-claro:   #162550;
  --naranja:      #FF6B2B;
  --naranja-dark: #E05520;
  --blanco:       #FFFFFF;
  --negro:        #0A0A0A;
  --gris-100:     #F8F9FA;
  --gris-200:     #E9ECEF;
  --gris-300:     #CED4DA;
  --gris-500:     #6C757D;
  --gris-700:     #495057;
  --shadow-sm:    0 2px 8px rgba(0,0,0,.12);
  --shadow-md:    0 4px 20px rgba(0,0,0,.18);
  --shadow-lg:    0 8px 40px rgba(0,0,0,.22);
  --radius-sm:    8px;
  --radius-md:    14px;
  --radius-lg:    22px;
  --radius-full:  9999px;
  --transition:   .25s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--azul-marino);
  color: var(--negro);
  min-height: 100vh;
  overflow: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gris-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--naranja); }

/* ======================================================
   AUTH PAGES (Login / Register)
   ====================================================== */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--azul-marino) 0%, var(--azul-claro) 60%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow:scroll;
}
.auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,197,24,.08) 0%, transparent 70%);
  top: -200px; right: -200px;
  pointer-events: none;
}
.auth-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,107,43,.06) 0%, transparent 70%);
  bottom: -150px; left: -100px;
  pointer-events: none;
}

.auth-card {
  background: var(--blanco);
  border-radius: var(--radius-lg);
  padding: 2.8rem 2.4rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.05);
  position: relative;
  z-index: 1;
  animation: slideUp .5s ease;
}
@keyframes slideUp {
  from { opacity:0; transform: translateY(24px); }
  to   { opacity:1; transform: translateY(0); }
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 2rem;
  justify-content: center;
}
.auth-logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--azul-marino), var(--azul-claro));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(13,27,62,.3);
}
.auth-logo-icon svg { color: var(--amarillo); }
.auth-logo-text h1 { font-size: 1.5rem; font-weight: 800; color: var(--azul-marino); letter-spacing: -.5px; }
.auth-logo-text span { font-size: .8rem; color: var(--gris-500); font-weight: 500; }

.auth-title { font-size: 1.4rem; font-weight: 700; color: var(--azul-marino); margin-bottom: .4rem; }
.auth-subtitle { font-size: .9rem; color: var(--gris-500); margin-bottom: 1.8rem; }

/* Inputs */
.form-group { margin-bottom: 1.1rem; position: relative; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--gris-700); margin-bottom: .4rem; text-transform: uppercase; letter-spacing: .4px; }
.form-control {
  width: 100%; padding: .75rem 1rem;
  border: 2px solid var(--gris-200);
  border-radius: var(--radius-sm);
  font-size: .95rem; color: var(--negro);
  background: var(--gris-100);
  transition: var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--amarillo); background: var(--blanco); box-shadow: 0 0 0 3px rgba(245,197,24,.15); }
.form-control::placeholder { color: var(--gris-300); }
.form-control.input-icon { padding-left: 2.8rem; }
.input-wrapper { position: relative; }
.input-wrapper .icon {
  position: absolute; left: .9rem; top: 50%; transform: translateY(-50%);
  color: var(--gris-300); pointer-events: none; transition: var(--transition);
}
.form-control:focus + .icon,
.input-wrapper:focus-within .icon { color: var(--amarillo); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem; padding: .8rem 1.6rem;
  border: none; border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 600; cursor: pointer;
  transition: var(--transition); text-decoration: none; letter-spacing: .2px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--amarillo), var(--amarillo-dark));
  color: var(--azul-marino);
  box-shadow: 0 4px 14px rgba(245,197,24,.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245,197,24,.45); }
.btn-primary:active { transform: translateY(0); }
.btn-naranja {
  background: linear-gradient(135deg, var(--naranja), var(--naranja-dark));
  color: var(--blanco);
  box-shadow: 0 4px 14px rgba(255,107,43,.3);
}
.btn-naranja:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(255,107,43,.4); }
.btn-outline {
  background: transparent;
  border: 2px solid var(--gris-200);
  color: var(--gris-700);
}
.btn-outline:hover { border-color: var(--azul-marino); color: var(--azul-marino); background: var(--gris-100); }
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: var(--blanco);
}
.btn-danger:hover { transform: translateY(-1px); }
.btn-block { width: 100%; }
.btn-sm { padding: .5rem 1rem; font-size: .85rem; }
.btn-icon { padding: .6rem; border-radius: var(--radius-full); }

.auth-link { text-align: center; margin-top: 1.2rem; font-size: .88rem; color: var(--gris-500); }
.auth-link a { color: var(--naranja); font-weight: 600; text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

/* ======================================================
   CHAT LAYOUT
   ====================================================== */
.chat-app {
  display: flex;
  height: 100vh;
  background: var(--gris-100);
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 340px;
  min-width: 280px;
  background: var(--azul-marino);
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.06);
  position: relative;
  z-index: 10;
}

.sidebar-header {
  background: var(--azul-claro);
  padding: 1rem 1.2rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex; align-items: center; gap: .8rem; flex: 1; min-width: 0;
  cursor: pointer; padding: .3rem; border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-user:hover { background: rgba(255,255,255,.06); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--amarillo), var(--naranja));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem; color: var(--azul-marino);
  flex-shrink: 0; overflow: hidden; position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.2rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.6rem; }
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-weight: 600; font-size: .9rem; color: var(--blanco); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-status { font-size: .75rem; color: rgba(255,255,255,.5); }
.sidebar-actions { display: flex; gap: .3rem; }
.sidebar-actions button { background: transparent; border: none; cursor: pointer; padding: .5rem; border-radius: var(--radius-full); color: rgba(255,255,255,.6); transition: var(--transition); }
.sidebar-actions button:hover { background: rgba(255,255,255,.1); color: var(--amarillo); }

/* Search */
.sidebar-search { padding: .8rem 1rem; background: var(--azul-marino); }
.search-box {
  display: flex; align-items: center; gap: .5rem;
  background: rgba(255,255,255,.08);
  border-radius: var(--radius-full);
  padding: .5rem 1rem;
  border: 1px solid rgba(255,255,255,.1);
  transition: var(--transition);
}
.search-box:focus-within { background: rgba(255,255,255,.12); border-color: var(--amarillo); }
.search-box input { background: transparent; border: none; outline: none; flex: 1; font-size: .88rem; color: var(--blanco); }
.search-box input::placeholder { color: rgba(255,255,255,.35); }
.search-box svg { color: rgba(255,255,255,.4); flex-shrink: 0; }

/* Tabs */
.sidebar-tabs { display: flex; padding: 0 1rem .5rem; gap: .4rem; }
.tab-btn {
  flex: 1; padding: .45rem; border: none; border-radius: var(--radius-sm);
  font-size: .78rem; font-weight: 600; cursor: pointer;
  background: transparent; color: rgba(255,255,255,.45);
  transition: var(--transition); text-transform: uppercase; letter-spacing: .4px;
}
.tab-btn.active { background: var(--amarillo); color: var(--azul-marino); }
.tab-btn:hover:not(.active) { background: rgba(255,255,255,.08); color: var(--blanco); }

/* Conversations list */
.conversations-list { flex: 1; overflow-y: auto; padding: .4rem 0; }
.conv-item {
  display: flex; align-items: center; gap: .9rem;
  padding: .75rem 1.2rem; cursor: pointer;
  transition: var(--transition); position: relative;
  border-left: 3px solid transparent;
}
.conv-item:hover { background: rgba(255,255,255,.05); }
.conv-item.active { background: rgba(245,197,24,.1); border-left-color: var(--amarillo); }
.conv-info { flex: 1; min-width: 0; }
.conv-name { font-weight: 600; font-size: .88rem; color: var(--blanco); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-last-msg { font-size: .78rem; color: rgba(255,255,255,.45); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; flex-shrink: 0; }
.conv-time { font-size: .72rem; color: rgba(255,255,255,.35); }
.conv-badge {
  background: var(--naranja);
  color: var(--blanco); font-size: .7rem; font-weight: 700;
  padding: .15rem .45rem; border-radius: var(--radius-full); min-width: 20px; text-align: center;
}
.online-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #22c55e; border: 2px solid var(--azul-marino);
  position: absolute; bottom: 2px; right: 2px;
}

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 2rem; text-align: center; }
.empty-state svg { color: rgba(255,255,255,.2); margin-bottom: 1rem; }
.empty-state p { color: rgba(255,255,255,.3); font-size: .85rem; line-height: 1.6; }

/* ---- Chat Panel ---- */
.chat-panel {
  flex: 1; display: flex; flex-direction: column;
  background: #f0ece3;
  position: relative;
  background-image:
    radial-gradient(circle at 15% 25%, rgba(245,197,24,.04) 0%, transparent 50%),
    radial-gradient(circle at 85% 75%, rgba(255,107,43,.03) 0%, transparent 50%);
}

/* Welcome screen */
.chat-welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1.2rem; color: var(--gris-500);
}
.chat-welcome-icon {
  width: 120px; height: 120px;
  background: linear-gradient(135deg, var(--azul-marino), var(--azul-claro));
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  animation: pulse 3s ease-in-out infinite;
}
.chat-welcome-icon svg { color: var(--amarillo); }
@keyframes pulse { 0%,100% { box-shadow: var(--shadow-md); } 50% { box-shadow: 0 0 0 12px rgba(13,27,62,.12); } }
.chat-welcome h2 { font-size: 1.5rem; font-weight: 700; color: var(--azul-marino); }
.chat-welcome p { font-size: .9rem; max-width: 320px; text-align: center; line-height: 1.6; }

/* Chat header */
.chat-header {
  background: var(--azul-marino);
  padding: .75rem 1.2rem;
  display: flex; align-items: center; gap: .9rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  box-shadow: var(--shadow-sm);
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 700; font-size: 1rem; color: var(--blanco); }
.chat-header-status { font-size: .78rem; color: rgba(255,255,255,.5); }
.chat-header-actions { display: flex; gap: .3rem; }
.chat-header-actions button { background: transparent; border: none; cursor: pointer; padding: .5rem; border-radius: var(--radius-full); color: rgba(255,255,255,.6); transition: var(--transition); }
.chat-header-actions button:hover { background: rgba(255,255,255,.1); color: var(--amarillo); }

/* Messages area */
.messages-area {
  flex: 1; overflow-y: auto; padding: 1.2rem;
  display: flex; flex-direction: column; gap: .5rem;
}

.msg-wrapper { display: flex; align-items: flex-end; gap: .5rem; max-width: 70%; }
.msg-wrapper.sent { margin-left: auto; flex-direction: row-reverse; }
.msg-wrapper.received { margin-right: auto; }

.msg-bubble {
  padding: .6rem .9rem;
  border-radius: var(--radius-md);
  position: relative; line-height: 1.5;
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  word-break: break-word;
}
.msg-wrapper.sent .msg-bubble {
  background: var(--amarillo);
  color: var(--azul-marino);
  border-bottom-right-radius: 4px;
}
.msg-wrapper.received .msg-bubble {
  background: var(--blanco);
  color: var(--negro);
  border-bottom-left-radius: 4px;
}
.msg-text { font-size: .9rem; }
.msg-meta {
  display: flex; align-items: center; gap: .3rem;
  justify-content: flex-end; margin-top: .3rem;
  font-size: .72rem; opacity: .65;
}
.msg-time { }
.msg-read { color: var(--azul-marino); }

/* Image messages */
.msg-image { max-width: 260px; border-radius: var(--radius-sm); display: block; cursor: zoom-in; }
.msg-image:hover { opacity: .9; }
.msg-caption { font-size: .82rem; margin-top: .4rem; opacity: .8; font-style: italic; }

/* Date separator */
.date-separator {
  display: flex; align-items: center; gap: .8rem;
  padding: .5rem 0; color: var(--gris-500); font-size: .75rem;
}
.date-separator::before, .date-separator::after {
  content: ''; flex: 1; height: 1px; background: var(--gris-200);
}
.date-separator span {
  background: rgba(255,255,255,.75);
  padding: .2rem .8rem; border-radius: var(--radius-full);
  font-weight: 600; white-space: nowrap;
}

/* ---- Input area ---- */
.chat-input-area {
  background: var(--blanco);
  border-top: 1px solid var(--gris-200);
  padding: .8rem 1.2rem;
  display: flex; flex-direction: column; gap: .5rem;
}

/* Image preview */
.image-preview {
  display: none; align-items: center; gap: .8rem;
  background: var(--gris-100); border-radius: var(--radius-sm);
  padding: .6rem .9rem; border: 2px dashed var(--naranja);
}
.image-preview.show { display: flex; }
.preview-img { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius-sm); }
.preview-info { flex: 1; min-width: 0; }
.preview-name { font-size: .8rem; font-weight: 600; color: var(--azul-marino); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-size { font-size: .72rem; color: var(--gris-500); }
.preview-remove { background: transparent; border: none; cursor: pointer; color: #ef4444; padding: .3rem; border-radius: var(--radius-full); transition: var(--transition); }
.preview-remove:hover { background: #fee2e2; }

.chat-input-row { display: flex; align-items: flex-end; gap: .6rem; }
.msg-input-wrap { flex: 1; background: var(--gris-100); border: 2px solid var(--gris-200); border-radius: var(--radius-lg); padding: .55rem 1rem; display: flex; align-items: center; gap: .5rem; transition: var(--transition); }
.msg-input-wrap:focus-within { border-color: var(--amarillo); background: var(--blanco); }
.msg-input { flex: 1; border: none; outline: none; background: transparent; font-size: .92rem; color: var(--negro); resize: none; max-height: 120px; min-height: 22px; line-height: 1.5; font-family: inherit; }
.msg-input::placeholder { color: var(--gris-300); }

.btn-attach { background: transparent; border: none; cursor: pointer; padding: .45rem; color: var(--gris-500); border-radius: var(--radius-full); transition: var(--transition); flex-shrink: 0; }
.btn-attach:hover { color: var(--naranja); background: rgba(255,107,43,.08); }

.btn-send {
  width: 46px; height: 46px;
  background: linear-gradient(135deg, var(--azul-marino), var(--azul-claro));
  border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--amarillo); flex-shrink: 0;
  transition: var(--transition); box-shadow: var(--shadow-sm);
}
.btn-send:hover { transform: scale(1.08); box-shadow: var(--shadow-md); }
.btn-send:active { transform: scale(.95); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---- Users list panel ---- */
.users-panel { padding: .4rem 0; }
.user-item {
  display: flex; align-items: center; gap: .9rem;
  padding: .65rem 1.2rem; cursor: pointer;
  transition: var(--transition);
}
.user-item:hover { background: rgba(255,255,255,.06); }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: .88rem; color: var(--blanco); }
.user-status { font-size: .75rem; color: rgba(255,255,255,.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-online-badge {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gris-300); flex-shrink: 0;
}
.user-online-badge.online { background: #22c55e; }

/* ======================================================
   MODALS
   ====================================================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--blanco); border-radius: var(--radius-lg);
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .3s ease;
}
.modal-header {
  background: linear-gradient(135deg, var(--azul-marino), var(--azul-claro));
  padding: 1.2rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--blanco); }
.modal-close { background: transparent; border: none; cursor: pointer; color: rgba(255,255,255,.6); padding: .3rem; border-radius: var(--radius-full); transition: var(--transition); }
.modal-close:hover { color: var(--blanco); background: rgba(255,255,255,.1); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gris-200); display: flex; gap: .75rem; justify-content: flex-end; }

/* Avatar upload */
.avatar-upload { display: flex; flex-direction: column; align-items: center; gap: .8rem; margin-bottom: 1.2rem; }
.avatar-preview {
  width: 90px; height: 90px; border-radius: 50%;
  background: linear-gradient(135deg, var(--amarillo), var(--naranja));
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700; color: var(--azul-marino);
  cursor: pointer; overflow: hidden; position: relative;
  box-shadow: var(--shadow-md); border: 4px solid var(--gris-200);
  transition: var(--transition);
}
.avatar-preview:hover { border-color: var(--amarillo); }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-preview-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: var(--transition); border-radius: 50%;
}
.avatar-preview:hover .avatar-preview-overlay { opacity: 1; }
.avatar-preview-overlay svg { color: var(--blanco); }

/* ======================================================
   IMAGE LIGHTBOX
   ====================================================== */
.lightbox {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s ease;
}
.lightbox.hidden { display: none; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }
.lightbox-close {
  position: absolute; top: 1rem; right: 1rem;
  background: rgba(255,255,255,.15); border: none; cursor: pointer;
  color: var(--blanco); padding: .6rem; border-radius: var(--radius-full);
  transition: var(--transition);
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ======================================================
   LOADING / SPINNER
   ====================================================== */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: currentColor;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.typing-indicator {
  display: flex; align-items: center; gap: 4px; padding: .6rem .9rem;
  background: var(--blanco); border-radius: var(--radius-md);
  width: fit-content; box-shadow: var(--shadow-sm);
}
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gris-300); animation: typing 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%,80%,100% { transform: scale(.8); opacity: .5; } 40% { transform: scale(1.1); opacity: 1; } }

/* ======================================================
   TOAST / NOTIFICATIONS
   ====================================================== */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 3000; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--blanco); border-radius: var(--radius-sm);
  padding: .9rem 1.2rem; display: flex; align-items: center; gap: .7rem;
  box-shadow: var(--shadow-md); min-width: 260px; max-width: 360px;
  animation: slideRight .3s ease;
  border-left: 4px solid var(--naranja);
}
@keyframes slideRight { from { opacity:0; transform: translateX(30px); } to { opacity:1; transform: translateX(0); } }
.toast.success { border-left-color: #22c55e; }
.toast.error   { border-left-color: #ef4444; }
.toast-msg { flex: 1; font-size: .88rem; color: var(--negro); }

/* ======================================================
   RESPONSIVE
   ====================================================== */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: absolute; z-index: 100; height: 100vh; transform: translateX(0); transition: var(--transition); }
  .sidebar.mobile-hidden { transform: translateX(-100%); }
  .chat-panel { width: 100%; }
  .msg-wrapper { max-width: 85%; }
}

/* ======================================================
   UTILITIES
   ====================================================== */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.text-amarillo { color: var(--amarillo); }
.text-naranja  { color: var(--naranja); }
.text-blanco   { color: var(--blanco); }
.font-bold     { font-weight: 700; }
.text-sm       { font-size: .85rem; }
.mt-1          { margin-top: .25rem; }
.mt-2          { margin-top: .5rem; }
.w-full        { width: 100%; }

/* ======================================================
   THEME: LIGHT MODE SUPPORT
   ====================================================== */
body.theme-light {
  --azul-marino: #1e293b;
  --azul-claro: #334155;
  --blanco: #ffffff;
  --gris-100: #f8fafc;
  --gris-200: #e2e8f0;
  --gris-300: #cbd5e1;
  --gris-500: #64748b;
  --gris-700: #334155;
  --negro: #0f172a;
}
body.theme-light .sidebar {
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
}
body.theme-light .sidebar-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
body.theme-light .sidebar-user-name { color: #0f172a; }
body.theme-light .sidebar-user-status { color: #64748b; }
body.theme-light .sidebar-actions button { color: #64748b; }
body.theme-light .sidebar-actions button:hover { background: #e2e8f0; color: var(--naranja); }
body.theme-light .sidebar-search { background: #ffffff; }
body.theme-light .search-box {
  background: #f1f5f9;
  border-color: #e2e8f0;
}
body.theme-light .search-box input { color: #0f172a; }
body.theme-light .search-box input::placeholder { color: #94a3b8; }
body.theme-light .search-box svg { color: #94a3b8; }
body.theme-light .tab-btn { color: #64748b; }
body.theme-light .tab-btn:hover:not(.active) { background: #f1f5f9; color: #0f172a; }
body.theme-light .conv-name { color: #0f172a; }
body.theme-light .conv-last-msg { color: #64748b; }
body.theme-light .conv-time { color: #94a3b8; }
body.theme-light .conv-item:hover { background: #f8fafc; }
body.theme-light .conv-item.active { background: #fffbeb; border-left-color: var(--amarillo); }
body.theme-light .user-name { color: #0f172a; }
body.theme-light .user-status { color: #64748b; }
body.theme-light .user-item:hover { background: #f8fafc; }
body.theme-light .chat-panel {
  background: #efeae2;
  background-image:
    radial-gradient(circle at 15% 25%, rgba(0,0,0,.03) 0%, transparent 50%),
    radial-gradient(circle at 85% 75%, rgba(0,0,0,.02) 0%, transparent 50%);
}
body.theme-light .chat-header {
  background: #f0f2f5;
  border-bottom: 1px solid #e2e8f0;
}
body.theme-light .chat-header-name { color: #0f172a; }
body.theme-light .chat-header-status { color: #64748b; }
body.theme-light .chat-header-actions button { color: #64748b; }
body.theme-light .chat-header-actions button:hover { background: #e2e8f0; color: #0f172a; }

/* ======================================================
   IN-CHAT SEARCH BAR
   ====================================================== */
.chat-search-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--azul-claro);
  padding: .6rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  animation: slideDown .2s ease;
}
body.theme-light .chat-search-bar {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: rgba(255,255,255,.1);
  border-radius: var(--radius-full);
  padding: .4rem .9rem;
}
body.theme-light .chat-search-input-wrap {
  background: #ffffff;
  border: 1px solid #cbd5e1;
}
.chat-search-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--blanco);
  font-size: .88rem;
}
body.theme-light .chat-search-input-wrap input { color: #0f172a; }
.chat-search-input-wrap input::placeholder { color: rgba(255,255,255,.4); }
body.theme-light .chat-search-input-wrap input::placeholder { color: #94a3b8; }
.chat-search-count {
  font-size: .78rem;
  color: rgba(255,255,255,.6);
  white-space: nowrap;
}
body.theme-light .chat-search-count { color: #64748b; }
.chat-search-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  padding: .3rem;
  border-radius: 50%;
  transition: var(--transition);
}
body.theme-light .chat-search-close { color: #64748b; }
.chat-search-close:hover { color: #ef4444; background: rgba(255,255,255,.1); }
.msg-highlight {
  background: #fef08a !important;
  color: #854d0e !important;
  padding: 1px 3px;
  border-radius: 3px;
  font-weight: bold;
}

/* ======================================================
   EMOJI PICKER
   ====================================================== */
.emoji-picker-container {
  position: absolute;
  bottom: 72px;
  left: 20px;
  width: 320px;
  max-width: calc(100vw - 40px);
  background: var(--blanco);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gris-200);
  z-index: 500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp .2s ease;
}
.emoji-picker-header {
  display: flex;
  background: var(--gris-100);
  border-bottom: 1px solid var(--gris-200);
  overflow-x: auto;
  padding: .3rem;
  gap: .2rem;
}
.emoji-tab-btn {
  background: transparent;
  border: none;
  padding: .4rem .6rem;
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.emoji-tab-btn.active, .emoji-tab-btn:hover {
  background: var(--blanco);
  box-shadow: var(--shadow-sm);
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: .3rem;
  padding: .6rem;
  max-height: 200px;
  overflow-y: auto;
}
.emoji-item {
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: .3rem;
  border-radius: var(--radius-sm);
  transition: transform .15s ease;
  user-select: none;
}
.emoji-item:hover {
  background: var(--gris-100);
  transform: scale(1.25);
}

/* ======================================================
   VOICE RECORDER BAR
   ====================================================== */
.voice-recorder-bar {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: #fef2f2;
  border: 2px solid #f87171;
  border-radius: var(--radius-lg);
  padding: .5rem 1rem;
  flex: 1;
  animation: pulseRecording 1.5s infinite;
}
@keyframes pulseRecording {
  0%, 100% { border-color: #f87171; box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
  50% { border-color: #ef4444; box-shadow: 0 0 10px rgba(239, 68, 68, .25); }
}
.voice-rec-indicator {
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  animation: blink 1s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .2; }
}
.voice-rec-time {
  font-weight: 700;
  font-size: .92rem;
  color: #b91c1c;
  min-width: 45px;
}
.voice-rec-status {
  flex: 1;
  font-size: .85rem;
  color: #991b1b;
}
.btn-rec-cancel {
  background: transparent;
  border: none;
  color: #dc2626;
  cursor: pointer;
  padding: .4rem;
  border-radius: 50%;
  transition: var(--transition);
}
.btn-rec-cancel:hover {
  background: #fee2e2;
  transform: scale(1.1);
}
.btn-rec-send {
  background: #ef4444;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: .5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-rec-send:hover {
  background: #dc2626;
  transform: scale(1.08);
}

/* ======================================================
   AUDIO MESSAGE BUBBLE
   ====================================================== */
.msg-audio-wrap {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 210px;
  padding: .3rem 0;
}
.msg-audio-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(13, 27, 62, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--azul-marino);
}
.msg-wrapper.received .msg-audio-icon {
  background: rgba(255, 107, 43, .12);
  color: var(--naranja);
}
.msg-audio-player {
  flex: 1;
  height: 36px;
  outline: none;
}
.msg-audio-player::-webkit-media-controls-panel {
  background-color: transparent;
}

/* ======================================================
   DELETE MESSAGE BUTTON & HOVER MENU
   ====================================================== */
.msg-bubble-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.msg-wrapper.sent .msg-bubble-wrap {
  flex-direction: row-reverse;
}
.msg-delete-btn {
  opacity: 0;
  pointer-events: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: .35rem;
  color: var(--gris-500);
  border-radius: 50%;
  transition: var(--transition);
  margin: 0 .3rem;
}
.msg-wrapper.sent:hover .msg-delete-btn {
  opacity: 1;
  pointer-events: auto;
}
.msg-delete-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, .12);
}

/* ======================================================
   REACTIONS (Floating Bar & Badges)
   ====================================================== */
.msg-react-trigger {
  opacity: 0;
  pointer-events: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: .35rem;
  color: var(--gris-500);
  border-radius: 50%;
  transition: var(--transition);
  margin: 0 .2rem;
}
.msg-wrapper:hover .msg-react-trigger {
  opacity: 1;
  pointer-events: auto;
}
.msg-react-trigger:hover {
  color: var(--amarillo-dark);
  background: rgba(245, 197, 24, .18);
  transform: scale(1.15);
}

.reactions-bar {
  position: absolute;
  top: -38px;
  background: var(--blanco);
  border-radius: var(--radius-full);
  box-shadow: 0 4px 18px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .5rem;
  z-index: 50;
  animation: popIn .2s cubic-bezier(.175, .885, .32, 1.275);
  border: 1px solid var(--gris-200);
}
.msg-wrapper.sent .reactions-bar { right: 0; }
.msg-wrapper.received .reactions-bar { left: 0; }

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.reaction-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: .2rem .35rem;
  border-radius: 50%;
  transition: transform .15s ease, background .15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reaction-btn:hover {
  transform: scale(1.35) translateY(-2px);
  background: var(--gris-100);
}

.msg-reactions-badge {
  position: absolute;
  bottom: -10px;
  background: var(--blanco);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  border: 1px solid var(--gris-200);
  font-size: .75rem;
  cursor: pointer;
  user-select: none;
  z-index: 5;
  transition: var(--transition);
}
.msg-reactions-badge:hover {
  transform: scale(1.08);
}
.msg-wrapper.sent .msg-reactions-badge { right: 8px; }
.msg-wrapper.received .msg-reactions-badge { left: 8px; }

/* ======================================================
   DOCUMENT ATTACHMENT CARD
   ====================================================== */
.msg-doc-card {
  display: flex;
  align-items: center;
  gap: .8rem;
  background: rgba(0,0,0,.04);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem;
  min-width: 220px;
  max-width: 320px;
  border: 1px solid rgba(0,0,0,.06);
  transition: var(--transition);
}
.msg-wrapper.sent .msg-doc-card {
  background: rgba(13, 27, 62, .08);
  border-color: rgba(13, 27, 62, .12);
}
.msg-doc-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: #ef4444;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .65rem;
  flex-shrink: 0;
  letter-spacing: .5px;
}
.msg-doc-icon.pdf { background: #dc2626; }
.msg-doc-icon.doc, .msg-doc-icon.docx { background: #2563eb; }
.msg-doc-icon.xls, .msg-doc-icon.xlsx { background: #16a34a; }
.msg-doc-icon.zip, .msg-doc-icon.rar { background: #f59e0b; }
.msg-doc-icon.txt { background: #64748b; }

.msg-doc-info {
  flex: 1;
  min-width: 0;
}
.msg-doc-name {
  font-weight: 600;
  font-size: .85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}
.msg-doc-meta {
  font-size: .72rem;
  opacity: .7;
  margin-top: 2px;
}
.msg-doc-download {
  color: inherit;
  opacity: .7;
  padding: .35rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.msg-doc-download:hover {
  opacity: 1;
  transform: translateY(1px);
  background: rgba(0,0,0,.08);
}

/* Attachment Dropdown Menu */
.attach-menu {
  position: absolute;
  bottom: 60px;
  left: 50px;
  background: var(--blanco);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gris-200);
  padding: .5rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  z-index: 500;
  animation: slideUp .2s ease;
}
.attach-menu-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .9rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  color: var(--negro);
  transition: var(--transition);
  width: 100%;
  text-align: left;
}
.attach-menu-item:hover {
  background: var(--gris-100);
  color: var(--naranja);
}
.attach-menu-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.attach-menu-icon.image { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.attach-menu-icon.doc   { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }