@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@700&display=swap');

/* =============================================
   SPLASH / POST-LOGIN TRANSITION SCREEN
   ============================================= */

/* ---- Keyframes ---- */
@keyframes splash-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes splash-fade-out {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(1.04); }
}
@keyframes splash-float-1 {
    0%, 100% { transform: translateY(0px) rotate(-6deg); }
    50%       { transform: translateY(-14px) rotate(-6deg); }
}
@keyframes splash-float-2 {
    0%, 100% { transform: translateY(0px) rotate(5deg); }
    50%       { transform: translateY(-18px) rotate(5deg); }
}
@keyframes splash-float-3 {
    0%, 100% { transform: translateY(0px) rotate(-3deg); }
    50%       { transform: translateY(-10px) rotate(-3deg); }
}
@keyframes splash-float-4 {
    0%, 100% { transform: translateY(0px) rotate(8deg); }
    50%       { transform: translateY(-22px) rotate(8deg); }
}
@keyframes splash-card-in {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes splash-logo-pulse {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(59,130,246,0.6)); transform: scale(1); }
    50%       { filter: drop-shadow(0 0 30px rgba(59,130,246,0.9)); transform: scale(1.08); }
}
@keyframes splash-content-rise {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes splash-bar-fill {
    from { width: 0%; }
    to   { width: 100%; }
}
@keyframes splash-orb-pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50%       { transform: scale(1.15); opacity: 0.7; }
}
@keyframes splash-sparkle-spin {
    from { transform: rotate(0deg) scale(1); opacity: 0.7; }
    to   { transform: rotate(360deg) scale(1.2); opacity: 1; }
}
@keyframes bubble-bar-shimmer {
    0%   { opacity: 0.4; }
    50%  { opacity: 0.8; }
    100% { opacity: 0.4; }
}

/* ---- Root element ---- */
#splash-screen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;                 /* shown via JS after login */
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: radial-gradient(ellipse at 30% 40%, #0d1b3e 0%, #080c1e 60%, #0a0614 100%);
    animation: splash-fade-in 0.45s ease forwards;
}

#splash-screen.splash-hiding {
    animation: splash-fade-out 0.55s ease forwards;
    pointer-events: none;
}

/* ---- Glow Orbs ---- */
.splash-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: splash-orb-pulse 4s ease-in-out infinite;
}
.splash-orb--left {
    width: 420px;
    height: 420px;
    background: radial-gradient(circle, rgba(30, 64, 175, 0.55) 0%, transparent 70%);
    top: -60px;
    left: -80px;
    animation-delay: 0s;
}
.splash-orb--right {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(109, 40, 217, 0.4) 0%, transparent 70%);
    bottom: -80px;
    right: -100px;
    animation-delay: 1.5s;
}

/* ---- Floating Chat Bubbles ---- */
.splash-bubble {
    position: absolute;
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    opacity: 0;
    animation:
        splash-card-in 0.6s ease forwards,
        splash-float-1 5s ease-in-out infinite;
}
.splash-bubble::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: inherit;
    border-right: 1px solid rgba(255,255,255,0.12);
    border-bottom: 1px solid rgba(255,255,255,0.12);
    border-radius: 0 0 3px 0;
}
/* Bubble 1 - top left */
.splash-bubble--1 {
    top: 9%;
    left: 6%;
    animation-delay: 0.3s, 0s;
    animation-fill-mode: both;
    animation-name: splash-card-in, splash-float-1;
    animation-duration: 0.6s, 5s;
    transform: rotate(-6deg);
}
.splash-bubble--1::after { bottom: -6px; right: 18px; transform: rotate(45deg); }

/* Bubble 2 - right side center */
.splash-bubble--2 {
    top: 28%;
    right: 7%;
    animation-delay: 0.5s, 0.3s;
    animation-fill-mode: both;
    animation-name: splash-card-in, splash-float-2;
    animation-duration: 0.6s, 6s;
    transform: rotate(5deg);
}
.splash-bubble--2::after { bottom: -6px; left: 22px; transform: rotate(45deg); }

/* Bubble 3 - bottom left */
.splash-bubble--3 {
    bottom: 16%;
    left: 5%;
    animation-delay: 0.7s, 0.6s;
    animation-fill-mode: both;
    animation-name: splash-card-in, splash-float-3;
    animation-duration: 0.6s, 4.5s;
    transform: rotate(-3deg);
}
.splash-bubble--3::after { top: -6px; right: 20px; transform: rotate(225deg); }

/* Bubble 4 - bottom right */
.splash-bubble--4 {
    bottom: 18%;
    right: 6%;
    animation-delay: 0.9s, 0.9s;
    animation-fill-mode: both;
    animation-name: splash-card-in, splash-float-4;
    animation-duration: 0.6s, 5.5s;
    transform: rotate(8deg);
}
.splash-bubble--4::after { top: -6px; left: 18px; transform: rotate(225deg); }

/* ---- Bubble Bars (simulated message lines) ---- */
.bubble-bar {
    display: block;
    height: 8px;
    background: rgba(255,255,255,0.25);
    border-radius: 100px;
    width: 110px;
    animation: bubble-bar-shimmer 2.5s ease-in-out infinite;
}
.bubble-bar--short  { width: 68px; animation-delay: 0.4s; }
.bubble-bar--medium { width: 90px; animation-delay: 0.2s; }
.bubble-bar--long   { width: 130px; }

.splash-check {
    font-size: 0.7rem;
    color: #3b82f6;
    text-align: right;
    font-weight: 700;
}
.splash-check--orange { color: #fb923c; font-size: 0.75rem; }

/* ---- Floating Glass Cards (like notification panels) ---- */
.splash-card {
    position: absolute;
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    opacity: 0;
    animation: splash-card-in 0.7s ease forwards;
}
.splash-card--top {
    top: 5%;
    left: 30%;
    width: 220px;
    height: 70px;
    animation-delay: 0.4s;
}
.splash-card--bottom {
    bottom: 6%;
    left: 28%;
    width: 200px;
    height: 65px;
    animation-delay: 0.8s;
}
/* Bell-like dot on top cards */
.splash-card--top::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    top: -4px;
    right: 24px;
    box-shadow: 0 0 8px rgba(239,68,68,0.7);
}
/* Small icon on bottom card */
.splash-card--bottom::before {
    content: '🔔';
    font-size: 0.7rem;
    position: absolute;
    bottom: 10px;
    right: 14px;
    opacity: 0.6;
}

/* ---- Central Content ---- */
.splash-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0;
    opacity: 0;
    animation: splash-content-rise 0.7s ease 0.5s forwards;
}

/* Logo */
.splash-logo-wrap {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.splash-logo-icon {
    width: 160px;
    height: auto;
    display: block;
    animation: splash-logo-pulse 2.5s ease-in-out infinite;
}

/* Title */
.splash-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2.4rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.5px;
    line-height: 1.1;
    margin-bottom: 14px;
    text-shadow: 0 0 40px rgba(59,130,246,0.3);
}

/* Subtitle */
.splash-subtitle {
    font-size: 1rem;
    color: rgba(255,255,255,0.55);
    max-width: 320px;
    line-height: 1.6;
    margin-bottom: 40px;
}

/* Loading bar */
.splash-loader {
    width: 240px;
    height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 100px;
    overflow: hidden;
}
.splash-loader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    border-radius: 100px;
    animation: splash-bar-fill 4.5s cubic-bezier(0.4, 0, 0.2, 1) 0.6s forwards;
    box-shadow: 0 0 12px rgba(139,92,246,0.6);
}

/* ---- Corner Sparkle ---- */
.splash-sparkle {
    position: absolute;
    bottom: 40px;
    right: 60px;
    font-size: 2rem;
    color: rgba(255,255,255,0.5);
    animation: splash-sparkle-spin 6s linear infinite;
}


.d-none {
    display: none !important;
}
:root {
    --bg-main: #f8fafc;
    --bg-nav: #ffffff;
    --bg-panel: #ffffff;
    --bg-panel-hover: #f1f5f9;
    --bg-message-in: #ffffff;
    --bg-message-out: #0ea5e9;

    --text-pure: #0f172a;
    --text-light: #334155;
    --text-muted: #64748b;
    --text-tiny: #94a3b8;

    --border-color: #e2e8f0;

    --accent-blue: #0ea5e9;
    --accent-red: #ef4444;

    --font-primary: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-main);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* 4-Column Layout */
.app-container {
    width: 100%;
    height: 100vh;
    display: grid;
    grid-template-columns: 260px 300px 1fr 280px;
    background-color: var(--bg-main);
    transition: grid-template-columns 0.3s ease;
}

.app-container.sidebar-collapsed-grid {
    grid-template-columns: 70px 300px 1fr 280px;
}

/* ====== COLUMNA 1: NAVEGACIÓN PRINCIPAL ====== */
.sidebar-nav-main {
    background-color: var(--bg-nav);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.nav-brand {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.brand-name {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 1px;
    white-space: nowrap;
    color: var(--text-pure);
}

#sidebar {
    transition: width 0.3s ease;
}

#sidebar.sidebar-collapsed {
    width: 70px;
}

#sidebar.sidebar-collapsed .nav-text {
    display: none;
}

#sidebar.sidebar-collapsed .nav-section-title,
#sidebar.sidebar-collapsed .brand-name,
#sidebar.sidebar-collapsed .sidebar-title {
    display: none;
}

#sidebar.sidebar-collapsed .nav-item {
    justify-content: center;
}

.brand-icon {
    color: var(--text-muted);
    cursor: pointer;
}

.nav-section-title {
    padding: 24px 20px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-pure);
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item:hover {
    color: var(--text-light);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-pure);
    border-left: 3px solid var(--accent-blue);
}

.nav-icon {
    width: 24px;
    height: 24px;
    opacity: 0.8;
    transition: color 0.3s ease, transform 0.3s ease;
}

.nav-soporte:hover .nav-icon, .nav-soporte:hover .nav-text { color: #ff4d4d; }
.nav-ventas:hover .nav-icon, .nav-ventas:hover .nav-text { color: #00e676; }
.nav-voucher:hover .nav-icon, .nav-voucher:hover .nav-text { color: #ff9100; }

/* ---- Label count badges ---- */
.nav-badge {
    display: none;           /* hidden when count is 0 */
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
    background: #fb923c;
    color: #fff;
    margin-left: auto;
    flex-shrink: 0;
    line-height: 1;
}

.nav-badge--red {
    background: #ef4444;
}

.nav-badge.visible {
    display: inline-flex;
}

/* In collapsed mode, badges sit below the icon centred */
#sidebar.sidebar-collapsed .nav-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 14px;
    height: 14px;
    font-size: 0.55rem;
    padding: 0 3px;
    margin-left: 0;
}

#sidebar.sidebar-collapsed .nav-item {
    position: relative;
}


/* ====== PROFILE BUTTON (sidebar bottom) ====== */
.nav-profile-wrap {
    margin-top: auto;
    padding: 12px 8px;
    border-top: 1px solid var(--border-color);
}

.nav-profile-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: none;
    border: none;
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    min-width: 0;
}

.nav-profile-btn:hover {
    background: var(--bg-panel-hover);
}

.nav-profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.nav-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.nav-profile-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
}

.nav-profile-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-pure);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-profile-phone {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hide text labels when collapsed */
#sidebar.sidebar-collapsed .nav-profile-info {
    display: none;
}

#sidebar.sidebar-collapsed .nav-profile-btn {
    justify-content: center;
    padding: 8px 6px;
}

/* ====== PROFILE MODAL ====== */
@keyframes profile-modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.profile-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
}

.profile-modal-overlay.open {
    display: flex;
}

.profile-modal-card {
    position: relative;
    background: #ffffff;
    border-radius: 20px;
    padding: 40px 36px 32px;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(15,23,42,0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: profile-modal-in 0.3s ease forwards;
}

.profile-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.profile-modal-close:hover {
    color: var(--text-pure);
}

.profile-modal-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(37,99,235,0.25);
    margin-bottom: 4px;
}

.profile-modal-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-modal-name {
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-pure);
    text-align: center;
    margin: 0;
}

.profile-modal-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.profile-modal-meta svg {
    color: var(--accent-blue);
    flex-shrink: 0;
}

.profile-modal-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #10b981;
    background: #d1fae5;
    padding: 5px 12px;
    border-radius: 100px;
    margin-top: 4px;
}

.profile-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    flex-shrink: 0;
    animation: splash-orb-pulse 2s ease-in-out infinite;
}

/* ====== COLUMNA 2: LISTA DE CHATS ====== */
.sidebar-left {
    background-color: var(--bg-main);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;       /* Ocupa toda la altura de su celda en el grid */
    overflow: hidden;   /* Restringe el scroll al interior, no a la página */
}

.sidebar-title {
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.brand-header-area {
    padding: 20px 20px 10px;
    border-bottom: 1px solid var(--border-color);
}

.brand-name-center {
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem;
    color: var(--text-pure);
    margin-bottom: 15px;
}

.chat-search-input {
    width: 100%;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-pure);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 10px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

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

.chat-search-input:focus {
    border-color: var(--accent-blue);
}

.active-session-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #10b981;
    /* green */
    margin-right: 6px;
}

.chats-header-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.chats-actions svg {
    color: var(--text-muted);
    cursor: pointer;
}

.chat-list {
    flex: 1;
    min-height: 0;      /* Clave en flexbox: sin esto, el hijo no se encoge y el overflow no funciona */
    overflow-y: auto;
    overflow-x: hidden; /* Evita scroll horizontal si un nombre es muy largo */
}

.chat-list::-webkit-scrollbar {
    width: 4px;
}

.chat-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-list-item {
    display: flex;
    padding: 16px;
    margin: 8px 16px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: all 0.2s;
}

.chat-list-item:hover,
.chat-list-item.active {
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border-color: #cbd5e1;
    background-color: #ffffff;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #e0f2fe;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.95rem;
    margin-right: 12px;
    flex-shrink: 0;
    color: #0284c7;
}

.chat-list-info {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

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

.chat-list-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-pure);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-time {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.chat-list-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loading {
    padding: 20px;
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-muted);
}

/* ====== COLUMNA 3: CHAT AREA ====== */
.chat-area {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    height: 100vh;
    overflow: hidden;
}

.chat-header {
    height: 60px;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background-color: #ffffff;
}

.chat-title-info {
    font-size: 1.1rem;
    font-weight: 600;
    color: #0f172a;
}

.chat-header-date {
    display: none;
}

#messages-container,
.messages-list {
    flex: 1;
    overflow-y: auto;
    height: 0;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Scrollbar dark minimal */
.messages-list::-webkit-scrollbar {
    width: 6px;
}
.messages-list::-webkit-scrollbar-track {
    background: transparent;
}
.messages-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.message {
    max-width: 65%;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 2px;
}

.message-in {
    align-self: flex-start;
}

.message-out {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-bubble {
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.message-in .message-bubble {
    background-color: #ffffff;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.message-out .message-bubble {
    background-color: #5c7c9a;
    color: #ffffff;
    border: none;
    border-bottom-right-radius: 4px;
}

.message-meta {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.message-meta::after {
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
}

.message-in .message-meta::after {
    content: '';
    width: 14px;
    height: 14px;
    background: url('data:image/svg+xml;utf8,<svg fill="%2364748b" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C9.243 2 7 4.243 7 7s2.243 5 5 5 5-2.243 5-5-2.243-5-5-5zm0 8c-1.654 0-3-1.346-3-3s1.346-3 3-3 3 1.346 3 3-1.346 3-3 3zm9 11v-1c0-3.859-3.141-7-7-7H10c-3.859 0-7 3.141-7 7v1h2v-1c0-2.757 2.243-5 5-5h4c2.757 0 5 2.243 5 5v1h2z"/></svg>') no-repeat center;
    background-size: contain;
}

.message-out .message-meta::after {
    content: 'A';
    color: #1e293b;
}

/* Image Attachments */
.chat-message-image {
    max-width: 300px;
    max-height: 200px;
    width: auto;
    height: auto;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.chat-message-image:hover {
    transform: scale(1.02);
}

/* Lightbox Modal */
#lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#lightbox.show-lightbox {
    display: flex;
    opacity: 1;
}

#lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 4px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
    background-color: #000;
    /* Fallback si la img es png transaprente */
}

#lightbox .close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

#lightbox .close:hover,
#lightbox .close:focus {
    color: var(--accent-red);
    text-decoration: none;
}

.empty-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
}

/* Chat Input */
.chat-input-area {
    padding: 10px 24px 24px;
    flex-shrink: 0;
    background-color: transparent;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background-color: #ffffff;
    border-radius: 30px;
    padding: 8px 16px;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    border: 1px solid #e2e8f0;
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: #0f172a;
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
}

.input-wrapper input::placeholder {
    color: #94a3b8;
}

.attach-btn,
.send-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.attach-btn:hover {
    color: #0ea5e9;
}

.send-btn {
    background-color: #5c7c9a;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
}

.send-btn svg {
    fill: #fff;
    width: 16px;
    height: 16px;
    margin-left: -2px;
}

/* ====== COLUMNA 4: PANEL DERECHO ====== */
.sidebar-right {
    background-color: #f1f5f9;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.agent-control-card {
    margin: 20px;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.contact-profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px 10px;
    text-align: center;
}

.contact-avatar-large {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dbeafe, #c7d2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: #1e3a8a;
    font-size: 2.2rem;
    font-weight: 500;
    overflow: hidden;
    border: none;
}

.contact-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contact-name-large {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 2px;
}

.contact-phone {
    font-size: 0.85rem;
    color: #94a3b8;
}

.bot-status-title {
    display: none;
}

.bot-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bot-btn {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background-color: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    color: #64748b;
    gap: 12px;
    position: relative;
    text-align: left;
}

/* The toggle track */
.bot-btn::before {
    content: '';
    display: inline-flex;
    flex-shrink: 0;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background-color: #cbd5e1;
    transition: background-color 0.25s;
    /* The circle inside is simulated via box-shadow on ::after */
    position: relative;
}

/* The circle knob - positioned relative to the ::before via known offsets */
.bot-btn::after {
    content: '';
    position: absolute;
    left: 28px;   /* agent-control-card padding(12px) + btn padding-left(14px) + 2px */
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: left 0.25s, background-color 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* ACTIVE state */
.btn-activate.selected {
    color: #10b981;
    font-weight: 600;
}
.btn-activate.selected::before {
    background-color: #34d399;
}
.btn-activate.selected::after {
    left: 42px;   /* 28px + 14px (track width - knob width) */
    background-color: #ffffff;
}

/* INACTIVE state - RED */
.btn-deactivate.selected {
    color: #ef4444;
    font-weight: 600;
}
.btn-deactivate.selected::before {
    background-color: #fca5a5;
}
.btn-deactivate.selected::after {
    left: 42px;
    background-color: #ef4444;
}

.system-load-placeholder {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.load-label {
    font-size: 0.6rem;
    color: var(--text-tiny);
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.load-status {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chat-area {
    position: relative;
}

/* ====== ATTACHMENT PREVIEW OVERLAY ====== */
#attachment-preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-main);
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.preview-header {
    padding: 20px;
    display: flex;
    justify-content: flex-end;
}

#btn-close-preview {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 2rem;
    cursor: pointer;
}

.preview-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 20px;
}

#preview-img {
    max-width: 80%;
    max-height: 60vh;
    border-radius: 8px;
    object-fit: contain;
}

.preview-footer {
    display: flex;
    gap: 10px;
    padding: 20px;
    background: var(--bg-panel);
}

#preview-caption {
    flex: 1;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-pure);
    border-radius: 8px;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
}

#btn-send-attachment {
    padding: 0 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
}

/* ====== LABELS ====== */
.chat-list-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.chat-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.label-ventas { background: #dcfce7; color: #166534; border: 1px solid transparent; }
.label-agente_desactivado { background: #fee2e2; color: #b91c1c; border: 1px solid transparent; }
.label-soporte { background: #fee2e2; color: #b91c1c; border: 1px solid transparent; }
.label-voucher { background: #fef3c7; color: #b45309; border: 1px solid transparent; }

.nav-item { transition: all 0.2s ease; border-left: 3px solid transparent; }

.nav-item[data-label="all"].active-workspace { border-left-color: #0ea5e9 !important; color: #0ea5e9 !important; background-color: #e0f2fe !important; }
.nav-item[data-label="ventas"].active-workspace { border-left-color: #10b981 !important; color: #10b981 !important; background-color: #d1fae5 !important; }
.nav-item[data-label="soporte"].active-workspace { border-left-color: #ef4444 !important; color: #ef4444 !important; background-color: #fee2e2 !important; }
.nav-item[data-label="voucher"].active-workspace { border-left-color: #f97316 !important; color: #f97316 !important; background-color: #ffedd5 !important; }

/* Opcional: heredar el color a los SVG también */
.nav-item[data-label="all"].active-workspace .nav-icon { color: #0ea5e9 !important; }
.nav-item[data-label="ventas"].active-workspace .nav-icon { color: #10b981 !important; }
.nav-item[data-label="soporte"].active-workspace .nav-icon { color: #ef4444 !important; }
.nav-item[data-label="voucher"].active-workspace .nav-icon { color: #f97316 !important; }

/* ====== TOAST NOTIFICATIONS ====== */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast-notification { display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: rgba(20, 20, 20, 0.95); border-left: 4px solid; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); color: #fff; transform: translateX(120%); animation: slideIn 0.4s forwards, fadeOut 0.4s forwards 4.6s; backdrop-filter: blur(10px); min-width: 280px; }
.toast-voucher { border-color: #ff9100; }
.toast-soporte { border-color: #ff4d4d; }
.toast-title { font-weight: bold; font-size: 0.9rem; text-transform: uppercase; margin-bottom: 4px; }
.toast-desc { font-size: 0.8rem; color: #aaa; }
@keyframes slideIn { to { transform: translateX(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-10px); } }

/* ====== LOGIN SYSTEM — PREMIUM REDESIGN ====== */

@keyframes login-fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes login-grid-drift {
    0%   { background-position: 0 0; }
    100% { background-position: 60px 60px; }
}
@keyframes login-btn-pulse {
    0%   { box-shadow: 0 4px 18px rgba(37,99,235,0.35); }
    50%  { box-shadow: 0 4px 28px rgba(37,99,235,0.55); }
    100% { box-shadow: 0 4px 18px rgba(37,99,235,0.35); }
}
@keyframes login-spinner {
    to { transform: rotate(360deg); }
}

/* Container */
#login-container {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    background: #eef2f7;
    overflow: hidden;
}

/* Animated grid background */
.login-bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(148,163,184,0.18) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148,163,184,0.18) 1px, transparent 1px);
    background-size: 60px 60px;
    animation: login-grid-drift 8s linear infinite;
    pointer-events: none;
}

/* Card */
.login-card {
    position: relative;
    background: rgba(255,255,255,0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.9);
    border-radius: 24px;
    padding: 10px 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow:
        0 4px 6px rgba(0,0,0,0.04),
        0 20px 40px rgba(15,23,42,0.10),
        inset 0 1px 0 rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    gap: 22px;
    animation: login-fade-in 0.5s ease forwards;
    overflow: hidden;
}

/* Card header */
.login-card-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.login-card-logo {
    width: 280px;
    height: 280px;
    object-fit: contain;
    margin-top: -80px;
    margin-bottom: -80px;
    filter: drop-shadow(0 2px 6px rgba(37,99,235,0.2));
}

.login-card-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: #0f172a;
    margin: 0;
}

.login-card-subtitle {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0;
}

/* Field wrapper (groups underline + hint below it) */
.login-field-wrap {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Input fields */
.login-field {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1.5px solid #94a3b8;
    padding-bottom: 8px;
    transition: border-color 0.25s ease;
}

.login-field:focus-within {
    border-bottom-color: #1d4ed8;
}

.login-field-icon {
    color: #94a3b8;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color 0.25s;
}

.login-field:focus-within .login-field-icon {
    color: #1d4ed8;
}

.login-field-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.login-field input {
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: #0f172a;
    width: 100%;
    padding: 0;
}

.login-field input::placeholder {
    color: #94a3b8;
    font-size: 0.9rem;
}

.login-field-hint {
    font-size: 0.7rem;
    color: #94a3b8;
}

/* Password toggle */
.login-toggle-pass {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 0;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.login-toggle-pass:hover {
    color: #475569;
}

/* Submit button */
.login-btn {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 60%, #3b82f6 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 14px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.3s;
    box-shadow: 0 4px 18px rgba(37,99,235,0.35);
    margin-top: 4px;
}

.login-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    animation: login-btn-pulse 1.4s ease infinite;
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Status / error message */
#login-error {
    font-size: 0.82rem;
    min-height: 20px;
    margin: -8px 0 0;
    text-align: center;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: color 0.2s;
}

/* Elegant "Validating" spinner state */
#login-error.validating {
    color: #1d4ed8;
}

#login-error.validating::before {
    content: '';
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid #bfdbfe;
    border-top-color: #1d4ed8;
    border-radius: 50%;
    animation: login-spinner 0.7s linear infinite;
    flex-shrink: 0;
}

/* Footer */
.login-footer {
    text-align: center;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: -4px;
    border-top: 1px solid rgba(203,213,225,0.5);
    padding-top: 16px;
}

/* ============================================================
   BOTONES DE NAVEGACIÓN MÓVIL (solo visibles en mobile)
   ============================================================ */
.mobile-back-btn,
.mobile-info-btn,
#mobile-nav-close {
    display: none; /* ocultos en desktop */
}

/* Botón atrás de Columna 4: oculto en desktop, visible solo en móvil */
#mobile-back-from-info {
    display: none;
}

/* ============================================================
   RESPONSIVE MÓVIL — max-width: 768px
   ============================================================ */
@media (max-width: 768px) {

    body {
        overflow: hidden;
        height: 100dvh; /* dynamic viewport height para móviles */
    }

    /* El grid de 4 columnas pasa a una sola columna que llena la pantalla */
    .app-container,
    .app-container.sidebar-collapsed-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: 100dvh;
        width: 100vw;
    }

    /* ---- ESTADO 1: Solo Col1 + Col2 visibles (pantalla inicial) ---- */
    .app-container .sidebar-nav-main,
    .app-container .sidebar-left,
    .app-container .chat-area,
    .app-container #right-sidebar {
        display: none !important;
    }

    /* Estado 1: mostrar solo nav + lista */
    .app-container.mobile-state-1 .sidebar-nav-main {
        display: flex !important;
        width: 60px;
        flex-shrink: 0;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 10;
    }

    .app-container.mobile-state-1 .sidebar-left {
        display: flex !important;
        position: fixed;
        left: 60px;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 10;
    }

    /* Estado 1: colapsar siempre el nav lateral en móvil */
    .app-container.mobile-state-1 .sidebar-nav-main .nav-text,
    .app-container.mobile-state-1 .sidebar-nav-main .sidebar-title,
    .app-container.mobile-state-1 .sidebar-nav-main .brand-name,
    .app-container.mobile-state-1 .sidebar-nav-main .nav-profile-info {
        display: none !important;
    }
    .app-container.mobile-state-1 .sidebar-nav-main .nav-item {
        justify-content: center;
    }
    .app-container.mobile-state-1 .sidebar-nav-main .nav-profile-btn {
        justify-content: center;
        padding: 8px 6px;
    }

    /* ---- ESTADO 2: Solo Columna 3 (chat) ---- */
    .app-container.mobile-state-2 .chat-area {
        display: flex !important;
        position: fixed;
        inset: 0;
        z-index: 20;
        height: 100dvh;
        width: 100vw;
    }

    /* ---- ESTADO 3: Solo Columna 4 (info contacto) ---- */
    .app-container.mobile-state-3 #right-sidebar {
        display: flex !important;
        position: fixed;
        inset: 0;
        z-index: 30;
        height: 100dvh;
        width: 100vw;
        overflow-y: auto;
    }

    /* ---- Botones de navegación móvil ---- */
    .mobile-back-btn,
    .mobile-info-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--text-pure);
        padding: 6px;
        border-radius: 8px;
        transition: background 0.2s;
        flex-shrink: 0;
    }

    .mobile-back-btn:hover,
    .mobile-info-btn:hover {
        background: var(--bg-panel-hover);
    }

    .mobile-back-btn svg,
    .mobile-info-btn svg {
        width: 22px;
        height: 22px;
    }

    /* Botón atrás en la Columna 4 */
    #mobile-back-from-info {
        display: flex;
        align-items: center;
        gap: 8px;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--text-pure);
        padding: 16px 20px 0;
        font-size: 0.9rem;
        font-weight: 500;
        font-family: inherit;
    }

    #mobile-back-from-info svg {
        width: 20px;
        height: 20px;
    }

    /* ---- Menú hamburguesa móvil: drawer lateral fijo + overlay oscuro ---- */

    /* Panel blanco del menú: drawer de 270px anclado a la izquierda */
    .app-container.mobile-state-1 .sidebar-nav-main.mobile-nav-open {
        width: 270px !important;    /* !important necesario para ganar al #sidebar.sidebar-collapsed {width:70px} */
        left: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        position: fixed !important;
        z-index: 200 !important;
        background: var(--bg-nav);
        padding-bottom: 24px;
        overflow-y: auto;
        overflow-x: hidden;
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.2);
    }

    /* Mostrar textos cuando el menú está abierto en móvil */
    .app-container.mobile-state-1 .sidebar-nav-main.mobile-nav-open .nav-text,
    .app-container.mobile-state-1 .sidebar-nav-main.mobile-nav-open .sidebar-title,
    .app-container.mobile-state-1 .sidebar-nav-main.mobile-nav-open .nav-profile-info {
        display: block !important;
    }

    .app-container.mobile-state-1 .sidebar-nav-main.mobile-nav-open .nav-item {
        justify-content: flex-start;
    }

    .app-container.mobile-state-1 .sidebar-nav-main.mobile-nav-open .nav-profile-btn {
        justify-content: flex-start;
        padding: 8px 10px;
    }

    /* Overlay oscuro: cubre el 100% DETRÁS del panel blanco */
    #mobile-nav-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.55);
        z-index: 190;           /* Debajo del panel (200) pero encima del resto */
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    #mobile-nav-overlay.active {
        display: block;
    }

    /* Botón X cerrar menú: solo visible cuando el drawer está abierto */
    #mobile-nav-close {
        display: none; /* oculto por defecto en móvil también */
        align-items: center;
        justify-content: flex-end;
        padding: 16px 20px 8px;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 1.6rem;
        cursor: pointer;
        width: 100%;
        line-height: 1;
    }
    /* Solo aparece cuando el drawer está abierto */
    .sidebar-nav-main.mobile-nav-open #mobile-nav-close {
        display: flex;
    }
    #mobile-nav-close:hover {
        color: var(--text-pure);
    }
}