/* style.css (Versión 2.1 - Tema Claro, Responsivo y con Login Corregido) */
:root {
    --bg-color: #F0F2F5;
    --content-bg: #FFFFFF;
    --sidebar-bg: #FFFFFF;
    --text-color: #050505;
    --text-muted: #65676B;
    --border-color: #DADDE1;
    --accent-blue: #1877F2;
    --accent-green: #42b72a;
    --accent-red: #FA383E;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
}

.sidebar {
    width: 240px;
    background-color: var(--sidebar-bg);
    padding: 20px;
    height: 100vh;
    border-right: 1px solid var(--border-color);
    box-sizing: border-box;
    position: fixed;
    left: 0;
    transition: left 0.3s ease;
}

.sidebar .brand {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--accent-blue);
    margin-bottom: 30px;
    display: block;
    text-decoration: none;
}

.sidebar nav a {
    display: block;
    color: var(--text-muted);
    text-decoration: none;
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.sidebar nav a.active, .sidebar nav a:hover {
    background-color: #E7F3FF;
    color: var(--accent-blue);
}

.sidebar .logout {
    position: absolute;
    bottom: 20px;
    width: 200px;
}
.sidebar .logout a {
    border: 1px solid var(--border-color);
}
.sidebar .logout a:hover {
    background-color: #f2f2f2;
    color: var(--text-color);
}

.main-content {
    flex-grow: 1;
    padding: 20px 20px 20px 2px; /* Padding izquierdo casi eliminado */
    height: 100vh;
    overflow-y: auto;
    box-sizing: border-box;
    margin-left: 17% !important; /* Reducido 15px del original para eliminar completamente el espacio */
    transition: margin-left 0.3s ease;
}

.main-processors {
    margin-left: 1px !important; /* Más espacio para la página de procesadores */
}
h1, h2 {
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--content-bg);
    margin-top: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
th, td {
    border-bottom: 1px solid var(--border-color);
    padding: 15px;
    text-align: left;
}
th {
    background-color: #F5F6F7;
    font-weight: 600;
}
tr:last-child td {
    border-bottom: none;
}
tr:hover {
    background-color: #f5f6f7;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
}
a:hover {
    text-decoration: underline;
}

/* --- Estilos Responsivos --- */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .sidebar { left: -240px; z-index: 1000; }
    .sidebar.show { left: 0; }
    .main-content { margin-left: 0; padding: 20px; }
    .main-content.sidebar-open { margin-left: 240px; }
    .menu-toggle { display: block; }
    h1 { font-size: 1.5em; }
}

/* --- Otros Estilos --- */
.status-PENDIENTE { color: #f0ad4e; font-weight: bold; }
.status-ENVIADO { color: var(--accent-green); font-weight: bold; }
.status-FALLIDO { color: var(--accent-red); font-weight: bold; }

.chat-box {
    background: #E4E2DE;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5em;
    height: 70vh;
    overflow-y: scroll;
    display: flex;
    flex-direction: column;
}

/* --- Burbujas de chat tipo WhatsApp --- */
.message {
    margin-bottom: 1em;
    padding: 10px 16px;
    border-radius: 18px;
    max-width: 65%;
    line-height: 1.5;
    box-shadow: 0 1px 1px rgba(0,0,0,0.07);
    position: relative;
    word-break: break-word;
    font-size: 1.05em;
}
.message-content {
    margin-bottom: 5px;
    line-height: 1.4;
}

.message-info {
    display: block;
    font-size: 0.75em;
    color: var(--text-muted);
    margin-top: 5px;
    opacity: 0.8;
}
.align-left {
    align-self: flex-start;
    text-align: left;
}
.align-right {
    align-self: flex-end;
    text-align: right;
}
.align-center {
    align-self: center;
    text-align: center;
}
.agent-bubble {
    background: #fff;
    border: 1px solid #e0e0e0;
    color: #222;
    margin-right: auto;
}
.client-bubble {
    background: #DCF8C6;
    color: #222;
    border: 1px solid #b2e59e;
    margin-left: auto;
}
.system-bubble {
    background: #f0f0f0;
    color: #666;
    border: 1px solid #ddd;
    margin: 10px auto;
    max-width: 80%;
    text-align: center;
    font-size: 0.9em;
    font-style: italic;
}

/* --- INICIO DE LAS CLASES CORREGIDAS PARA EL LOGIN --- */
.login-body {
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-container {
    background: var(--content-bg);
    padding: 2.5em;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-align: center;
    border: 1px solid var(--border-color);
    width: 350px;
}
.login-container h1 {
    border: none;
    padding-bottom: 0;
    margin-bottom: 5px;
}
.login-container input {
    background-color: #F5F6F7;
    color: var(--text-color);
    width: 100%;
    padding: 12px;
    margin-top: 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box;
}
.login-container button {
    background-color: var(--accent-blue);
    color: white;
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    margin-top: 15px;
    transition: background-color 0.2s;
}
.login-container button:hover {
    background-color: #166FE5;
}
.login-container .error {
    color: var(--accent-red);
    margin-top: 15px;
    font-weight: 500;
}


/* --- Estilos para los Logos --- */

/* Logo en la página de Login */
.login-container .logo {
    width: 150px; /* Ajusta el tamaño según tu logo */
    height: auto;
    margin-bottom: 15px;
}

/* Logo en el menú lateral (sidebar) */
.sidebar .brand {

    display: flex;
    justify-content: center; /* <-- Esta línea centra el logo */
    padding-bottom: 15px;
}

.sidebar-logo {
    width: 100px; /* Tamaño del logo en el menú */
    height: auto;
}

/* --- Estilos para la Información del Usuario --- */

/* --- Estilos para la Información del Usuario --- */

.user-info {
    display: flex; /* <-- Pone los elementos en línea (horizontal) */
    align-items: center; /* <-- Los alinea verticalmente al centro */
    padding: 15px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px; /* Espacio entre el ícono y el nombre */
}

.user-icon {
    width: 36px; /* <-- Tamaño del círculo del ícono (más pequeño) */
    height: 36px;
    border-radius: 50%;
    background-color: #e4e6eb;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0; /* Evita que el ícono se encoja */
}

.user-icon svg {
    width: 20px; /* <-- Tamaño del ícono SVG (más pequeño) */
    height: 20px;
    fill: var(--text-muted);
}

.username {
    font-weight: 600;
    color: var(--text-color);
    font-size: 1em; /* Un poco más pequeño para elegancia */
    /* Estas propiedades evitan que un nombre muy largo rompa el diseño */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Estilos para Gestión de Contactos (Buscador, Botones, Paginador) --- */

.form-container {
    max-width: 700px; /* <-- ESTA ES LA LÍNEA NUEVA */
    background-color: var(--content-bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
}
.form-container input, .form-container button {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
}
.form-container button {
    background-color: var(--accent-green);
    color: white;
    cursor: pointer;
    font-weight: 600;
}
.error { background-color: #ffebe6; color: #d92b00; border: 1px solid #ffc2b3; }
.success { background-color: #e6ffed; color: #006421; border: 1px solid #b3ffc8; }
.template-link { display: inline-block; margin-top: 10px; color: var(--text-muted); }

.search-form {
    display: flex;
    gap: 10px;
}
.search-form input {
    flex-grow: 1;
    margin: 0;
}
.search-form button, .clear-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.search-form button {
    background-color: var(--accent-blue);
    color: white;
}
.clear-btn {
    background-color: #6c757d;
    color: white;
    display: flex;
    align-items: center;
}

.action-btn {
    display: inline-block;
    padding: 5px 10px;
    font-size: 0.9em;
    border-radius: 4px;
    color: white;
    text-align: center;
    margin-right: 5px;
}
.action-btn.toggle {
    background-color: #f0ad4e;
}
.action-btn.delete {
    background-color: var(--accent-red);
}

.pagination {
    margin-top: 20px;
    text-align: center;
}
.pagination a {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 4px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
}
.pagination a:hover {
    background-color: #e9ecef;
    text-decoration: none;
}
.pagination a.active {
    background-color: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    font-weight: bold;
}

/* --- Estilos para las Etiquetas de Estado --- */

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 0.85em;
    font-weight: 600;
    border-radius: 15px; /* Píldora redondeada */
    text-transform: capitalize;
}

/* Color para el estado Activo/Suscrito */
.status-badge.status-subscribed {
    background-color: #e6ffed; /* Fondo verde claro */
    color: #006421; /* Texto verde oscuro */
    border: 1px solid #b3ffc8;
}

/* Color para el estado Desactivado/No Suscrito */
.status-badge.status-unsubscribed {
    background-color: #ffebee; /* Fondo rojo claro */
    color: #c62828; /* Texto rojo oscuro */
    border: 1px solid #ffcdd2;
}

/* Estilos para estados de conversaciones */
.status-open {
    color: #2e7d32; /* Verde para conversaciones abiertas */
    font-weight: bold;
}

.status-closed {
    color: #757575; /* Gris para conversaciones cerradas */
}

.status-active {
    color: #1976d2; /* Azul para conversaciones activas */
    font-weight: bold;
}


/* --- Estilos Mejorados para Formularios --- */

.form-group {
    margin-bottom: 20px; /* Crea espacio vertical entre cada campo */
}

.form-container label {
    display: block; /* Asegura que la etiqueta esté en su propia línea */
    font-weight: 600;
    margin-bottom: 8px; /* Espacio entre la etiqueta y el campo */
    font-size: 0.9em;
    color: var(--text-muted);
}

/* Estilo unificado para todos los campos de texto y textarea */
.form-container input[type="text"],
.form-container textarea {
    width: 100%;
    padding: 12px;
    background-color: var(--content-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box; /* Previene que el padding afecte el ancho */
    font-size: 1em;
    transition: border-color 0.2s;
}

.form-container input[type="text"]:focus,
.form-container textarea:focus {
    border-color: var(--accent-blue); /* Resalta el campo al hacer clic */
    outline: none;
}

/* Estilo para el campo de subir archivo */
.form-container input[type="file"] {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
}


/* --- Estilos para los Estados de Campaña --- */
.status-badge.status-draft,
.status-badge.status-paused {
    background-color: #e9ecef;
    color: #6c757d;
    border: 1px solid #ced4da;
}
.status-badge.status-scheduled,
.status-badge.status-sending {
    background-color: #e7f3ff;
    color: var(--accent-blue);
    border: 1px solid #b3d7ff;
}
.status-badge.status-sent {
    background-color: #e6ffed;
    color: #006421;
    border: 1px solid #b3ffc8;
}

/* --- Estilos para el Centro de Procesadores --- */
.processors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px; /* Reducido de 30px a 25px */
    margin-top: 10px; /* Reduce espacio superior */
    margin-left: 0; /* Sin margen izquierdo adicional */
    max-width: 100%; /* Evita que se extienda demasiado */
}
.processor-card {
    background-color: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}
.processor-card.paused .status-indicator {
    background-color: #6c757d; /* Gris para pausado */
}
.processor-card.running .status-indicator {
    background-color: var(--accent-green); /* Verde para activo */
    animation: pulse 2s infinite;
}
.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}
.card-body {
    display: flex;
    gap: 15px;
    padding: 20px;
    min-height: 150px;
}
.robot-icon {
    font-size: 3em;
    opacity: 0.5;
}
.log-output {
    font-family: monospace;
    font-size: 0.9em;
    color: var(--text-muted);
}
.log-output p { margin: 0 0 5px 0; }
.card-footer {
    background-color: #F5F6F7;
    padding: 15px;
    text-align: right;
    border-top: 1px solid var(--border-color);
}
.control-btn {
    display: inline-block;
    background-color: var(--accent-blue);
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 600;
}
.processor-card.running .control-btn {
    background-color: var(--accent-red); /* Botón rojo para pausar */
}

.action-btn.resume {
    background-color: var(--accent-green);
}

.action-btn.resend {
    background-color: #2a55e2; /* Un color azul claro/cian */
    white-space: nowrap; /* Evita que el texto del botón se parta en dos líneas */
}

/* --- Estilos para Filtros y Buscador --- */
.search-form select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--content-bg);
    color: var(--text-color);
    font-weight: 600;
}

/* --- Estilos para Filtros Avanzados y Acciones en Lote --- */
.search-form {
    align-items: center; /* Alinea los elementos verticalmente */
}
.filter-input {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--content-bg);
    color: var(--text-color);
}
.batch-actions {
    margin-top: 20px;
}
.batch-actions button {
    background-color: var(--accent-blue);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
}


/* --- FIN DE LAS CLASES CORREGIDAS PARA EL LOGIN --- */