/* ============================================
   Chat Module — Estilos
   ============================================ */

/* --- Lightbox overlay (homevf) --- */
.chat-lightbox-root {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1060;
  display: flex; align-items: center; justify-content: center;
}
.chat-lightbox-root .js-chat-lightbox-content {
  width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto;
  margin: 0 auto;
}
@media (max-width: 480px) {
  .chat-lightbox-root .js-chat-lightbox-content { max-width: 100%; }
}
.chat-lightbox-root.d-none { display: none !important; }

/* --- Lightbox overlay (viewKines) --- */
.chat-lightbox-root {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1060;
  display: flex; align-items: center; justify-content: center;
}
.chat-lightbox-root .js-chat-lightbox-content {
  width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto;
  margin: 0 auto;
}
@media (max-width: 480px) {
  .chat-lightbox-root .js-chat-lightbox-content { max-width: 100%; }
}

/* --- Temas de chat (DARK / WHITE / PINK) --- */
.chat-theme-dark {
  --chat-bg: #1C1C1E;
  --chat-bubble-own-bg: #005C4B;
  --chat-bubble-own-text: #FFFFFF;
  --chat-bubble-other-bg: #2C2C2E;
  --chat-bubble-other-text: #FFFFFF;
  --chat-header-bg: #075E54;
  --chat-header-text: #FFFFFF;
  --chat-input-bg: #2C2C2E;
  --chat-input-text: #FFFFFF;
  --chat-date-sep-bg: rgba(255,255,255,0.1);
  --chat-date-sep-text: #aebac1;
  --chat-inbox-bg: #111b21;
  --chat-inbox-hover: #202c33;
  --chat-inbox-text: #e9edef;
  --chat-msg-area-bg: #0b141a;
  --chat-inputbar-bg: #1f2c33;
  --chat-context-menu-bg: #1f2c33;
  --chat-context-menu-border: #374045;
  --chat-bubble-tail-own: #005C4B;
  --chat-bubble-tail-other: #2C2C2E;
  --chat-accent: #00a884;
  --chat-thread-hover: #2a3942;
}

.chat-theme-white {
  --chat-bg: #F5F5F5;
  --chat-bubble-own-bg: #DCF8C6;
  --chat-bubble-own-text: #111111;
  --chat-bubble-other-bg: #FFFFFF;
  --chat-bubble-other-text: #111111;
  --chat-header-bg: #FFFFFF;
  --chat-header-text: #1C1C1E;
  --chat-input-bg: #FFFFFF;
  --chat-input-text: #1C1C1E;
  --chat-date-sep-bg: rgba(0,0,0,0.08);
  --chat-date-sep-text: #54656f;
  --chat-inbox-bg: #FFFFFF;
  --chat-inbox-hover: #f0f2f5;
  --chat-inbox-text: #1C1C1E;
  --chat-msg-area-bg: #e5ddd5;
  --chat-inputbar-bg: #f0f2f5;
  --chat-context-menu-bg: #FFFFFF;
  --chat-context-menu-border: #e0e0e0;
  --chat-bubble-tail-own: #DCF8C6;
  --chat-bubble-tail-other: #FFFFFF;
  --chat-accent: #008069;
  --chat-thread-hover: #f0f2f5;
}

.chat-theme-pink {
  --chat-bg: #FFF0F5;
  --chat-bubble-own-bg: #F48FB1;
  --chat-bubble-own-text: #FFFFFF;
  --chat-bubble-other-bg: #FCE4EC;
  --chat-bubble-other-text: #880E4F;
  --chat-header-bg: #F06292;
  --chat-header-text: #FFFFFF;
  --chat-input-bg: #FCE4EC;
  --chat-input-text: #880E4F;
  --chat-date-sep-bg: rgba(240,98,146,0.15);
  --chat-date-sep-text: #880E4F;
  --chat-inbox-bg: #FFF0F5;
  --chat-inbox-hover: #FCE4EC;
  --chat-inbox-text: #880E4F;
  --chat-msg-area-bg: #FFF0F5;
  --chat-inputbar-bg: #FCE4EC;
  --chat-context-menu-bg: #FFFFFF;
  --chat-context-menu-border: #F48FB1;
  --chat-bubble-tail-own: #F48FB1;
  --chat-bubble-tail-other: #FCE4EC;
  --chat-accent: #F06292;
  --chat-thread-hover: #FCE4EC;
}

/* Aplicar variables a los elementos del chat */
.wa-lightbox { background: var(--chat-bg); }
.wa-header { background: var(--chat-header-bg); color: var(--chat-header-text); }
.text-themed { color: var(--chat-header-text) !important; }
.wa-back-bar { background: var(--chat-header-bg); }
.wa-back-bar:hover { background: color-mix(in srgb, var(--chat-header-bg) 85%, black); }
.wa-inbox { background: var(--chat-inbox-bg); }
.wa-inbox .wa-thread-link:hover,
.wa-inbox .wa-thread-link.active { background: var(--chat-thread-hover); }
.wa-inbox .fw-medium { color: var(--chat-inbox-text) !important; }
.wa-inbox .wa-thread-link.active .fw-medium { color: var(--chat-accent) !important; font-weight: 700 !important; }
.wa-group-header { background: transparent; border-color: var(--chat-thread-hover); }
.wa-group-header:hover { background: var(--chat-thread-hover) !important; }
.wa-group-header .fst-italic,
.wa-group-header .small,
.wa-group-header .fw-semibold { color: var(--chat-inbox-text) !important; }
.wa-conversation-panel { background: var(--chat-msg-area-bg); }
.wa-context-menu { background: var(--chat-context-menu-bg); }
.wa-context-menu .dropdown-divider { border-color: var(--chat-context-menu-border); }

/* Selector de tema: botón paleta */
.js-theme-btn { background: transparent; border: none; color: inherit; padding: 0; }
.js-theme-btn:hover { opacity: 0.8; }
.theme-dropdown { position: absolute; top: 100%; right: 0; z-index: 1050; min-width: 140px; padding: 4px 0; border-radius: 8px; display: none; }
.theme-dropdown.show { display: block; }
.theme-option { display: flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px; }
.theme-option:hover { background: rgba(0,0,0,0.08); }
.theme-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid transparent; flex-shrink: 0; }
.theme-dot.dark { background: #1C1C1E; border-color: #555; }
.theme-dot.white { background: #F5F5F5; border-color: #ccc; }
.theme-dot.pink { background: #F48FB1; border-color: #ccc; }
.theme-option.active .theme-dot { border-color: var(--chat-accent, #00a884); }

/* --- Floating chat icon (chat-floating-icon.blade.php) --- */
.floating-chat-icon {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d41459, #911a6c);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    box-shadow: 0 4px 15px rgba(212, 20, 89, 0.4);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.floating-chat-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(212, 20, 89, 0.65);
    color: #fff;
}
.floating-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    background: #dc3545;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    border: 2px solid #1a1a2e;
    line-height: 1;
}
.floating-chat-badge.pulse-in {
    animation: chatBadgePopIn 0.4s ease;
}
@keyframes chatBadgePopIn {
    0%   { transform: scale(0.3); }
    55%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}
.floating-chat-icon.notify {
    animation: chatIconAlarm 0.8s ease;
}
@keyframes chatIconAlarm {
    0%   { transform: scale(1);    box-shadow: 0 4px 15px rgba(212,20,89,0.4); }
    8%   { transform: scale(1.22); box-shadow: 0 0 35px rgba(220,53,69,1); }
    16%  { transform: scale(0.92); box-shadow: 0 0 5px rgba(220,53,69,0.3); }
    24%  { transform: scale(1.14); box-shadow: 0 0 35px rgba(220,53,69,1); }
    32%  { transform: scale(0.96); box-shadow: 0 0 5px rgba(220,53,69,0.3); }
    40%  { transform: scale(1.07); box-shadow: 0 0 28px rgba(220,53,69,0.8); }
    52%  { transform: scale(0.98); box-shadow: 0 0 10px rgba(220,53,69,0.4); }
    64%  { transform: scale(1.03); box-shadow: 0 0 20px rgba(220,53,69,0.6); }
    100% { transform: scale(1);    box-shadow: 0 4px 15px rgba(212,20,89,0.4); }
}

/* Inbox lightbox */
.chat-inbox-lightbox-root {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-inbox-lightbox-root.d-none { display: none !important; }
.chat-inbox-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.chat-inbox-lightbox-card {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: 92vw;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    overflow-x: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
    z-index: 1;
}
[data-bs-theme="dark"] .chat-inbox-lightbox-card {
    background: #1e1e2f;
    color: #e0e0e0;
}
@media (max-width: 576px) {
    .floating-chat-icon {
        bottom: 80px;
        right: 12px;
        width: 48px;
        height: 48px;
        font-size: 22px;
    }
    .floating-chat-badge {
        min-width: 20px;
        height: 20px;
        font-size: 10px;
        top: -3px;
        right: -3px;
    }
    .chat-inbox-lightbox-card {
        width: 96vw;
        max-height: 90vh;
        border-radius: 8px;
    }
}
