/* 
 * WhatsApp Bot Manager - Estilos CSS
 * Fecha: 13 de noviembre de 2025
 */

:root {
    --primary-color: #25d366;
    --secondary-color: #128c7e;
    --tertiary-color: #075e54;
    --accent-color: #dcf8c6;
    --dark-bg: #1f2937;
    --light-bg: #f9fafb;
    --border-color: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
}

/* Ajuste global: reducir tamaño de letra base en toda la app */
html {
    font-size: 14px; /* Default 16px -> 14px para fuentes más pequeñas */
}

/* Ajuste base para compatibilidad con rem */
body {
    font-size: 0.95rem;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR — diseño alineado con el login
   ═══════════════════════════════════════════════════════ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width, 270px);
    height: 100vh;
    background: linear-gradient(160deg, color-mix(in srgb, var(--brand-dark, #0d47a1) 80%, #000) 0%, var(--brand-dark, #0d47a1) 55%, var(--brand, #1565c0) 100%);
    color: white;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.28s ease, box-shadow 0.28s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
}

/* Círculos decorativos (igual que login) */
.sidebar::before,
.sidebar::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    pointer-events: none;
    animation: sb-float 9s ease-in-out infinite;
}
.sidebar::before {
    width: 260px; height: 260px;
    bottom: -80px; right: -80px;
    animation-delay: 0s;
}
.sidebar::after {
    width: 160px; height: 160px;
    top: -50px; left: -50px;
    animation-delay: 4s;
}
@keyframes sb-float {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}

/* ── Cabecera ─────────────────────────────────────────── */
.sidebar-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(4px);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

/* ── Lista de menú ────────────────────────────────────── */
.sidebar-menu {
    list-style: none;
    padding: 6px 0;
    margin: 0;
    flex: 1;
    position: relative;
    z-index: 1;
}

.sidebar-menu li {
    border-bottom: none;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    margin: 2px 10px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.80);
    text-decoration: none;
    font-size: 0.88rem;
    transition: background 0.2s, color 0.2s, transform 0.18s;
    position: relative;
    overflow: hidden;
}

.sidebar-menu .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.13);
    transform: translateX(3px);
}

.sidebar-menu .nav-link.active {
    color: var(--cat-color, var(--brand-dark, #0d47a1));
    background: color-mix(in srgb, var(--cat-color, #fff) 10%, #fff);
    font-weight: 700;
    font-size: 0.93rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    transform: translateX(4px);
    border-left: 4px solid var(--cat-color, var(--brand, #1565c0));
}

.sidebar-menu .nav-link i {
    margin-right: 10px;
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

/* ── Etiquetas de categoría ───────────────────────────── */
.sidebar-menu li.sidebar-section {
    border-bottom: none;
    padding: 10px 30px 6px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.65);
    pointer-events: auto;
    cursor: pointer;
    display: block;
    text-align: center;
    position: relative;
    z-index: 1;
    border-radius: 6px;
    border-left: 3px solid transparent;
    margin: 4px 8px 0;
    transition: background .15s, color .15s, border-color .15s;
}
.sidebar-menu li.sidebar-section:hover { color: rgba(255,255,255,.9); background: rgba(255,255,255,.07); }
.sidebar-menu li.sidebar-section.has-active {
    border-left-color: var(--cat-color, rgba(255,255,255,.7));
    background: rgba(255,255,255,.1);
    color: #fff;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
}
.sidebar-menu li.sidebar-section .sb-cat-label { display:inline-flex; align-items:center; gap:4px; }
.sidebar-menu li.sidebar-section::after { display: none; }

/* ── Badge dentro de un item ──────────────────────────── */
.sidebar-menu .nav-link .sidebar-badge {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.68rem;
    padding: 0.1rem 0.34rem;
    border-radius: 999px;
    line-height: 1;
}

/* ── Divisor ──────────────────────────────────────────── */
.sidebar-divider {
    margin: 8px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

/* ── Logout ───────────────────────────────────────────── */
.sidebar-menu .logout-link {
    color: rgba(255, 255, 255, 0.65);
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.25);
}

.sidebar-menu .logout-link:hover {
    color: #fff;
    background: rgba(220, 53, 69, 0.22);
    border-color: rgba(220, 53, 69, 0.45);
    transform: translateX(3px);
}

/* ── Usuario al pie ───────────────────────────────────── */
.sidebar-user {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.sidebar-user-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.48);
    text-transform: uppercase;
    letter-spacing: 0.09em;
}

/* ── Scrollbar ────────────────────────────────────────── */
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.35); }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width, 270px);
    min-height: 100vh;
    transition: margin-left 0.28s ease;
}

/* Responsive: ver bloque unificado al final del archivo */
.content-header {
    background: white;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.content-header h1 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

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

/* Nuevo badge de estado mejorado */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    transition: all 0.3s ease;
}

.status-badge:hover {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

.status-dot.status-online {
    background-color: #fff;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 1);
}

@keyframes pulse-dot {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(255, 255, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

.status-text {
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.025em;
}

/* Backward compatibility - mantener el antiguo */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-indicator.online {
    color: var(--success-color);
}

.status-indicator i {
    font-size: 0.7rem;
    animation: pulse 2s infinite;
}

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

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease;
}

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

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

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    border: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

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

.card-header {
    background: var(--light-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 12px 12px 0 0;
}

.card-header h5 {
    margin: 0;
    color: var(--text-primary);
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Stat Cards */
.card-stat {
    border-radius: 12px;
    border: none;
    transition: all 0.3s ease;
}

.card-stat:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card-stat-title {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 5px;
}

.card-stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 10px 20px;
    transition: all 0.3s ease;
    border: none;
    position: relative;
    overflow: hidden;
}

.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;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--brand, #1565c0), var(--brand-dark, #0d47a1));
    color: white;
    border-color: transparent;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--brand-dark, #0d47a1), var(--brand, #1565c0));
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px color-mix(in srgb, var(--brand, #1565c0) 40%, transparent);
}

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

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

.btn-danger {
    background: var(--error-color);
}

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

/* Forms */
.form-control {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 15px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.form-control:focus {
    border-color: var(--brand, var(--primary-color));
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--brand, #1565c0) 22%, transparent);
    outline: none;
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Tables */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    background: var(--light-bg);
    color: var(--text-primary);
    font-weight: 600;
    border: none;
}

/* Menu options UI tweaks */
.menu-option-item h6 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-option-item .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

.table td.text-nowrap {
    white-space: nowrap;
}

/* Ensure action buttons are always visible and don't wrap */
.table td .d-flex {
    align-items: center;
    justify-content: flex-end;
}

.table td {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: color-mix(in srgb, var(--brand, #1565c0) 6%, transparent);
}

/* Badges */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

.badge-danger {
    background: var(--error-color);
    color: white;
}

.badge-info {
    background: var(--info-color);
    color: white;
}

.badge-secondary {
    background: var(--text-secondary);
    color: white;
}

/* Modal Fallback Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1055;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}

.modal.show {
    display: block !important;
}

.modal-dialog {
    position: relative;
    width: auto;
    margin: 1.75rem auto;
    max-width: 500px;
}

.modal-content {
    background: white;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1rem;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* Menu Tree */
.menu-tree {
    list-style: none;
    padding-left: 0;
}

.menu-tree li {
    margin-bottom: 10px;
}

.menu-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: between;
    align-items: center;
    transition: all 0.3s ease;
}

.menu-item:hover {
    border-color: var(--brand, var(--primary-color));
    background: color-mix(in srgb, var(--brand, #1565c0) 5%, transparent);
}

.menu-item.root {
    border-left: 4px solid var(--brand, var(--primary-color));
}

.menu-item.child {
    margin-left: 20px;
    border-left: 4px solid var(--info-color);
}

/* Recent conversations */
.recent-message {
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid var(--brand, var(--primary-color));
    background: color-mix(in srgb, var(--brand, #1565c0) 5%, transparent);
}

.recent-message .time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.recent-message .content {
    font-size: 0.9rem;
    margin-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Alerts */
.alert {
    border: none;
    border-radius: 8px;
    padding: 15px 20px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--success-color);
    color: var(--success-color);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid var(--warning-color);
    color: var(--warning-color);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--error-color);
    color: var(--error-color);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--info-color);
    color: var(--info-color);
}

/* Chat Interface */
.chat-container {
    height: 400px;
    overflow-y: auto;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 15px;
}

.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
}

.message.incoming {
    justify-content: flex-start;
}

.message.outgoing {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 18px;
    position: relative;
}

.message.incoming .message-bubble {
    background: white;
    border-bottom-left-radius: 4px;
}

.message.outgoing .message-bubble {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 5px;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — breakpoints unificados
   ═══════════════════════════════════════════════════════ */

/* ── Móvil (< 576px) ───────────────────────────────── */
@media (max-width: 575.98px) {
    .content-header {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .content-header h1 {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(100vw - 80px);
    }
    .content-header small {
        font-size: .72rem;
    }
    .header-actions {
        width: 100%;
        gap: 6px;
        flex-wrap: wrap;
    }
    .header-actions .btn {
        padding: 6px 10px;
        font-size: .8rem;
    }
    .tab-content {
        padding: 12px 10px;
    }
    .card-body {
        padding: 12px;
    }
    .card-stat-number {
        font-size: 1.6rem;
    }
    /* Tablas: scroll horizontal */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    .table th,
    .table td {
        padding: 8px 10px;
        font-size: .8rem;
    }
    /* Ocultar columnas secundarias de tabla en móvil muy pequeño */
    .table .d-xs-none { display: none !important; }
    /* Botones de acción en tablas: solo iconos */
    .table td .btn-sm {
        padding: 4px 6px;
        font-size: .75rem;
    }
    .table td .btn-sm span,
    .table td .btn-sm .btn-text { display: none; }
    /* Cards de estadísticas: 2 por fila */
    .row > [class*='col-xl-3'] {
        flex: 0 0 50%;
        max-width: 50%;
    }
    /* Modales: full width */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    /* Sidebar toggle: siempre visible */
    #sidebar-toggle { display: inline-flex !important; }
}

/* ── Tablet (576px – 991px) ────────────────────────── */
@media (min-width: 576px) and (max-width: 991.98px) {
    .content-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .content-header h1 {
        font-size: 1.15rem;
    }
    .header-actions {
        gap: 8px;
    }
    .tab-content {
        padding: 16px 14px;
    }
    .card-stat-number {
        font-size: 2rem;
    }
    .table th,
    .table td {
        padding: 10px 12px;
    }
    #sidebar-toggle { display: inline-flex !important; }
}

/* ── Móvil + Tablet: sidebar oculto / overlay ──────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: 270px;
        box-shadow: none;
    }
    .sidebar.open,
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0,0,0,.30);
        z-index: 1200;
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.40);
        z-index: 1100;
        display: none;
        backdrop-filter: blur(2px);
    }
    .status-badge { display: none !important; }
}

/* ── Desktop (>= 992px) ────────────────────────────── */
@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0) !important;
        width: var(--sidebar-width, 270px);
    }
    #sidebar-toggle { display: none !important; }
}


/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.d-flex { display: flex; }
.d-block { display: block; }
.d-none { display: none; }

.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.justify-content-end { justify-content: flex-end; }

.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--border-color);
}

::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 4px;
}

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

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.bounce {
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* Custom Components */
.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring__circle {
    stroke: var(--primary-color);
    stroke-linecap: round;
    transition: stroke-dasharray 0.35s;
}

.notification-dot {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 10px;
    height: 10px;
    background: var(--error-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* Print Styles */
@media print {
    .sidebar,
    .header-actions,
    .btn {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* =================================
   LAB SIDEBAR TOGGLE (mobile)
   ================================= */

/* El botón hamburguesa solo es visible en mobile/tablet */
.lab-sidebar-toggle {
    display: none !important;
    flex-shrink: 0;
    margin-right: 8px;
}

/* content-header cuando tiene el toggle: evitar desbordamiento del título */
.content-header.has-sidebar-toggle {
    gap: 8px;
    flex-wrap: nowrap;
}
.content-header.has-sidebar-toggle > div:nth-child(2) {
    min-width: 0;
    flex: 1;
}
.content-header.has-sidebar-toggle h1 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-size: clamp(.9rem, 2.5vw, 1.4rem);
}

@media (max-width: 991.98px) {
    .lab-sidebar-toggle { display: inline-flex !important; }
    .content-header.has-sidebar-toggle { padding: 10px 12px; }
    /* Evitar que el body haga scroll horizontal cuando el sidebar está abierto */
    body.sidebar-open { overflow: hidden; }
    /* Contenedores con padding excesivo en móvil */
    .container-fluid { padding-left: 10px !important; padding-right: 10px !important; }
}

@media (max-width: 575.98px) {
    /* Cards de lab en 2 columnas en móvil pequeño */
    .col-md-3, .col-xl-3, .col-lg-3 { flex: 0 0 50%; max-width: 50%; }
    /* Tablas lab: texto más pequeño */
    .table th, .table td { font-size: .78rem; padding: 7px 8px; }
    /* Header sub-info en móvil */
    .content-header small { font-size: .7rem; }
    /* Botón Nuevo en header: ocultar texto, solo icono */
    .content-header .btn-primary .me-1 ~ * { display: none; }
}

/* =================================
   CHAT STYLES 
   ================================= */

.chat-container {
    background: linear-gradient(135deg, #e5ddd5 0%, #d4c5b9 100%);
}

.conversation-row:hover {
    background-color: #f8f9fa !important;
    cursor: pointer;
}

.message-bubble {
    position: relative;
    word-wrap: break-word;
    border: none;
}

.message-bubble.outgoing {
    margin-left: auto;
}

.message-bubble.incoming {
    margin-right: auto;
}

.message-time {
    text-align: right;
    margin-top: 4px;
    font-size: 0.7rem;
}

.avatar-placeholder {
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
}

/* Modal de chat personalizado */
#chatModal .modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

#chatModal .modal-header {
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

#chatModal .modal-body {
    padding: 0;
}

.message-bubble.bg-success {
    background: linear-gradient(135deg, #25d366, #20b358) !important;
}

.message-bubble.bg-white {
    background: #ffffff !important;
    border: 1px solid #e9ecef;
}

/* Mejorar responsividad de conversaciones */
@media (max-width: 768px) {
    .conversation-row .btn-group .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .message-bubble {
        max-width: 85% !important;
    }
    
    #chatModal .modal-dialog {
        max-width: 95%;
        margin: 1rem auto;
    }
}

/* Animaciones para mensajes */
.message-bubble {
    animation: messageAppear 0.3s ease-out;
}

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

/* Estilos mejorados para lista de conversaciones */
.conversation-card {
    border: none;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    overflow: hidden;
}

.conversation-card .card-header {
    border: none;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    padding: 1.5rem;
}

.conversation-list {
    max-height: 600px;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background: white;
}

.conversation-item:hover {
    background: #f8f9fa;
    transform: translateX(5px);
}

.conversation-item:last-child {
    border-bottom: none;
}

.conversation-avatar {
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, #25d366, #128c7e);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.4rem;
    margin-right: 15px;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    position: relative;
}

.conversation-avatar.online::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #4ade80;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.conversation-details {
    flex: 1;
    min-width: 0;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.conversation-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 8px;
}

.conversation-time {
    font-size: 0.8rem;
    color: #9ca3af;
    white-space: nowrap;
}

.conversation-preview {
    display: flex;
    align-items: center;
    gap: 8px;
}

.conversation-last-message {
    color: #6b7280;
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.conversation-unread {
    background: #25d366;
    color: white;
    border-radius: 50%;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Unread conversation visual state: darker green and subtle background */
.conversation-item.unread {
    background: linear-gradient(90deg, #effff5, #f6fff9);
}
.conversation-item.unread .conversation-avatar {
    background: linear-gradient(135deg, #0f9a6a, #0b7a57);
    box-shadow: 0 6px 18px rgba(11, 122, 87, 0.25);
}

/* Conversation requiring advisor attention */
.conversation-item.attention {
    border-left: 4px solid #dc3545;
    background: rgba(220, 53, 69, 0.03);
}
.conversation-item.attention .conversation-avatar {
    box-shadow: 0 6px 18px rgba(220, 53, 69, 0.12);
}

.conversation-attention {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    font-size: 0.85rem;
}

.conversation-attention i {
    font-size: 0.9rem;
}

/* Notification bell indicator when there are unseen notifications */
#notification-bell.has-notifications {
    position: relative;
}
#notification-bell.has-notifications::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 12px;
    height: 12px;
    background: #15803d; /* darker green */
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.12);
    animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
    0% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.15); opacity: 0.6; }
    100% { transform: scale(1); opacity: 0.9; }
}

.conversation-status-icon {
    font-size: 0.8rem;
}

.conversation-status-icon.outgoing {
    color: #25d366;
}

.conversation-status-icon.incoming {
    color: #3b82f6;
}

.conversation-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.conversation-item:hover .conversation-actions {
    opacity: 1;
}

.conversation-actions .btn {
    padding: 6px 10px;
    font-size: 0.8rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #6b7280;
    transition: all 0.2s ease;
}

.conversation-actions .btn:hover {
    background: #25d366;
    color: white;
    border-color: #25d366;
    transform: translateY(-1px);
}

.conversation-empty {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
}

.conversation-empty .empty-icon {
    font-size: 4rem;
    color: #d1d5db;
    margin-bottom: 20px;
}

.conversation-search {
    border-radius: 25px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 20px;
}

.conversation-search::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.conversation-search:focus {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* ─────────────────────────────────────────────────────────────────────────
   MODO OSCURO
   Activación dual:
     1) @media (prefers-color-scheme: dark) — OS sin JS
     2) [data-bs-theme="dark"] en <html>   — Bootstrap 5.3 via script inline

   Bootstrap 5.3 maneja automáticamente (cuando data-bs-theme está activo):
   card, modal, table, form-control, form-select, dropdown, badge, alert,
   list-group, nav, pagination, offcanvas, toast, popover, etc.
   Aquí solo cubrimos variables custom y elementos no-Bootstrap.
───────────────────────────────────────────────────────────────────────── */

/* ── Variables custom para elementos no-Bootstrap ── */
@media (prefers-color-scheme: dark) {
    :root {
        --dm-body:   #0a1628;
        --dm-surf:   #071322;
        --dm-surf2:  #0b1c32;
        --dm-bdr:    #163240;
        --dm-txt:    #e6eef1;
        --dm-muted:  #9ca3af;
        --dm-link:   #a6f3c9;
        /* Alias compatibilidad con código que usa estas vars */
        --light-bg:       #071322;
        --text-primary:   #e6eef1;
        --text-secondary: #9ca3af;
        --border-color:   #163240;
    }
}
[data-bs-theme="dark"] {
    --dm-body:   #0a1628;
    --dm-surf:   #071322;
    --dm-surf2:  #0b1c32;
    --dm-bdr:    #163240;
    --dm-txt:    #e6eef1;
    --dm-muted:  #9ca3af;
    --dm-link:   #a6f3c9;
    --light-bg:       #071322;
    --text-primary:   #e6eef1;
    --text-secondary: #9ca3af;
    --border-color:   #163240;
}

/* ── Reglas para modo OS sin JS (fallback) ── */
@media (prefers-color-scheme: dark) {
    body { background-color: var(--dm-body); color: var(--dm-txt); }

    /* Fondo principal */
    .main-content { background-color: var(--dm-body) !important; }

    /* Bootstrap no cambia bg-white — forzamos adaptación */
    .bg-white { background-color: var(--dm-surf) !important; color: var(--dm-txt) !important; }

    /* Encabezados y texto */
    .content-header { background: var(--dm-surf); border-color: var(--dm-bdr) !important; color: var(--dm-txt); }
    .content-header h1, .card-header h5, .sidebar-header h4,
    .status-text, .status-indicator, .conversation-empty { color: var(--dm-txt) !important; }

    /* Componentes Bootstrap (fallback sin data-bs-theme) */
    .card { background: var(--dm-surf); color: var(--dm-txt); border-color: var(--dm-bdr); box-shadow: none; }
    .card-header { background: transparent; border-color: rgba(255,255,255,.06); }
    .form-control, .form-select {
        background: var(--dm-surf2);
        color: var(--dm-txt);
        border-color: var(--dm-bdr);
    }
    .form-control:focus, .form-select:focus {
        background: var(--dm-surf2);
        color: var(--dm-txt);
        border-color: #2d6a8a;
        box-shadow: 0 0 0 .2rem rgba(45,106,138,.25);
    }
    .table { color: var(--dm-txt); border-color: var(--dm-bdr); }
    .table th { background: var(--dm-surf2); color: var(--dm-txt); }
    .modal-content { background: var(--dm-surf); color: var(--dm-txt); }
    .modal-header, .modal-footer { border-color: var(--dm-bdr); }
    .dropdown-menu { background: var(--dm-surf); border-color: var(--dm-bdr); }
    .dropdown-item { color: var(--dm-txt); }
    .dropdown-item:hover { background: var(--dm-surf2); color: var(--dm-txt); }
    .list-group-item { background: var(--dm-surf); color: var(--dm-txt); border-color: var(--dm-bdr); }
    .input-group-text { background: var(--dm-surf2); color: var(--dm-txt); border-color: var(--dm-bdr); }
    .nav-tabs .nav-link { color: var(--dm-muted); }
    .nav-tabs .nav-link.active { background: var(--dm-surf); color: var(--dm-txt); border-color: var(--dm-bdr); }

    /* Sidebar custom */
    .sidebar { background: linear-gradient(135deg, #08131a, #0b2221); color: #e6eef1; }

    /* Chat */
    .chat-container { background: var(--dm-surf); color: var(--dm-txt); border-color: var(--dm-bdr); }
    .chat-header { background: linear-gradient(135deg, #1f5a3f, #0f513e); color: #fff; }
    .message-bubble { color: var(--dm-txt); }
    .message-incoming { background: var(--dm-surf2); color: var(--dm-txt); box-shadow: none; }
    .message-outgoing { background: #0f513e; color: #fff; }
    .message-document, .media-preview { background: rgba(255,255,255,.03); color: var(--dm-txt); }
    .conversation-search { background: rgba(255,255,255,.04); color: var(--dm-txt); }
    .conversation-actions .btn { background: #0b1220; border-color: #1f2937; color: var(--dm-muted); }

    /* Links */
    a:not(.btn):not(.badge), .nav-link { color: var(--dm-link); }

    /* Placeholders */
    ::placeholder { color: var(--dm-muted) !important; opacity: 1; }
}

/* ── Reglas para Bootstrap dark mode activo (data-bs-theme="dark") ── */
/* Bootstrap ya maneja card, modal, table, form, dropdown, badge, alert, etc. */
/* Solo corregimos lo que Bootstrap no toca: elementos custom y clases forzadas */

[data-bs-theme="dark"] .main-content           { background-color: var(--dm-body, #0a1628) !important; }
[data-bs-theme="dark"] .bg-white               { background-color: var(--bs-body-bg) !important; color: var(--bs-body-color) !important; }
[data-bs-theme="dark"] .sidebar                { background: linear-gradient(135deg, #08131a, #0b2221) !important; color: #e6eef1; }
[data-bs-theme="dark"] .chat-container         { background: var(--dm-surf, #071322); border-color: var(--dm-bdr, #163240); }
[data-bs-theme="dark"] .chat-header            { background: linear-gradient(135deg, #1f5a3f, #0f513e); color: #fff; }
[data-bs-theme="dark"] .message-bubble         { color: var(--dm-txt, #e6eef1); }
[data-bs-theme="dark"] .message-incoming       { background: var(--dm-surf2, #0b1c32); color: var(--dm-txt, #e6eef1); box-shadow: none; }
[data-bs-theme="dark"] .message-outgoing       { background: #0f513e; color: #fff; }
[data-bs-theme="dark"] .message-document,
[data-bs-theme="dark"] .media-preview          { background: rgba(255,255,255,.03); color: var(--dm-txt, #e6eef1); }
[data-bs-theme="dark"] .conversation-search    { background: rgba(255,255,255,.04); color: var(--dm-txt, #e6eef1); }
[data-bs-theme="dark"] .conversation-actions .btn { background: #0b1220; border-color: #1f2937; color: var(--dm-muted, #9ca3af); }
[data-bs-theme="dark"] a:not(.btn):not(.badge) { color: var(--dm-link, #a6f3c9); }
[data-bs-theme="dark"] ::placeholder           { color: var(--dm-muted, #9ca3af) !important; opacity: 1; }
