html { font-size: 15px; position: relative; min-height: 100%; }
body { background: #f4f6f8; }

/* Barra superior */
.navbar.bg-success { background: linear-gradient(90deg, #084c3c 0%, #0b6b53 100%) !important; box-shadow: 0 2px 10px rgba(8, 76, 60, .25); }
.navbar .nav-link { margin: 0 .1rem; padding: .4rem .95rem; border-radius: 999px; font-weight: 500; transition: background .15s, color .15s; }
.navbar .nav-link:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.navbar .nav-link.active { background: rgba(255, 255, 255, .18); color: #fff; }

/* Indicador de conexión en vivo */
.live-dot { display: inline-flex; align-items: center; gap: .4rem; margin: 0 .9rem; font-size: .8rem; color: rgba(255, 255, 255, .75); white-space: nowrap; }
.live-dot i { width: 9px; height: 9px; border-radius: 50%; background: #adb5bd; }
.live-dot[data-state="on"] i { background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); animation: live-pulse 2s infinite; }
.live-dot[data-state="wait"] i { background: #fbbf24; }
.live-dot[data-state="off"] i { background: #f87171; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }

/* Aviso de que no hay base de datos */
.memory-banner { padding: .55rem 1rem; background: #fef3c7; color: #92400e; border-bottom: 1px solid #fcd34d; font-size: .86rem; text-align: center; }
.memory-banner code { color: inherit; background: rgba(146, 64, 14, .1); padding: .05rem .35rem; border-radius: .3rem; }

/* Campana de notificaciones */
.bell-wrap { position: relative; display: flex; align-items: center; }
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: rgba(255, 255, 255, .85); transition: background .15s, color .15s; }
.bell:hover, .bell[aria-expanded="true"] { background: rgba(255, 255, 255, .15); color: #fff; }
.bell.ring svg { animation: bell-ring .9s ease-in-out; transform-origin: 50% 10%; }
.bell-badge { position: absolute; top: 1px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #ef4444; color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; border: 2px solid #0b6b53; box-sizing: content-box; }
.bell-badge[hidden] { display: none; }
.bell-menu { width: min(360px, calc(100vw - 24px)); padding: 0; border: 1px solid #e5e7eb; border-radius: 1rem; box-shadow: 0 16px 40px rgba(15, 31, 42, .18); overflow: hidden; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid #eef1f4; }
.bell-head span { padding: .1rem .55rem; border-radius: 999px; background: #fee2e2; color: #b91c1c; font-size: .72rem; font-weight: 700; }
.bell-head span:empty { display: none; }
.bell-list { max-height: 360px; overflow-y: auto; }
.bell-tools { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem 1rem; background: #fafcfb; border-bottom: 1px solid #eef1f4; }
.bell-tools[hidden] { display: none; }
.bell-tools button { padding: .15rem 0; border: 0; background: none; color: #0b6b53; font-size: .78rem; font-weight: 600; }
.bell-tools button:last-child { color: #6b7280; }
.bell-tools button:hover { text-decoration: underline; }
.bell-item { position: relative; display: flex; align-items: flex-start; border-bottom: 1px solid #f3f4f6; }
.bell-item:hover { background: #f4faf7; }
.bell-main { flex: 1; min-width: 0; display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .4rem .7rem 1rem; color: #1f2937; text-decoration: none; }
.bell-main:hover { color: #1f2937; }
.bell-item.unread .bell-main::before { content: ""; position: absolute; left: 5px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: #2563eb; }
.bell-item.read .bell-main { opacity: .6; }
.bell-item.read .bell-text b { font-weight: 500; }
.bell-actions { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: .35rem .5rem .35rem 0; opacity: 0; transition: opacity .12s; }
.bell-item:hover .bell-actions, .bell-actions:focus-within { opacity: 1; }
.bell-actions button { width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; color: #6b7280; font-size: .8rem; line-height: 1; }
.bell-actions button:hover { background: #e5e7eb; color: #111827; }
.bell-actions button.del:hover { background: #fee2e2; color: #b91c1c; }
@media (hover: none) { .bell-actions { opacity: 1; } }
.bell-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #e6f4ee; font-size: 1rem; }
.bell-item.chat .bell-icon { background: #fef3c7; }
.bell-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bell-text b { font-size: .88rem; }
.bell-text span { font-size: .82rem; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bell-ago { flex: none; font-size: .72rem; color: #9ca3af; }
.bell-empty { margin: 0; padding: 1.6rem 1rem; text-align: center; color: #6b7280; font-size: .88rem; }
.bell-foot { display: flex; justify-content: space-between; gap: .5rem; padding: .65rem 1rem; background: #fafcfb; border-top: 1px solid #eef1f4; font-size: .82rem; }
.bell-foot a { color: #0b6b53; font-weight: 600; text-decoration: none; }
.bell-foot a:hover { text-decoration: underline; }
@keyframes bell-ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-6deg); } 75% { transform: rotate(3deg); } }
@media (max-width: 767.98px) { .bell-wrap { margin: .4rem 0; } .bell-menu { position: absolute; } }
@media (prefers-reduced-motion: reduce) { .bell.ring svg { animation: none; } }

/* Avisos emergentes y destello de lo que llega en vivo */
#live-toasts { position: fixed; top: 70px; right: 16px; z-index: 1080; display: flex; flex-direction: column; gap: .5rem; width: min(340px, calc(100vw - 32px)); }
.live-toast { display: flex; flex-direction: column; gap: .15rem; padding: .7rem .9rem; background: #fff; color: #1f2937; text-decoration: none; border-left: 4px solid #0b6b53; border-radius: .6rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); animation: live-in .25s ease-out; }
.live-toast span { font-size: .85rem; color: #6b7280; }
@keyframes live-in { from { opacity: 0; transform: translateY(-8px); } }
.live-new { animation: live-flash 2.4s ease-out; }
@keyframes live-flash { 0%, 30% { box-shadow: 0 0 0 3px rgba(11, 107, 83, .55); } 100% { box-shadow: 0 0 0 3px rgba(11, 107, 83, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot i, .live-toast, .live-new { animation: none !important; } }

.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #adb5bd; flex: none; }
.status-dot.ok { background: #198754; }
.status-dot.wait { background: #ffc107; }
.status-dot.bad { background: #dc3545; }

.qr-box { width: 264px; height: 264px; padding: 12px; background: #fff; border: 1px solid #dee2e6; border-radius: .5rem; }
.qr-box img { width: 100%; height: 100%; image-rendering: pixelated; }

.card.stat { color: inherit; transition: box-shadow .15s; }
.card.stat:hover { box-shadow: 0 .25rem .75rem rgba(0,0,0,.08) !important; }

.chat { max-height: 60vh; overflow-y: auto; background: #efeae2; border-radius: .5rem; padding: 1rem; }
.bubble { max-width: 80%; padding: .5rem .75rem; border-radius: .5rem; margin-bottom: .5rem; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.bubble.in { background: #fff; margin-right: auto; }
.bubble.out { background: #d9fdd3; margin-left: auto; }
.bubble.agent { background: #cfe2ff; margin-left: auto; }
.bubble .meta { font-size: .75rem; color: #6c757d; margin-top: .25rem; text-align: right; }

/* Fotos, videos, audios y documentos en el chat y en las solicitudes (de master, con los colores de este panel) */
/* Anchos en px/vw (no en %): con % el globo se ensancharía al tamaño original de la foto. */
.media-img { display: block; max-width: min(320px, 65vw); max-height: 360px; border-radius: 8px; object-fit: contain; background: #f1f3f5; }
.media-img.media-sticker { max-width: 160px; background: transparent; }
.media-video { display: block; max-width: min(360px, 65vw); max-height: 360px; border-radius: 8px; background: #000; }
.media-audio { display: block; width: min(300px, 70vw); }
.media-video-thumb { position: relative; display: inline-block; line-height: 0; border-radius: 8px; overflow: hidden; cursor: pointer; }
.media-video-thumb .media-video { pointer-events: none; }
.media-play { position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%;
  background: rgba(15, 23, 42, .62); color: #fff; font-size: 1.15rem; line-height: 1; padding-left: 4px; transition: transform .15s, background .15s; }
.media-video-thumb:hover .media-play { background: rgba(11, 107, 83, .9); transform: scale(1.08); }
a[data-lightbox] { cursor: zoom-in; }
a[data-lightbox="video"] { cursor: pointer; }

/* Visor de fotos y videos */
html.lb-open { overflow: hidden; }
.lb { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(8, 12, 20, .92);
  animation: lb-in .15s ease-out; }
.lb[hidden] { display: none; }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.lb-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem;
  background: linear-gradient(rgba(0, 0, 0, .55), transparent); color: #fff; z-index: 1; }
.lb-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; opacity: .9; }
.lb-btn, .lb-nav { border: 0; background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; text-decoration: none; display: grid; place-items: center; transition: background .15s; }
.lb-btn { width: 38px; height: 38px; border-radius: 50%; font-size: 1.05rem; }
.lb-btn:hover, .lb-nav:hover { background: rgba(255, 255, 255, .26); color: #fff; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 64px; border-radius: 12px; font-size: 2.2rem; line-height: 1; z-index: 1; }
.lb-prev { left: .75rem; } .lb-next { right: .75rem; }
.lb.single .lb-nav { display: none; }
.lb-stage { position: absolute; inset: 3.5rem 4rem 2.75rem; display: flex; align-items: center; justify-content: center; }
.lb-media { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #000; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
img.lb-media { background: transparent; }
.lb-count { position: absolute; bottom: .9rem; left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, .75); font-size: .8rem; }
@media (max-width: 640px) {
  .lb-stage { inset: 3.5rem .5rem 2.75rem; }
  .lb-nav { width: 38px; height: 54px; font-size: 1.8rem; }
}
.media-actions { font-size: .72rem; color: #64748b; margin-top: .25rem; }
.media-actions a { color: inherit; }
.media-status { font-size: .85rem; color: #64748b; }
.media-doc { display: flex; align-items: center; gap: .65rem; min-width: min(220px, 60vw); max-width: min(340px, 65vw); padding: .55rem .7rem; border-radius: 10px;
  background: rgba(15, 23, 42, .045); border: 1px solid rgba(15, 23, 42, .06); color: inherit; text-decoration: none; }
.media-doc:hover { background: rgba(15, 23, 42, .08); }
.media-doc-icon { font-size: 1.6rem; line-height: 1; }
.media-doc-name { font-weight: 600; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-doc-action { font-size: 1.1rem; color: #0b6b53; }
.reply-form.dragging { outline: 2px dashed #0b6b53; outline-offset: 4px; border-radius: 12px; }
.media-doc-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.attachment-info { font-size: .85rem; margin-bottom: .45rem; padding: .3rem .7rem; background: #e6f4ee; color: #084c3c;
  border-radius: 999px; display: inline-flex; align-items: center; }

/* Reloj del negocio en la barra: hora en la zona elegida en Configuración y si está abierto */
.biz-clock { display: inline-flex; align-items: center; gap: .4rem; margin: 0 .9rem 0 0; font-size: .8rem; color: rgba(255, 255, 255, .8); text-decoration: none; white-space: nowrap; }
.biz-clock:hover { color: #fff; }
.biz-clock i { width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; }
.biz-clock i.open { background: #4ade80; }
.biz-clock b { font-variant-numeric: tabular-nums; color: #fff; }

/* Mensajes sin leer: número junto a "Conversaciones" y sonido de la campana */
.nav-unread { display: inline-block; margin-left: .4rem; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #ef4444; color: #fff;
  font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px; }
.nav-unread[hidden] { display: none; }
.bell-head strong { margin-right: .5rem; }
.bell-sound { margin-left: auto; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; font-size: 1rem; line-height: 1; }
.bell-sound:hover { background: #eef1f4; }
.bell-desktop { display: block; width: 100%; padding: .5rem 1rem; border: 0; border-bottom: 1px solid #eef1f4; background: #eff6ff; color: #1d4ed8; font-size: .8rem; font-weight: 600; text-align: left; }
.bell-desktop:hover { background: #dbeafe; }
.bell-desktop[hidden] { display: none; }
