/* ==========================================
   AeroCRM Premium Design System (Glassmorphism & Dark Vibe)
   ========================================== */

/* Variables y Paleta de Colores HSL */
:root {
    --bg-app: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: hsl(210, 40%, 98%);
    --border-glass: hsl(214, 32%, 91%);
    --border-glass-focus: hsla(145, 63%, 42%, 0.6);
    
    /* Acentos */
    --primary: hsl(145, 63%, 42%);      /* Verde PROXI Crédito */
    --primary-hover: hsl(145, 63%, 34%);
    --primary-glow: hsla(145, 63%, 42%, 0.22);

    --secondary: hsl(216, 62%, 35%);    /* Azul navy (de Crédito) */
    --accent-orange: hsl(32, 95%, 52%);  /* Naranja / Pendientes */
    --accent-red: hsl(0, 85%, 60%);     /* Rojo / Cancelados */
    --accent-green: hsl(142, 70%, 45%);   /* Verde / Resueltos */
    
    /* Textos */
    --text-main: hsl(215, 35%, 18%);
    --text-muted: hsl(215, 16%, 47%);
    --text-dark: hsl(222, 25%, 15%);
    
    /* Animaciones y Sombras */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-soft: 0 4px 16px rgba(15, 23, 42, 0.08);
    --blur-glass: blur(12px);
}

/* Reset de Estilos */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: #ffffff;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Contenedor Principal (Layout de Rejilla / Grid) */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* ==========================================
   Barra Lateral (Sidebar)
   ========================================== */
.sidebar {
    background: hsl(210, 40%, 98%);
    border-right: 1px solid var(--border-glass);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 3rem;
}

.logo-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
    transition: var(--transition);
}

.logo-img:hover {
    transform: rotate(360deg);
}

.logo-area h2 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

.logo-area h2 span {
    color: var(--primary);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    color: var(--text-main);
    background: var(--bg-card);
    box-shadow: inset 0 0 0 1px var(--border-glass);
}

.nav-item.active {
    color: var(--primary);
    box-shadow: inset 0 0 0 1px hsla(208, 65%, 48%, 0.2);
}

.nav-item .icon {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    border-top: 1px solid var(--border-glass);
    padding-top: 1.5rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.75rem;
    color: var(--primary);
}

/* ==========================================
   Contenido Principal
   ========================================== */
.main-content {
    padding: 2.5rem;
    overflow-y: auto;
    max-height: 100vh;
}

/* Encabezado Superior (Header) */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.header-title h1 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Estado de Conexión */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-orange);
    box-shadow: 0 0 8px var(--accent-orange);
}

.status-dot.online {
    background-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* ==========================================
   KPIs Grid (Tarjetas de Métricas)
   ========================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.kpi-card {
    background: var(--bg-card);
    backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-4px);
    border-color: hsla(210, 100%, 56%, 0.3);
    box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.kpi-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon svg {
    width: 20px;
    height: 20px;
}

.kpi-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--secondary); }
.kpi-icon.cyan { background: rgba(6, 182, 212, 0.15); color: var(--secondary); }
.kpi-icon.green { background: rgba(34, 197, 94, 0.15); color: var(--accent-green); }
.kpi-icon.orange { background: rgba(249, 115, 22, 0.15); color: var(--accent-orange); }

.kpi-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.kpi-subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================
   Controles y Filtros
   ========================================== */
.table-section {
    background: var(--bg-card);
    backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 1.75rem;
    box-shadow: var(--shadow-soft);
}

.table-controls {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 500px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    background: hsl(210, 40%, 98%);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 14px 16px 14px 48px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--border-glass-focus);
    box-shadow: 0 0 10px var(--primary-glow);
}

.filter-box select {
    background: hsl(210, 40%, 98%);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 14px 20px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    min-width: 200px;
    transition: var(--transition);
}

.filter-box select:focus {
    border-color: var(--border-glass-focus);
}

/* ==========================================
   Tabla de Leads
   ========================================== */
.table-container {
    overflow-x: auto;
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.leads-table th {
    padding: 16px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-glass);
}

.leads-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.95rem;
}

.leads-table tbody tr {
    transition: var(--transition);
    cursor: pointer;
}

.leads-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.table-loading {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Celdas especiales */
.date-cell {
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.name-cell {
    font-weight: 600;
    color: var(--text-main);
}

.phone-cell {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--secondary);
}

.summary-cell {
    color: var(--text-muted);
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Etiquetas de Estado */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

/* Badges de Tipo de Consulta */
.badge.tipo-compra { background: rgba(59, 130, 246, 0.15); color: hsl(210, 100%, 75%); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge.tipo-financiar { background: rgba(168, 85, 247, 0.15); color: hsl(270, 100%, 80%); border: 1px solid rgba(168, 85, 247, 0.3); }
.badge.tipo-visita { background: rgba(236, 72, 153, 0.15); color: hsl(330, 100%, 80%); border: 1px solid rgba(236, 72, 153, 0.3); }
.badge.tipo-promotor { background: rgba(249, 115, 22, 0.15); color: hsl(25, 100%, 75%); border: 1px solid rgba(249, 115, 22, 0.3); }
.badge.tipo-entrega { background: rgba(6, 182, 212, 0.15); color: hsl(190, 100%, 75%); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge.tipo-pqr { background: rgba(239, 68, 68, 0.15); color: hsl(0, 100%, 75%); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge.tipo-proveedor { background: rgba(234, 179, 8, 0.15); color: hsl(45, 100%, 70%); border: 1px solid rgba(234, 179, 8, 0.3); }
.badge.tipo-vacio { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); border: 1px solid var(--border-glass); }

/* Badges de Estado */
.badge.estado-nuevo { background: rgba(6, 182, 212, 0.15); color: var(--secondary); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge.estado-gestion { background: rgba(59, 130, 246, 0.15); color: hsl(210, 100%, 75%); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge.estado-pendiente { background: rgba(249, 115, 22, 0.15); color: var(--accent-orange); border: 1px solid rgba(249, 115, 22, 0.3); }
.badge.estado-resuelto { background: rgba(34, 197, 94, 0.15); color: var(--accent-green); border: 1px solid rgba(34, 197, 94, 0.3); }
.badge.estado-sin-respuesta { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); border: 1px solid rgba(107, 114, 128, 0.3); }

/* ==========================================
   Botones y Elementos de Acción
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: var(--bg-app);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-success {
    background: var(--primary);
    color: var(--bg-app);
}

.btn-success:hover {
    background: var(--primary-hover);
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 14px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(210, 40%, 96%);
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    transition: var(--transition);
}

.btn-icon:hover {
    background: hsl(210, 40%, 92%);
    color: var(--text-main);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.text-right {
    text-align: right;
}

.icon {
    width: 20px;
    height: 20px;
}

/* Animación del Spinner */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.syncing .spinner-icon {
    animation: spin 1s linear infinite;
}

/* ==========================================
   Panel Lateral Deslizable (Drawer)
   ========================================== */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100vh;
    background: var(--bg-app);
    border-left: 1px solid var(--border-glass);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    transition: cubic-bezier(0.4, 0, 0.2, 1) 0.4s;
}

.drawer.active {
    right: 0;
}

.drawer-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-header-left h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.phone-badge {
    font-size: 0.8rem;
    color: var(--secondary);
    font-family: monospace;
}

.close-drawer {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.close-drawer:hover {
    color: var(--accent-red);
}

.drawer-content {
    padding: 1.5rem;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Visor de Chat estilo WhatsApp */
.chat-container {
    background: hsl(210, 40%, 98%);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    height: 380px; /* Caja fija para chats */
    overflow: hidden;
}

.chat-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-glass);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-avatar-img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--primary);
}

.chat-header-info h4 {
    font-size: 0.85rem;
    font-weight: 600;
}

.chat-header-info p {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chat-messages {
    flex-grow: 1;
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Fondo estilo WhatsApp */
    background-image: radial-gradient(var(--border-glass) 1px, transparent 1px);
    background-size: 16px 16px;
}

/* Burbujas de Chat */
.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.4;
    position: relative;
    word-break: break-word;
}

/* Mensaje del Bot (Izquierda - Gris Oscuro) */
.message.bot {
    align-self: flex-start;
    background: hsl(210, 40%, 96%);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
    border: 1px solid var(--border-glass);
}

/* Mensaje del Cliente (Derecha - Azul Corporativo) */
.message.client {
    align-self: flex-end;
    background: hsl(216, 62%, 35%);
    color: #fff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.message-time {
    display: block;
    text-align: right;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.message.client .message-time {
    color: hsla(210, 30%, 96%, 0.6);
}

/* Formulario de Edición */
.lead-edit-form h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--primary);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    background: hsl(210, 40%, 98%);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    padding: 12px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--border-glass-focus);
}

textarea.form-control {
    resize: none;
    line-height: 1.5;
}

/* Barra de desplazamiento (Scrollbars) estilizada */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: hsl(214, 32%, 93%);
}

::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-glow);
}

/* ==========================================
   Botón expandir chat
   ========================================== */
.btn-expand-chat {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-expand-chat:hover {
    background: var(--bg-card-hover);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-expand-chat svg {
    width: 16px;
    height: 16px;
}

/* ==========================================
   Modal Conversación Completa
   ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--bg-app);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    width: 90%;
    max-width: 720px;
    height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    transform: scale(0.95);
    transition: var(--transition);
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-chat {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-image: radial-gradient(var(--border-glass) 1px, transparent 1px);
    background-size: 16px 16px;
}

/* Media Queries para diseño responsive */
@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none; /* Simplificado para móviles en esta fase */
    }
}

/* Sidebar Robot Section */
.sidebar-robot {
    background: hsl(210, 40%, 97%);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 1rem;
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.robot-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--secondary);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
    animation: float 3s ease-in-out infinite;
}

.robot-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* ==========================================
   MEDIA STYLES (añadidos al final)
   ========================================== */

.chat-media {
    max-width: 220px;
    border-radius: 12px;
    cursor: zoom-in;
    display: block;
}

video.chat-media,
img.chat-media {
    max-width: 220px;
}

audio.chat-media {
    width: 240px;
    cursor: auto;
}

.chat-media-doc {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: hsl(210, 40%, 96%);
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    max-width: 280px;
}

.message.valentina {
    align-self: flex-start;
    background: hsl(145, 50%, 92%);
    border: 1px solid var(--accent-green);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.message.valentina strong::before {
    content: "👩‍💼 Valentina ";
}

/* Botón adjuntar */
#btn-attach-drawer,
#btn-attach-modal {
    border: 1px solid var(--border-glass);
    background: transparent;
    color: var(--text-muted);
    transition: var(--transition);
}

#btn-attach-drawer:hover,
#btn-attach-modal:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-glow);
}

/* Chip preview pre-envío */
.media-preview-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    font-size: 0.8rem;
    margin: 4px 0;
}

/* Lightbox */
#lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

#lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

#lightbox-overlay .lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
}

/* Responsive: media bubbles caben en móvil */
@media (max-width: 768px) {
    .chat-media {
        max-width: 180px;
    }
    audio.chat-media {
        width: 100%;
        max-width: 280px;
    }
    .message {
        max-width: 90%;
    }
}

/* ==========================================================================
   Controles de ventana del modal (media / completa / minimizar)
   ========================================================================== */
.modal-win-controls { display: flex; align-items: center; gap: 4px; }
.win-btn {
    background: none;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.win-btn:hover { background: var(--bg-card-hover); color: var(--primary); border-color: var(--primary); }
.win-btn .icon { width: 16px; height: 16px; }
.win-btn.close-drawer:hover { color: var(--accent-red); border-color: var(--accent-red); }

.modal-box.fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: 100vh;
    border-radius: 0;
}

/* Ícono flotante (chat minimizado) */
.chat-float-btn {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    border: 2px solid var(--primary);
    background: var(--bg-card);
    z-index: 1150;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: visible;
}
.chat-float-btn.active { display: flex; }
.chat-float-btn:hover { box-shadow: 0 0 18px var(--primary-glow); }
.chat-float-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.chat-float-btn .float-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--accent-red);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
}
.chat-float-btn.has-new .float-badge { display: flex; }

/* Botón grabar audio */
.btn-rec {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-rec:hover { color: var(--primary-hover); border-color: var(--primary); background: transparent; }
.btn-rec.recording {
    color: #fff;
    background: var(--accent-red);
    border-color: var(--accent-red);
    font-size: 0.85rem;
    font-weight: 600;
    animation: recpulse 1.2s ease-in-out infinite;
}
@keyframes recpulse { 0%,100%{opacity:1;} 50%{opacity:0.55;} }
