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

:root {
    --primary-color: #25D366;
    --primary-dark: #128C7E;
    --secondary-color: #34B7F1;
    --bg-dark: #0B141A;
    --bg-card: #1E2428;
    --bg-hover: #2A2F32;
    --text-primary: #E9EDEF;
    --text-secondary: #8696A0;
    --border-color: #2A2F32;
    --success: #25D366;
    --error: #F15C6D;
    --warning: #FFB800;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #0B141A 0%, #1E2428 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px 30px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: pulse 2s infinite;
}

.status-dot.ready {
    background: var(--success);
    animation: none;
}

.status-dot.connecting {
    background: var(--warning);
}

.status-dot.error {
    background: var(--error);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 320px 1fr 350px;
    gap: 20px;
}

/* Conversations Sidebar */
.conversations-sidebar {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    overflow: hidden;
}

.conversations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.conversations-header h2 {
    font-size: 20px;
    color: var(--text-primary);
    margin: 0;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.conversations-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-btn {
    flex: 1;
    min-width: 70px;
    padding: 8px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conversations-list::-webkit-scrollbar {
    width: 6px;
}

.conversations-list::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 3px;
}

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

.conversation-item {
    background: var(--bg-dark);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.conversation-item:hover {
    background: var(--bg-hover);
    transform: translateX(2px);
}

.conversation-item.active {
    background: var(--bg-hover);
    border-left-color: var(--primary-color);
}

.conversation-item.has-unread {
    border-left-color: var(--primary-color);
    border-left-width: 4px;
}

.conversation-item.has-unread .conversation-name {
    font-weight: 700;
    color: var(--text-primary);
}

.conversation-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.conversation-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 8px;
    white-space: nowrap;
}

.conversation-preview {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.conversations-search {
    margin-bottom: 12px;
}

.conversation-search-input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
}

.conversation-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-secondary);
}

.conversation-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--bg-hover);
}

.conversation-badge.group {
    background: rgba(52, 183, 241, 0.2);
    color: var(--secondary-color);
}

/* Notification Badge */
.notification-badge {
    display: inline-block;
    background: var(--error);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    min-width: 20px;
    text-align: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.conversation-unread {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}

.empty-state-small {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
}

/* Conversation Info */
.conversation-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conversation-info h2 {
    font-size: 18px;
    color: var(--text-primary);
    margin: 0;
}

#conversationSubtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.sidebar-section h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 8px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-value {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 16px;
}

/* Forms */
.send-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.send-form input,
.send-form textarea {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.3s;
}

.send-form input:focus,
.send-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.send-form textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    width: 100%;
    margin-bottom: 15px;
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-small {
    padding: 8px 16px;
    font-size: 12px;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.btn-danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}

.btn-danger:disabled {
    background: #6c757d;
    border-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-small:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

/* Messages Area */
.messages-area {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    overflow: hidden;
    position: relative;
}

/* Chat Selected View - Layout de 3 secciones fijas */
#chatSelectedView {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    position: relative;
}

.messages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
    background: var(--bg-card);
    z-index: 10;
}

.messages-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

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

.search-input {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    min-width: 200px;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    box-sizing: border-box;
    min-height: 0; /* Importante para que funcione el scroll */
    /* Asegurar que el scroll funcione correctamente */
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 4px;
}

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

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
}

/* Message Card */
.message-card {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease-out;
    max-width: 75%;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-card.message-received {
    align-items: flex-start;
}

.message-card.message-sent {
    align-items: flex-end;
    margin-left: auto;
}

.message-author {
    font-size: 12px;
    color: var(--primary-color);
    margin-bottom: 4px;
    padding-left: 4px;
    font-weight: 500;
}

.message-bubble {
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    max-width: 100%;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

.message-received .message-bubble {
    background: var(--bg-card);
    border-top-left-radius: 4px;
    color: var(--text-primary);
}

.message-sent .message-bubble {
    background: #DCF8C6;
    border-top-right-radius: 4px;
    color: #111B21;
}

.message-body {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-received .message-body {
    color: var(--text-primary);
}

.message-sent .message-body {
    color: #111B21;
}

.message-body strong {
    font-weight: 600;
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: inherit;
}

.message-option {
    margin: 4px 0;
    padding: 3px 0;
    padding-left: 8px;
    line-height: 1.4;
    font-size: 13px;
    border-left: 2px solid rgba(255, 255, 255, 0.2);
}

.message-sent .message-option {
    border-left-color: rgba(0, 0, 0, 0.1);
}

.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
}

.message-time {
    font-size: 11px;
    text-align: right;
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-received .message-time {
    color: var(--text-secondary);
}

.message-sent .message-time {
    color: rgba(0, 0, 0, 0.5);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-badge {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

/* Chats List */
.chats-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-item {
    background: var(--bg-dark);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.chat-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

/* Modal de QR - siempre visible cuando se muestra */
#qrModal {
    z-index: 10000;
}

#qrModal .close {
    /* Ocultar el botón de cerrar si no está autenticado */
    cursor: not-allowed;
    opacity: 0.5;
}

#qrModal.authenticated .close {
    cursor: pointer;
    opacity: 1;
}

.modal-content {
    background: var(--bg-card);
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    max-width: 400px;
    max-height: 90vh;
    overflow: hidden;
    text-align: center;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.modal-content > form,
.modal-content > div:not(.close) {
    padding: 30px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.modal-content > h2 {
    padding: 30px 30px 15px 30px;
    margin: 0;
    flex-shrink: 0;
    text-align: left;
}

.modal-content > .close {
    position: absolute;
    right: 20px;
    top: 20px;
    z-index: 10;
    padding: 0;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content .close,
.modal-large .close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
    background: var(--bg-card);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

#qrContainer {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

#qrContainer img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.qr-instructions {
    font-size: 12px;
    line-height: 1.6;
    margin-top: 15px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-left: 4px solid var(--primary-color);
    min-width: 300px;
    animation: toastSlideIn 0.3s ease-out;
}

.toast.error {
    border-left-color: var(--error);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.info {
    border-left-color: var(--secondary-color);
    background: rgba(52, 183, 241, 0.1);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Templates Section */
.templates-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.templates-header {
    display: flex;
    gap: 8px;
    align-items: center;
}

.template-filter {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
}

.template-filter:focus {
    outline: none;
    border-color: var(--primary-color);
}

.templates-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.templates-list::-webkit-scrollbar {
    width: 6px;
}

.templates-list::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 3px;
}

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

.template-item {
    background: var(--bg-dark);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.template-item:hover {
    background: var(--bg-hover);
    border-left-color: var(--primary-color);
    transform: translateX(2px);
}

.template-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.template-item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
    flex: 1;
}

.template-item-actions {
    display: flex;
    gap: 4px;
}

.template-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.template-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.template-action-btn.favorite {
    color: var(--warning);
}

.template-item-preview {
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.template-item-meta {
    display: flex;
    gap: 8px;
    font-size: 10px;
    color: var(--text-secondary);
}

.template-badge {
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

/* Template Modal */
.modal-large {
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    text-align: left;
}

.modal-large > form,
.modal-large > div:not(.close) {
    padding: 30px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.modal-large > h2 {
    padding: 30px 30px 15px 30px;
    margin: 0;
    flex-shrink: 0;
    text-align: left;
}

.modal-large > .close {
    position: absolute;
    right: 20px;
    top: 20px;
    z-index: 10;
    padding: 0;
}

.template-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0; /* Permite que el flex funcione correctamente con overflow */
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-hint {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
}

.variables-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.variable-item {
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--bg-dark);
    padding: 8px;
    border-radius: 6px;
}

.variable-item input {
    flex: 1;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px;
    color: var(--text-primary);
    font-size: 12px;
}

.variable-item button {
    background: var(--error);
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: auto; /* Empuja los botones hacia abajo */
    padding-top: 20px;
    flex-shrink: 0; /* Evita que los botones se compriman */
    border-top: 1px solid var(--border-color);
}

/* Surveys Section */
.surveys-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.surveys-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.surveys-list::-webkit-scrollbar {
    width: 6px;
}

.surveys-list::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 3px;
}

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

.survey-item {
    background: var(--bg-dark);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.survey-item:hover {
    background: var(--bg-hover);
    border-left-color: var(--secondary-color);
    transform: translateX(2px);
}

.survey-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.survey-item-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
    flex: 1;
}

.survey-item-actions {
    display: flex;
    gap: 4px;
}

.survey-item-preview {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.survey-item-stats {
    display: flex;
    gap: 12px;
    font-size: 10px;
    color: var(--text-secondary);
}

.survey-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.option-item {
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--bg-dark);
    padding: 8px;
    border-radius: 6px;
}

.option-item input {
    flex: 1;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px;
    color: var(--text-primary);
    font-size: 12px;
}

.option-item button {
    background: var(--error);
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

/* Survey Results */
.survey-results {
    max-height: 500px;
    overflow-y: auto;
}

.results-summary {
    background: var(--bg-dark);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.results-summary h3 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
    font-size: 16px;
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.stat-box {
    background: var(--bg-hover);
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}

.stat-box-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-box-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.results-chart {
    margin: 20px 0;
}

.chart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.chart-label {
    min-width: 120px;
    font-size: 13px;
    color: var(--text-primary);
}

.chart-bar-container {
    flex: 1;
    background: var(--bg-dark);
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.chart-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    transition: width 0.3s ease;
}

.chart-value {
    color: white;
    font-size: 11px;
    font-weight: 600;
}

.responses-list {
    margin-top: 20px;
}

.responses-list h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 14px;
}

.response-item {
    background: var(--bg-dark);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.response-from {
    font-size: 12px;
    color: var(--text-secondary);
}

.response-text {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.response-time {
    font-size: 11px;
    color: var(--text-secondary);
}

/* File Upload */
.file-upload-section {
    margin: 10px 0;
}

.file-preview {
    margin-top: 8px;
    padding: 8px;
    background: var(--bg-dark);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    min-height: 50px;
    display: block;
}

.file-preview:empty {
    display: none;
}

.file-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.file-preview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px;
    background: var(--bg-hover);
    border-radius: 4px;
    margin-bottom: 4px;
}

.file-preview-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    font-size: 12px;
}

.file-preview-remove {
    background: var(--error);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

/* Scheduled Messages */
.scheduled-list,
.auto-reply-list {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scheduled-item,
.auto-reply-item {
    background: var(--bg-dark);
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.scheduled-item:hover,
.auto-reply-item:hover {
    background: var(--bg-hover);
    transform: translateX(2px);
}

.scheduled-item-header,
.auto-reply-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.scheduled-item-name,
.auto-reply-item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
    flex: 1;
}

.scheduled-item-time,
.auto-reply-item-keywords {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.scheduled-item-status {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.scheduled-item-status.pending {
    background: var(--warning);
    color: white;
}

.scheduled-item-status.sent {
    background: var(--success);
    color: white;
}

.scheduled-item-status.error {
    background: var(--error);
    color: white;
}

.auto-reply-item-active {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    background: var(--success);
    color: white;
}

.auto-reply-item-inactive {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    background: var(--text-secondary);
    color: white;
}

/* Chat Selector */
.chat-selector-container {
    margin-top: 10px;
}

.chat-search-input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    color: var(--text-primary);
    font-size: 13px;
    margin-bottom: 10px;
}

.chat-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chat-selector-list {
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
}

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

.chat-selector-list::-webkit-scrollbar-track {
    background: var(--bg-hover);
    border-radius: 3px;
}

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

.chat-selector-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
}

.chat-selector-item:hover {
    background: var(--bg-hover);
}

.chat-selector-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.chat-selector-item-info {
    flex: 1;
    min-width: 0;
}

.chat-selector-item-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-selector-item-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.selected-chats {
    margin-top: 10px;
    padding: 10px;
    background: var(--bg-dark);
    border-radius: 6px;
    min-height: 40px;
}

.selected-chat-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin: 4px;
}

.selected-chat-tag button {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.selected-chat-tag button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.bulk-selector-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* No Chat Selected View */
.no-chat-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
}

.quick-actions {
    width: 100%;
    max-width: 900px;
}

.quick-actions h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-primary);
    font-size: 28px;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.quick-action-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.quick-action-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 8px 16px rgba(37, 211, 102, 0.2);
}

.quick-action-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.quick-action-card h3 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 18px;
}

.quick-action-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

/* Message Send Form */
.message-send-form {
    display: flex !important;
    align-items: flex-end;
    gap: 10px;
    padding: 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-grow: 0;
    z-index: 10;
    min-height: fit-content;
    position: relative;
    visibility: visible !important;
    opacity: 1 !important;
}

.message-input-textarea {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    font-family: inherit;
    min-height: 44px;
    max-height: 120px;
}

.message-input-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-send {
    min-width: 50px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Stats Modal */
.stats-full {
    padding: 20px 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-card-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.stat-card-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.stat-card-label {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Message with Media */
.message-media {
    margin-top: 8px;
    border-radius: 6px;
    overflow: hidden;
    max-width: 100%;
}

.message-media-icon {
    margin-right: 6px;
}

.message-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 6px;
    display: block;
    object-fit: contain;
    cursor: pointer;
}

.message-video {
    max-width: 100%;
    max-height: 400px;
    border-radius: 6px;
    display: block;
}

.message-audio {
    width: 100%;
    max-width: 300px;
    margin-top: 4px;
}

.message-media-link {
    color: var(--primary-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    background: var(--bg-hover);
    border-radius: 6px;
    font-size: 12px;
    transition: background 0.2s;
}

.message-media-link:hover {
    background: var(--bg-dark);
}

.message-media-fallback {
    padding: 8px;
    background: var(--bg-hover);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Respuesta a mensaje - Estilo unificado para enviados y recibidos */
.message-reply-to {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 6px;
    border-left: 3px solid;
    border-radius: 4px;
    font-size: 12px;
    max-width: 100%;
    overflow: hidden;
}

/* Estilo diferente para mensajes recibidos vs enviados */
.message-received .message-reply-to {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--primary-color);
}

.message-sent .message-reply-to {
    background: rgba(0, 0, 0, 0.2);
    border-left-color: rgba(255, 255, 255, 0.4);
}

.message-reply-to-indicator {
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
    opacity: 0.8;
}

.message-reply-to-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.message-reply-to-author {
    font-weight: 600;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.3;
}

/* Color del autor según tipo de mensaje */
.message-received .message-reply-to-author {
    color: var(--primary-color);
}

.message-sent .message-reply-to-author {
    color: rgba(255, 255, 255, 0.9);
}

.message-reply-to-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.3;
    opacity: 0.8;
}

/* Color del texto según tipo de mensaje */
.message-received .message-reply-to-text {
    color: var(--text-secondary);
}

.message-sent .message-reply-to-text {
    color: rgba(255, 255, 255, 0.7);
}

/* Indicador de respuesta en el formulario */
.reply-indicator {
    background: var(--bg-hover);
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reply-indicator-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reply-indicator-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.reply-indicator-text {
    flex: 1;
    min-width: 0;
}

.reply-indicator-author {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 12px;
    margin-bottom: 2px;
}

.reply-indicator-preview {
    color: var(--text-secondary);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-indicator-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.reply-indicator-close:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* Hover en mensajes para indicar que se puede responder */
.message-card {
    transition: background 0.2s;
    position: relative;
}

.message-card:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Menú de opciones de mensaje */
.message-options {
    position: relative;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: 4px;
}

.message-card:hover .message-options {
    opacity: 1;
}

.message-options-btn {
    background: transparent;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s;
    padding: 0;
    opacity: 0.7;
}

.message-received .message-options-btn {
    color: var(--text-secondary);
}

.message-sent .message-options-btn {
    color: rgba(0, 0, 0, 0.5);
}

.message-options-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

.message-sent .message-options-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.message-options-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 150px;
    z-index: 100;
    display: none;
    overflow: hidden;
}

.message-options-menu.active {
    display: block;
    animation: slideDown 0.2s ease-out;
}

.message-option-item {
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    transition: background 0.2s;
}

.message-option-item:hover {
    background: var(--bg-hover);
}

.message-option-item span {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.message-option-danger {
    color: var(--error);
}

.message-option-danger:hover {
    background: rgba(241, 92, 109, 0.1);
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Responsive */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 280px 1fr 300px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .conversations-sidebar {
        height: auto;
        min-height: 300px;
        max-height: 400px;
    }
    
    .messages-area {
        height: auto;
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
}

