/* === OMNITOK DASHBOARD - ESTILOS PRINCIPALES === */

/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Clases utilitarias para seguridad CSP */
.hidden {
    display: none !important;
}

/* Variables CSS para manipulación segura de estilos */
:root {
    --login-btn-min-width: auto;
}

.login-btn {
    min-width: var(--login-btn-min-width, auto);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

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

/* Login Form - Diseño Moderno */
#loginForm {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

/* Fondo animado */
#loginForm::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.3) 0%, transparent 50%);
    animation: backgroundMove 20s ease-in-out infinite;
}

@keyframes backgroundMove {
    0%, 100% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(-20px) translateY(-10px); }
    50% { transform: translateX(20px) translateY(10px); }
    75% { transform: translateX(-10px) translateY(20px); }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 50px 40px;
    border-radius: 24px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    animation: cardSlideIn 0.8s ease-out;
    width: 100%;
    max-width: 450px;
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2, #f093fb, #f5576c);
    background-size: 300% 100%;
    animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    animation: logoFloat 3s ease-in-out infinite;
}

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

.login-header h1 {
    color: #333;
    margin-bottom: 8px;
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: #666;
    font-size: 16px;
    font-weight: 400;
}

.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-container {
    position: relative;
}

.form-group input {
    width: 100%;
    padding: 16px 20px 16px 50px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 18px;
    transition: color 0.3s ease;
}

.form-group input:focus + .input-icon {
    color: #667eea;
}

.login-btn {
    width: 100%;
    min-width: 200px;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.login-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.login-btn:hover::before {
    left: 100%;
}

.login-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

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

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.login-btn:disabled::before {
    display: none;
}

.error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
    padding: 16px 20px;
    border-radius: 12px;
    margin-top: 20px;
    border: 1px solid #fca5a5;
    display: none;
    font-weight: 500;
    animation: errorShake 0.5s ease-in-out;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Spinner específico para el botón de login */
.btn-loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Dashboard */
#dashboard {
    display: block;
}

#dashboard.hidden {
    display: none !important;
}

.dashboard-header {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.dashboard-title {
    flex: 1;
}

.dashboard-title h1 {
    color: #333;
    margin-bottom: 4px;
    font-size: 20px;
}

.dashboard-title p {
    color: #666;
    font-size: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.user-name {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.user-role {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.user-instances {
    color: #666;
    font-size: 14px;
}

.logout-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.logout-btn:hover {
    background: #dc2626;
}

.controls-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.instance-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.instance-selector label {
    color: rgba(255,255,255,0.9);
    font-size: 14px;
    font-weight: 500;
}

.instance-select {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.instance-select:hover {
    background: rgba(255,255,255,0.2);
}

.instance-select option {
    background: #333;
    color: white;
}

.last-update {
    color: rgba(255,255,255,0.8);
    font-size: 14px;
}

.control-buttons {
    display: flex;
    gap: 10px;
}

.control-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.refresh-btn {
    background: #10b981;
    color: white;
}

.refresh-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}

.toggle-btn {
    background: #6b7280;
    color: white;
}

.toggle-btn:hover {
    background: #4b5563;
    transform: translateY(-1px);
}

.toggle-btn.active {
    background: #f59e0b;
}

.control-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Instance Cards */
.instances-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.instance-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: transform 0.3s;
}

.instance-card:hover {
    transform: translateY(-2px);
}

.instance-header {
    background: #f8fafc;
}

.instance-header h2 {
    padding: 12px 16px;
    margin: 0 0 10px 0;
    font-size: 18px;
    color: #333;
}

.instance-stats,
.agents-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

.stat,
.agent-stat {
    text-align: center;
    padding: 16px 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.stat:hover,
.agent-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.stat-icon,
.agent-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 4px;
}

.stat-number,
.agent-stat-number {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.stat-label,
.agent-stat-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Colores unificados para ambas vistas */
.stat.total .stat-number,
.agent-stat.total .agent-stat-number { color: #374151; }
.stat.total .stat-icon,
.agent-stat.total .agent-stat-icon { background: #f3f4f6; color: #374151; }

.stat.connected .stat-number,
.stat.online .stat-number,
.agent-stat.connected .agent-stat-number,
.agent-stat.online .agent-stat-number { color: #10b981; }
.stat.connected .stat-icon,
.stat.online .stat-icon,
.agent-stat.connected .agent-stat-icon,
.agent-stat.online .agent-stat-icon { background: #ecfdf5; color: #10b981; }

.stat.disconnected .stat-number,
.stat.offline .stat-number,
.agent-stat.disconnected .agent-stat-number,
.agent-stat.offline .agent-stat-number { color: #ef4444; }
.stat.disconnected .stat-icon,
.stat.offline .stat-icon,
.agent-stat.disconnected .agent-stat-icon,
.agent-stat.offline .agent-stat-icon { background: #fef2f2; color: #ef4444; }

.stat.in-chat .stat-number,
.stat.with-chats .stat-number,
.agent-stat.in-chat .agent-stat-number,
.agent-stat.with-chats .agent-stat-number { color: #8b5cf6; }
.stat.in-chat .stat-icon,
.stat.with-chats .stat-icon,
.agent-stat.in-chat .agent-stat-icon,
.agent-stat.with-chats .agent-stat-icon { background: #f5f3ff; color: #8b5cf6; }

.stat.active-chats .stat-number,
.agent-stat.active-chats .agent-stat-number { color: #f59e0b; }
.stat.active-chats .stat-icon,
.agent-stat.active-chats .agent-stat-icon { background: #fffbeb; color: #f59e0b; }

/* Navegación entre vistas */
.view-navigation {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 0 4px;
}

.view-btn {
    padding: 12px 20px;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 10px;
    color: #6b7280;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.view-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.view-btn:hover {
    border-color: #9ca3af;
    color: #374151;
    transform: translateY(-1px);
}

.view-btn:hover::before {
    left: 100%;
}

.view-btn.active {
    border-color: #10b981;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.view-btn.active::before {
    display: none;
}

/* Contenedores de vista */
.view-content {
    display: none;
}

.view-content.active {
    display: block;
}

/* Vista de Agentes */
.agents-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.agents-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: 1px solid #e5e7eb;
}

.agents-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.agents-subtitle {
    font-size: 14px;
    opacity: 0.9;
}

/* === ESTILOS HOMOLOGADOS PARA VISTA DE AGENTES === */

/* Header de contenido unificado */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: 1px solid #e5e7eb;
}

.instance-info h2.instance-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.instance-subtitle {
    font-size: 14px;
    opacity: 0.9;
}

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

.header-actions .refresh-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-actions .refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* Estilos para toggle en header */
.header-actions .filters-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-actions .filter-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.header-actions .toggle-checkbox {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    transition: background-color 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.header-actions .toggle-switch {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.header-actions .filter-toggle.active .toggle-checkbox {
    background: rgba(16, 185, 129, 0.8);
    border-color: rgba(16, 185, 129, 0.9);
}

.header-actions .filter-toggle.active .toggle-switch {
    transform: translateX(20px);
}

.header-actions .toggle-label {
    font-size: 14px;
    color: white;
    font-weight: 500;
    opacity: 0.9;
}

/* Grid de KPIs unificado */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    padding: 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

.kpi-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    gap: 16px;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: #f3f4f6;
    color: #374151;
}

.kpi-content {
    flex: 1;
}

.kpi-number {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Colores de KPI */
.kpi-card.online .kpi-icon { background: #ecfdf5; color: #10b981; }
.kpi-card.online .kpi-number { color: #10b981; }

.kpi-card.offline .kpi-icon { background: #fef2f2; color: #ef4444; }
.kpi-card.offline .kpi-number { color: #ef4444; }

.kpi-card.with-chats .kpi-icon { background: #f5f3ff; color: #8b5cf6; }
.kpi-card.with-chats .kpi-number { color: #8b5cf6; }

.kpi-card.active-chats .kpi-icon { background: #fffbeb; color: #f59e0b; }
.kpi-card.active-chats .kpi-number { color: #f59e0b; }

/* Controles de contenido */
.content-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 16px;
}

.search-section {
    flex: 1;
    min-width: 300px;
}

.search-wrapper {
    position: relative;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 16px;
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filters-section {
    display: flex;
    gap: 16px;
}

/* Toggle switch mejorado */
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.toggle-checkbox {
    position: relative;
    width: 44px;
    height: 24px;
    background: #d1d5db;
    border-radius: 12px;
    transition: background-color 0.3s;
}

.toggle-switch {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.filter-toggle.active .toggle-checkbox {
    background: #10b981;
}

.filter-toggle.active .toggle-switch {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
}

/* Lista de contenido */
.content-list {
    padding: 20px;
}

/* Grid de agentes mejorado */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

/* Cards de agentes mejoradas */
.agent-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    border-left: 4px solid #e5e7eb;
}

.agent-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.agent-card.online {
    border-left-color: #10b981;
}

.agent-card.offline {
    border-left-color: #ef4444;
}

/* Header del agente */
.agent-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.agent-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.agent-main-info {
    flex: 1;
    min-width: 0;
}

.agent-name {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-username {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.agent-status-text {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agent-status-text.online {
    color: #10b981;
}

.agent-status-text.offline {
    color: #ef4444;
}

/* Departamentos del agente */
.agent-departments {
    margin-bottom: 16px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
}

.departments-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    flex-wrap: wrap;
}

.chats-indicator {
    color: #8b5cf6;
    font-weight: 700;
    font-size: 11px;
}

.departments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.department-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e5e7eb;
    color: #374151;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    max-width: 140px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.department-badge.with-chats {
    background: #ddd6fe;
    color: #7c3aed;
    border-color: #a78bfa;
    box-shadow: 0 1px 3px rgba(124, 58, 237, 0.15);
}

.department-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.dept-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.chat-indicator {
    background: #8b5cf6;
    color: white;
    padding: 2px 5px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.no-departments {
    color: #9ca3af;
    font-style: italic;
    font-size: 12px;
}

/* Nueva grid compacta para agentes */
.agents-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(520px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

/* Tarjetas compactas de agentes */
.agent-card-compact {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    transition: all 0.2s ease;
    min-height: 60px;
    gap: 14px;
}

.agent-card-compact:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.agent-card-compact.online {
    border-left: 4px solid #10b981;
    background: #f0fdf4;
}

.agent-card-compact.offline {
    border-left: 4px solid #ef4444;
    background: #fef2f2;
}

/* Avatar compacto */
.agent-avatar-compact {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

/* Info del agente compacta */
.agent-info-compact {
    flex-shrink: 0;
    min-width: 120px;
    max-width: 160px;
    width: 160px;
}

.agent-name-compact {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.agent-status-compact {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agent-status-compact.online {
    color: #10b981;
}

.agent-status-compact.offline {
    color: #ef4444;
}

/* Departamentos compactos */
.agent-departments-compact {
    flex: 1;
    min-width: 0;
}

.departments-title {
    font-size: 10px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.departments-text {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.3;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chats-count {
    font-size: 11px;
    color: #8b5cf6;
    font-weight: 600;
}

/* Stats del agente */
.agent-stats {
    display: flex;
    gap: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: #f8fafc;
    border-radius: 8px;
    flex: 1;
    text-align: center;
}

.stat-item.active {
    background: #f5f3ff;
    color: #8b5cf6;
}

.stat-item.busy {
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fbbf24;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #374151;
}

.stat-item.active .stat-value {
    color: #8b5cf6;
}

.stat-item.busy .stat-value {
    color: #d97706;
}

.stat-label {
    font-size: 10px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Estados especiales */
.empty-state,
.error-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.empty-icon,
.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-title,
.error-title {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.empty-description,
.error-description {
    font-size: 14px;
    margin-bottom: 20px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.clear-search-btn,
.retry-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.clear-search-btn:hover,
.retry-btn:hover {
    background: #5a67d8;
}

/* Lista de agentes original (vista departamentos) */
.agents-list {
    padding: 20px;
}

.agents-search {
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s;
    position: relative;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-container {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 16px;
}

/* Lista de agentes más compacta */
.agents-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.agent-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    transition: all 0.2s ease;
    height: 64px;
}

.agent-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.agent-item.online {
    border-left: 3px solid #10b981;
}

.agent-item.offline {
    border-left: 3px solid #ef4444;
}

.agent-item.hidden {
    display: none;
}

.agent-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    margin-right: 12px;
    flex-shrink: 0;
}

.agent-details {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.agent-info {
    flex: 1;
    min-width: 0;
}

.agent-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-status {
    font-size: 12px;
    margin: 0;
}

.agent-status.online {
    color: #10b981;
}

.agent-status.offline {
    color: #ef4444;
}

.agent-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}

/* Departamentos compactos */
.agent-departments {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    max-width: 120px;
}

.department-badge {
    background: #f3f4f6;
    color: #374151;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
}

.department-badge.with-chats {
    background: #ddd6fe;
    color: #7c3aed;
}

/* Chat count compacto */
.agent-chat-count {
    background: #8b5cf6;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.agent-dept-count {
    background: #6b7280;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

/* Filtros compactos */
.agents-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #6b7280;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.filter-toggle:hover {
    color: #374151;
}

.filter-checkbox {
    width: 16px;
    height: 16px;
    border: 2px solid #d1d5db;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    transition: all 0.2s;
}

.filter-toggle.active .filter-checkbox {
    background: #667eea;
    border-color: #667eea;
}

.filter-toggle.active .filter-checkbox::after {
    content: '✓';
    color: white;
    font-size: 10px;
    font-weight: bold;
}

/* Sistema de notificaciones moderno */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    max-width: 400px;
    pointer-events: none;
}

.notification {
    pointer-events: auto;
}

.notification {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #e5e7eb;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideInRight 0.3s ease-out;
    max-width: 100%;
    word-wrap: break-word;
}

.notification.success {
    border-left-color: #10b981;
}

.notification.warning {
    border-left-color: #f59e0b;
}

.notification.error {
    border-left-color: #ef4444;
}

.notification.info {
    border-left-color: #3b82f6;
}

.notification-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 12px;
}

.notification.success .notification-icon {
    background: #ecfdf5;
    color: #10b981;
}

.notification.warning .notification-icon {
    background: #fef3c7;
    color: #f59e0b;
}

.notification.error .notification-icon {
    background: #fef2f2;
    color: #ef4444;
}

.notification.info .notification-icon {
    background: #eff6ff;
    color: #3b82f6;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 4px 0;
    line-height: 1.2;
}

.notification-message {
    font-size: 14px;
    color: #1f2937;
    margin: 0;
    line-height: 1.4;
}

.notification-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    margin: -2px 0 0 8px;
    transition: color 0.2s;
}

.notification-close:hover {
    color: #6b7280;
}

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

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

.notification.removing {
    animation: slideOutRight 0.3s ease-in forwards;
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .agents-list-container {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .agents-grid-compact {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .agent-item {
        height: 56px;
        padding: 6px 10px;
    }
    
    .agent-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
        margin-right: 10px;
    }
    
    .agent-name {
        font-size: 13px;
    }
    
    .agent-status {
        font-size: 11px;
    }
    
    .agent-chat-count,
    .agent-dept-count {
        font-size: 9px;
        padding: 1px 4px;
        min-width: 16px;
    }
    
    .agents-filters {
        gap: 8px;
    }
    
    .filter-toggle {
        font-size: 13px;
    }
    
    .notifications-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .notification {
        padding: 12px;
    }
    
    .notification-title {
        font-size: 13px;
    }
    
    .notification-message {
        font-size: 12px;
    }
}

.departments-container {
    padding: 12px 16px;
}

.department {
    margin-bottom: 16px;
}

.department:last-child {
    margin-bottom: 0;
}

.department h3 {
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    padding-bottom: 4px;
    border-bottom: 1px solid #e5e7eb;
}

.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

.agent-card {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s;
}

.agent-card.available {
    border-color: #10b981;
    background: #f0fdf4;
}

.agent-card.disconnected {
    border-color: #ef4444;
    background: #fef2f2;
}

.agent-card.in-chat {
    border-color: #8b5cf6;
    background: #f5f3ff;
}

.agent-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    margin-right: 8px;
    flex-shrink: 0;
}

.agent-info {
    flex: 1;
    min-width: 0;
}

.agent-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-status {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agent-chats {
    font-size: 10px;
    color: #10b981;
    font-weight: 600;
    margin-top: 2px;
}

.no-agents {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
    border: 2px dashed #d1d5db;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    text-align: center;
    color: rgba(255,255,255,0.95);
    font-size: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 20px;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    text-align: center;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin: 20px;
    border: 1px solid rgba(102, 126, 234, 0.1);
    min-height: 300px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.loading-text {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.loading-subtitle {
    font-size: 14px;
    color: #6b7280;
    font-weight: 400;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading específico para vista de agentes */
.agents-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    text-align: center;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin: 20px;
    min-height: 400px;
}

.agents-loading .loading-spinner {
    width: 56px;
    height: 56px;
    border-width: 5px;
    border-color: rgba(16, 185, 129, 0.2);
    border-top-color: #10b981;
}

.error-card {
    border-left-color: #ef4444 !important;
}

.error-message {
    color: #ef4444;
    font-weight: 500;
}

/* Paginación - Estilos unificados y mejorados */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: 20px 0 0 0;
    padding: 18px 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(102, 126, 234, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 14px;
    color: #6b7280;
    font-weight: 600;
    text-align: center;
    margin: 0;
    padding: 8px 12px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.1);
    order: 0;
    flex: 1;
    min-width: 200px;
}

.pagination-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    position: relative;
    overflow: hidden;
}

.pagination-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
    z-index: 1;
}

.pagination-btn:hover:not(:disabled)::after {
    left: 100%;
}

.pagination-btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.pagination-btn:active:not(:disabled) {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.pagination-btn:disabled {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pagination-btn:disabled::after {
    display: none;
}

.departments-pagination {
    display: flex;
    flex-direction: column;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .login-container {
        padding: 15px;
        min-height: 100vh;
    }

    .login-card {
        padding: 30px 20px;
        border-radius: 16px;
        margin: auto;
    }

    .login-logo {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }

    .login-header h1 {
        font-size: 24px;
    }

    .form-group input {
        padding: 14px 16px 14px 45px;
    }

    .input-icon {
        left: 14px;
        font-size: 16px;
    }

    .dashboard-header {
        flex-direction: column;
        text-align: center;
    }

    .user-info {
        justify-content: center;
    }

    .controls-section {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .controls-left {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .instance-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }

    .instance-select {
        width: 100%;
    }

    .control-buttons {
        justify-content: center;
    }

    .instances-grid {
        grid-template-columns: 1fr;
    }

    .instance-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .agents-grid {
        grid-template-columns: 1fr;
    }

    /* Mobile: Vista de Agentes */
    .view-navigation {
        flex-direction: column;
        gap: 8px;
    }

    .view-btn {
        padding: 12px 16px;
        font-size: 14px;
    }

    .agents-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px 16px;
    }

    .agent-stat-number {
        font-size: 20px;
    }

    .agents-list {
        padding: 12px;
    }

    .agent-item {
        padding: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .agent-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
        margin-right: 0;
        align-self: flex-start;
    }

    .agent-details {
        width: 100%;
    }

    .agent-departments {
        margin-bottom: 12px;
    }

    .department-badge {
        font-size: 11px;
        padding: 3px 6px;
    }

    .search-input {
        padding: 10px 14px 10px 36px;
        font-size: 14px;
    }

    .pagination-container {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
        margin: 16px 0 0 0;
        justify-content: center;
    }

    .pagination-info {
        order: -1;
        text-align: center;
        font-size: 13px;
        margin: 0;
        min-width: auto;
        flex: none;
    }
}

/* === CLASES PARA ELEMENTOS INLINE === */

/* Estilo para el badge "beta" del título principal */
.beta-badge {
    font-size: 0.5em !important; 
    color: #10b981 !important; 
    padding: 2px 4px !important; 
    border-radius: 4px !important; 
    font-weight: 800 !important; 
    font-style: italic !important; 
    vertical-align: super !important; 
    margin-left: 10px !important; 
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important; 
    display: inline-block !important; 
    letter-spacing: 0.5px !important; 
    font-family: 'Arial', sans-serif !important; 
    border: 2px solid #10b981 !important;
}

/* Estilo para el badge "BETA" del dashboard */
.dashboard-beta-badge {
    font-size: 0.4em !important; 
    background: linear-gradient(135deg, #10b981, #059669) !important; 
    color: white !important; 
    padding: 2px 6px !important; 
    border-radius: 4px !important; 
    font-weight: 500 !important; 
    vertical-align: super !important; 
    margin-left: 8px !important;
}

