:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #10b981;
    --bg-app: #f9fafb;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --text-main: #111827;
    --text-muted: #4b5563;
    --border-color: #e5e7eb;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 16px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    /* Alertas y Estados */
    --bg-danger-subtle: #fee2e2;
    --border-danger-subtle: #fecaca;
    --text-danger-strong: #991b1b;
    --text-danger-vibrant: #ef4444;
    --bg-surface: #f1f5f9;
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    --nav-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --primary-contrast: #4f46e5;
    --pdf-accent: #6366f1;
    /* Colores de Estado Semánticos */
    --status-abierta: #ef4444;
    --status-en-proceso: #f59e0b;
    --status-resuelta: #10b981;
    --status-cerrada: #6b7280;
    --status-pendientes: #ea580c;
    --accent-purple: #8b5cf6;
    --accent-purple-light: #f5f3ff;
}

body.dark-mode {
    --primary: #4f46e5;
    --primary-contrast: #818cf8;
    --bg-app: #111827;
    --bg-card: #1f2937;
    --bg-input: #374151;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --border-color: #4b5563;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --bg-danger-subtle: rgba(248, 113, 113, 0.1);
    --border-danger-subtle: rgba(248, 113, 113, 0.2);
    --text-danger-strong: #f87171;
    --text-danger-vibrant: #fca5a5;
    --bg-surface: #0f172a;
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --nav-gradient: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    --pdf-accent: #818cf8;
    --accent-purple: #a78bfa;
    --accent-purple-light: rgba(167, 139, 250, 0.1);
    /* Ajustes para modo oscuro si es necesario (mantener legibilidad) */
    --status-abierta: #f87171;
    --status-en-proceso: #fbbf24;
    --status-resuelta: #34d399;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#app {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Transiciones suaves para el cambio de tema */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4 {
    color: var(--text-main);
}

body.dark-mode .card,
body.dark-mode .task-card,
body.dark-mode .dropdown-menu,
body.dark-mode .comment-composer {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Utilidades */
.container {
    padding: 20px;
    flex: 1;
}

.hidden {
    display: none !important;
}

/* Tipografía */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

p {
    font-size: 1rem;
    color: var(--text-muted);
}

/* Botones */
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
    text-align: center;
}

.btn:active {
    transform: scale(0.98);
}

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

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

.btn-danger {
    background: var(--danger);
    color: white;
    margin-top: 10px;
}

.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.4);
    z-index: 100;
    transition: transform 0.2s, box-shadow 0.2s;
}

.fab:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 25px rgba(79, 70, 229, 0.5);
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

input,
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-main);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

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

/* Tarjetas */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.kpi-card.clickable:hover {
    transform: translateY(-6px) scale(1.02);
    border-color: var(--primary);
}

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

.status-badge {
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -0.01em;
}

.status-abierta {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-abierta);
}

.status-asignada,
.status-en_proceso {
    background: rgba(245, 158, 11, 0.15);
    color: var(--status-en-proceso);
}

.status-resuelta {
    background: rgba(16, 185, 129, 0.15);
    color: var(--status-resuelta);
}

.status-cerrada {
    background: var(--border-color);
    color: var(--status-cerrada);
}

/* Nota: Los colores específicos de dark-mode ya se gestionan mediante las variables en body.dark-mode */

/* Carga */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-app);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Barra de Navegación Móvil */
.navbar {
    background: var(--nav-gradient);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 150;
    color: white;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-title {
    font-weight: 800;
    color: white;
    font-size: 1.15rem;
    letter-spacing: -0.025em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Anuncio Dinámico - Siempre en segunda línea (estilo unificado PC y móvil) */
.nav-announcement {
    order: 3;
    width: 100%;
    flex: none;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    transition: opacity 0.5s ease;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin-top: 2px;
}

.nav-announcement.fade-out {
    opacity: 0;
}

.nav-announcement.fade-in {
    opacity: 1;
}

@media (max-width: 480px) {
    .navbar {
        padding: 10px 16px;
    }

    .nav-title {
        font-size: 1rem;
    }

    .nav-announcement {
        font-size: 0.72rem;
    }
}

.dashboard-header {
    background: var(--nav-gradient);
    color: white;
    padding: 25px 20px 45px;
    margin-bottom: -30px;
}

.dashboard-header h1 {
    color: white;
    margin-bottom: 5px;
    font-size: 2rem;
}

.dashboard-header p {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.nav-actions button {
    background: none;
    border: none;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Perfil y Menú Desplegable */
.nav-profile {
    position: relative;
    cursor: pointer;
}

.avatar {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, background 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

.notification-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background-color: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #4f46e5;
    /* Para que destaque sobre el borde de la navbar si es necesario */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.avatar:hover {
    transform: scale(1.08);
    background: rgba(255, 255, 255, 0.3);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    background: var(--bg-card);
    color: var(--text-main);
    min-width: 220px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    padding: 8px 0;
}

.dropdown-menu.show {
    display: flex;
    animation: slideDown 0.2s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.dropdown-header .user-name {
    display: block;
    font-weight: 700;
    color: var(--text-main);
}

.dropdown-header .user-role {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.dropdown-item {
    padding: 12px 20px;
    font-size: 0.95rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--bg-app);
    color: var(--primary);
}

.dropdown-item i {
    font-size: 1.1rem;
}

.dropdown-section-title {
    padding: 12px 15px;
    font-size: 0.75em;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.dropdown-section-title:hover {
    background: var(--bg-app);
    color: var(--text-main);
}

.dropdown-section-content {
    display: none;
    padding-bottom: 5px;
}

.dropdown-section-content.show {
    display: block;
}

.section-indicator {
    font-size: 1.2em;
    transition: transform 0.2s;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}


.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Menú de Acciones en Filas/Listados */
.action-dropdown {
    position: relative;
    display: inline-flex;
}

.action-dropdown .dropdown-menu {
    top: 100%;
    right: 0;
    margin-top: 5px;
    min-width: 180px;
    background: var(--bg-card); /* Forzado sólido */
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 200;
    border: 1.5px solid var(--border-color);
}

.action-dropdown .btn-actions {
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-app);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.2s;
}

.action-dropdown .btn-actions:hover {
    background: var(--border-color);
    color: var(--text-main);
}


/* Rediseño de Login */
.login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 40px 30px;
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: loginFadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

@keyframes loginFadeUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-avatar-container {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    position: relative;
}

.login-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border: 4px solid white;
    animation: floatAvatar 6s ease-in-out infinite;
}

@keyframes floatAvatar {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.login-title {
    background: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.025em;
}

.login-subtitle {
    color: #4b5563;
    font-size: 0.95rem;
    font-weight: 500;
}

.login-form .form-group label {
    color: #374151;
    font-weight: 600;
    margin-left: 4px;
}

.login-form input {
    background: rgba(255, 255, 255, 0.6);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    color: #1f2937;
}

.login-form input:focus {
    background: white;
    border-color: #4f46e5;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.login-btn {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
    border: none;
    color: white;
    font-size: 1.1rem;
    padding: 16px;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.4);
}

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

.login-error-card {
    background: #fee2e2;
    color: #b91c1c;
    padding: 10px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 15px;
    text-align: center;
    border: 1px solid #fecaca;
    display: none;
}

.login-error-card.show {
    display: block;
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* Acordeón de Agrupación por Mes */
.month-group {
    margin-bottom: 24px;
}

.month-header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    padding: 14px 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
    margin-bottom: 12px;
    transition: all 0.2s ease;
    color: white;
}

.month-header:hover {
    transform: translateX(4px);
    box-shadow: 0 6px 15px rgba(79, 70, 229, 0.35);
}

.month-header h3 {
    margin: 0;
    font-size: 1.15rem;
    color: white;
    font-weight: 700;
    text-transform: capitalize;
}

.month-content {
    display: block;
    animation: fadeInSlide 0.3s ease-out;
}

.month-content.collapsed {
    display: none;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Alerta de Antigüedad */
.aging-alert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fee2e2;
    color: #ef4444;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 1.1rem;
    margin-left: 8px;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
    border: 1px solid #fecaca;
    vertical-align: middle;
}

/* Cajas de Carga de Imágenes */
.image-upload-box {
    width: 100px;
    height: 100px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-app);
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

.image-upload-box:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
}

/* Galería de Imágenes en Detalle */
.incident-images {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    overflow-x: auto;
    /* Permitir desplazamiento horizontal si es necesario, aunque deberían caber */
}

.incident-images img {
    flex: 1;
    min-width: 0;
    /* Permitir encogerse por debajo del tamaño del contenido */
    max-width: 180px;
    /* Limitar tamaño máximo en pantallas más grandes */
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.incident-images img:hover {
    transform: scale(1.05);
}

/* Sección de Adjuntos PDF */
.attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: border-color 0.2s ease;
}

.attachment-item:hover {
    border-color: #6366f1;
}

.attachment-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.attachment-icon {
    font-size: 1.4em;
    flex-shrink: 0;
}

.attachment-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.attachment-name {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.attachment-size {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-top: 1px;
}

.attachment-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    margin-left: 8px;
}

.attachment-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.attachment-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: #6366f1;
}

.attachment-btn-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

@media (max-width: 600px) {
    .attachment-name {
        max-width: 140px;
    }

    .attachment-btn {
        width: 28px;
        height: 28px;
        font-size: 0.8em;
    }
}

/* Visor de PDF Modal */
.pdf-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    flex-direction: column;
    animation: fadeIn 0.2s ease;
}

.pdf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.pdf-modal-title {
    color: white;
    font-weight: 600;
    font-size: 0.95em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40%;
}

.pdf-modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pdf-modal-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pdf-modal-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.pdf-modal-close {
    color: white;
    font-size: 2em;
    cursor: pointer;
    line-height: 1;
    padding: 0 8px;
    transition: color 0.2s;
}

.pdf-modal-close:hover {
    color: #ef4444;
}

.pdf-modal-container {
    flex: 1;
    width: 100%;
    border: none;
    background: #525659;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

/* Clase estandarizada para el panel de adjuntos */
.attachment-card {
    border: 1px solid var(--border-color) !important;
    border-left: 6px solid var(--pdf-accent) !important;
    background: var(--bg-card) !important;
    margin-bottom: 20px !important;
    transition: transform 0.2s ease, border-color 0.3s ease;
}

body.dark-mode .attachment-card {
    background: var(--bg-app) !important;
}

.pdf-modal-container object,
.pdf-modal-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

@media (max-width: 600px) {
    .pdf-modal-header {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .pdf-modal-title {
        max-width: 100%;
        order: 1;
        font-size: 0.85em;
    }

    .pdf-modal-actions {
        order: 2;
        width: 100%;
        justify-content: flex-end;
    }

    .pdf-modal-btn {
        padding: 5px 10px;
        font-size: 0.8em;
    }

    .pdf-modal-btn-print {
        display: none;
    }
}

/* Banner de Modo Mantenimiento */
.maintenance-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 6px 15px;
    /* Reducido de 12px 20px */
    text-align: center;
    font-size: 0.8rem;
    /* Reducido de 0.9rem */
    z-index: 200;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
    animation: slideDownBanner 0.4s ease-out;
}

@keyframes slideDownBanner {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.maintenance-banner+* {
    margin-top: 32px;
    /* Reducido de 48px para coincidir con el banner más delgado */
    /* Desplazamiento para banner fijo */
}

/* Estilos del Pie de Página */

.app-footer {
    padding: 24px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.app-footer strong {
    color: var(--text-main);
}

.app-footer .copyright-owner {
    font-weight: 600;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Estilos de la Funcionalidad de Tareas */
.tasks-view {
    background-color: var(--bg-app);
    min-height: calc(100vh - 80px);
}

.task-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
    border-left: 6px solid #8b5cf6;
}

.task-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.status-task {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px !important;
    text-transform: capitalize;
}

.status-no-iniciada {
    background: var(--border-color);
    color: var(--text-main);
}

.status-en-curso {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}

.status-completada {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

body.dark-mode .status-en-curso {
    color: #60a5fa;
}

body.dark-mode .status-completada {
    color: #34d399;
}

.task-due-alert {
    color: #ef4444;
    font-size: 1.1em;
    font-weight: bold;
    margin-left: 8px;
}

.tasks-bg {
    background: var(--bg-app);
    padding-top: 2rem;
}

body.dark-mode .tasks-bg {
    background: var(--bg-app);
}

.task-meeting-badge {
    background: var(--bg-app);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px !important;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 4px;
    display: inline-block;
}

/* Estilos del Stepper de Tareas */
.task-stepper {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    position: relative;
    padding: 0 10px;
}

.task-stepper::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 40px;
    right: 40px;
    height: 2px;
    background: var(--border-color);
    z-index: 0;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
    flex: 1;
    position: relative;
}

.step-dot {
    width: 32px;
    height: 32px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    color: #9ca3af;
    transition: all 0.3s;
}

.step-label {
    margin-top: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #9ca3af;
    text-align: center;
}

.step-item.active .step-dot {
    border-color: #8b5cf6;
    color: #8b5cf6;
    background: #f5f3ff;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.step-item.active .step-label {
    color: #8b5cf6;
}

/* Botón de eliminar paso en tareas */
.btn-delete-step {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
    font-size: 1.1rem;
    line-height: 1;
}

.btn-delete-step:hover {
    color: var(--danger) !important;
    transform: scale(1.1);
}

.btn-delete-step:active {
    transform: scale(0.9);
}

.step-item.completed .step-dot {
    background: #8b5cf6;
    border-color: #8b5cf6;
    color: #fff;
}

.step-item.completed .step-label {
    color: #5b21b6;
}

.line-progress {
    pointer-events: none;
    position: absolute;
    top: 15px;
    left: 40px;
    height: 2px;
    background: #8b5cf6;
    z-index: 0;
    transition: width 0.3s;
}

/* Destacado de Tarea Urgente */
.task-card.due-soon {
    background-color: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-left: 6px solid #ef4444;
}

.task-card.due-soon .task-due-alert {
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

/* Estilos Mejorados de la Sección de Tareas */
.tasks-bg .month-header {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    /* Violeta Distintivo */
    color: white;
}

.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 6px solid #6366f1;
}

.task-card:hover {
    background: var(--bg-card);
    filter: brightness(1.03);
}

.task-card.due-soon {
    background-color: rgba(249, 115, 22, 0.08);
    border: 1px solid rgba(249, 115, 22, 0.2);
    border-left: 6px solid #f97316;
}

.task-card.due-soon:hover {
    filter: brightness(1.03);
}

.tasks-bg .month-group {
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

/* Colores de borde por estado de incidencia */
.card-border-abierta {
    border-left: 6px solid #fee2e2 !important;
}

.card-border-en_proceso {
    border-left: 6px solid #f59e0b !important;
}

.card-border-resuelta {
    border-left: 6px solid #10b981 !important;
}

.card-border-cerrada {
    border-left: 6px solid #6b7280 !important;
}

/* Sobreescritura de Prioridad - Debe ir después de los bordes de estado */
.card-urgent {
    border-left: 6px solid #b91c1c !important;
    background-color: rgba(239, 68, 68, 0.06) !important;
}

/* Botón Flotante (FAB) Específico de Tareas */
.fab-tasks {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important;
    box-shadow: 0 10px 20px rgba(124, 58, 237, 0.4);
    right: 24px;
    /* Alinear con el FAB de incidencias */
}

.fab-tasks:hover {
    box-shadow: 0 15px 25px rgba(124, 58, 237, 0.5);
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
}

/* Botón Flotante (FAB) Específico de Usuarios */
.fab-users {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.4);
    right: 24px;
}

.fab-users:hover {
    box-shadow: 0 15px 25px rgba(16, 185, 129, 0.5);
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
}

/* Cabecera de Tareas Profesional */
.tasks-header {
    background: #8b5cf6;
    /* Violeta sólido del botón de tareas */
    color: white;
    padding: 30px 20px 50px;
    margin-bottom: -30px;
    /* Solapamiento con contenido como el panel */
    text-align: center;
}

.tasks-header h2 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: white;
}

.tasks-header .header-gradient {
    -webkit-text-fill-color: white;
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
}

.tasks-header .header-emoji {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.tasks-header p {
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.95);
    max-width: 450px;
    margin: 0 auto;
    font-weight: 500;
}

.tasks-header::after {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.4);
    margin: 18px auto 0;
    border-radius: 10px;
}

/* Filtros de Tareas */
.task-filters {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 25px;
    padding: 10px;
    flex-wrap: nowrap;
    position: relative;
    z-index: 5;
}

.filter-pill {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    color: var(--text-muted);
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    filter: grayscale(100%);
}

.filter-pill:hover {
    background: var(--bg-app);
}

.filter-pill.active {
    background: #8b5cf6;
    color: white;
    box-shadow: 0 4px 6px rgba(139, 92, 246, 0.2);
    filter: none;
    border-color: #8b5cf6;
}

.filter-pill.active[data-filter="all"] {
    background: #6b7280;
}

.filter-pill.active[data-filter="no_iniciada"] {
    background: #9ca3af;
}

.filter-pill.active[data-filter="en_curso"] {
    background: #8b5cf6;
}

.filter-pill.active[data-filter="completada"] {
    background: #10b981;
}

/* Lista de Desglose Responsiva */
@media (min-width: 601px) {
    .desktop-only {
        display: block !important;
    }

    .mobile-only {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
    }
}

/* Diseño Responsivo del Panel de Actualización de Estado de Tarea */
.task-status-update-panel {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.task-status-update-panel select,
.task-status-update-panel button {
    height: 54px;
    border-radius: 12px;
}

@media (min-width: 601px) {
    .task-status-update-panel {
        flex: 0 0 65%;
        max-width: 650px;
    }

    .task-status-update-panel select,
    .task-status-update-panel button {
        font-size: 1.1em !important;
    }
}

@media (max-width: 600px) {
    .task-status-update-panel {
        flex: 1 1 100%;
    }

    .task-status-update-panel select,
    .task-status-update-panel button {
        font-size: 0.95em !important;
    }
}

/* ============================================================
   SECCIÓN: GRABADOR DE AUDIO Y COMENTARIOS MIXTOS
   ============================================================ */

/* Contenedor principal del formulario de comentarios */
.comment-composer {
    background: var(--bg-card);
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
}

/* Fila de entrada (Textarea + Botón Micro) */
.input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

/* Envoltura del botón de grabación y temporizador */
.recording-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 50px;
}

/* Botón de Micrófono */
#record-audio-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background-color: #4f46e5;
    /* Color primario de la app */
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
}

#record-audio-btn:hover {
    transform: scale(1.05);
}

/* Estado: GRABANDO ACTIVO */
#record-audio-btn.recording {
    background-color: #ef4444 !important;
    /* Rojo de alerta */
    animation: pulse-red 1.5s infinite;
}

/* Animación de parpadeo y pulso para grabación */
@keyframes pulse-red {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Temporizador de grabación */
#recording-timer {
    font-family: 'Outfit', sans-serif;
    background: #fef2f2;
    color: #b91c1c;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    border: 1px solid #fee2e2;
    white-space: nowrap;
}

/* Contenedor de previsualización de audio antes de enviar */
#audio-preview-container {
    display: flex;
    margin-bottom: 10px;
    align-items: center;
    gap: 10px;
    background: #f0f4f8;
    padding: 10px;
    border-radius: 8px;
    border: 1px dashed #cbd5e1;
}

/* Botón de borrar audio pendiente */
.btn-delete-audio {
    background: #ff4d4d;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: 600;
}

/* Estilo del reproductor de audio dentro de los comentarios */
.comment-body audio {
    width: 100%;
    height: 35px;
    margin-top: 8px;
    border-radius: 8px;
    display: block;
    /* Ajuste de color para navegadores compatibles */
    filter: sepia(10%) saturate(80%) hue-rotate(180deg) brightness(102%);
}

/* Spinner pequeño para botones */
.spinner-small {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin-small 0.8s linear infinite;
}

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

/* --- Correcciones de Login en Móvil --- */
input::-ms-reveal,
input::-ms-clear {
    display: none !important;
}

input::-webkit-contacts-auto-fill-button,
input::-webkit-credentials-auto-fill-button {
    visibility: hidden;
    position: absolute;
    right: 0;
}

/* Animaciones de Notificaciones */
@keyframes heartbeat {
    0% {
        transform: scale(1);
        background-color: transparent;
    }

    15% {
        transform: scale(1.1);
        background-color: rgba(239, 68, 68, 0.1);
    }

    30% {
        transform: scale(1);
        background-color: transparent;
    }

    45% {
        transform: scale(1.15);
        background-color: rgba(239, 68, 68, 0.2);
    }

    70% {
        transform: scale(1);
        background-color: transparent;
    }

    100% {
        transform: scale(1);
        background-color: transparent;
    }
}

.heartbeat-anim {
    animation: heartbeat 1.5s ease-in-out infinite !important;
    border: 2px solid rgba(255, 255, 255, 0.8) !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3) !important;
}

@keyframes blink-soft {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

.blink-anim {
    animation: blink-soft 1.2s ease-in-out infinite !important;
    font-weight: 700 !important;
}

/* --- Estilos de la Página de Mantenimiento --- */
.maintenance-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999;
}

.maintenance-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 60px 40px;
    border-radius: 32px;
    max-width: 600px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.8s ease-out;
}

.maintenance-icon {
    font-size: 5rem;
    margin-bottom: 30px;
    display: block;
    animation: float 4s ease-in-out infinite;
}

.maintenance-title {
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.maintenance-text {
    color: #94a3b8;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 40px;
}

.hidden-door {
    cursor: default;
    transition: opacity 0.3s;
    user-select: none;
    display: inline-block;
}

.hidden-door:active {
    opacity: 0.5;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Interruptor de Ajustes --- */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #4f46e5;
}

input:checked+.slider:before {
    transform: translateX(24px);
}

/* --- Modal de Imagen Lightbox --- */
.image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.image-modal-content {
    margin: auto;
    display: block;
    max-width: 95%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s;
}

.image-modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.image-modal-close:hover {
    color: #bbb;
}

@keyframes zoomIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================================================
   🤖 Chatbot UI
   ======================================================================== */

/* FAB — Floating Action Button */
/* Icono del Asistente IA en el Navbar (junto al sol/luna) */
.chatbot-nav-icon {
    cursor: pointer;
    font-size: 18px;
    opacity: 0.85;
    transition: all 0.3s ease;
    display: none;
    position: relative;
}

.chatbot-nav-icon:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Animación de temblor sutil para llamar la atención */
@keyframes chatbotWiggle {
    0% { transform: rotate(0deg); }
    15% { transform: rotate(15deg); }
    30% { transform: rotate(-12deg); }
    45% { transform: rotate(10deg); }
    60% { transform: rotate(-8deg); }
    75% { transform: rotate(5deg); }
    100% { transform: rotate(0deg); }
}

.chatbot-nav-icon.wiggle {
    animation: chatbotWiggle 0.6s ease-in-out;
}

/* Tooltip popup del asistente */
.chatbot-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.chatbot-tooltip.visible {
    opacity: 1;
}

.chatbot-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--bg-card);
}

/* FAB antiguo - ya no se usa, oculto por seguridad */
.chatbot-fab {
    display: none !important;
}

/* Drawer */
.chatbot-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 75vh;
    background: var(--bg-card);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    z-index: 899;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.chatbot-drawer.open {
    transform: translateY(0);
}

.chatbot-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chatbot-drawer-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.05em;
    color: var(--text-main);
}

.chatbot-drawer-title .icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.chatbot-drawer-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.chatbot-drawer-close:hover {
    background: var(--bg-app);
    color: var(--text-main);
}

/* Chat Body */
.chatbot-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: calc(75vh - 130px);
}

/* Burbujas de Chat */
.chatbot-bubble {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.92em;
    line-height: 1.55;
    word-wrap: break-word;
    animation: chatBubbleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.chatbot-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.chatbot-bubble.bot {
    align-self: flex-start;
    background: var(--bg-surface);
    color: var(--text-main);
    border-bottom-left-radius: 6px;
    border: 1px solid var(--border-color);
}

.chatbot-bubble.bot strong {
    color: var(--text-main);
}

/* Acciones interactivas (enlaces) dentro de la burbuja */
.chatbot-inline-action {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    padding: 0 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chatbot-inline-action:hover {
    background: rgba(79, 70, 229, 0.15);
    text-decoration-style: solid;
}

/* Source badge */
.chatbot-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72em;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.chatbot-source-badge.local {
    background: rgba(16, 185, 129, 0.12);
    color: var(--secondary);
}

.chatbot-source-badge.cloud {
    background: rgba(79, 70, 229, 0.12);
    color: var(--primary-contrast);
}

/* Sugerencias */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.chatbot-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chatbot-chip:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.06);
    color: var(--primary-contrast);
    transform: translateY(-1px);
}

.chatbot-chip:active {
    transform: scale(0.97);
}

/* Typing indicator */
.chatbot-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    align-self: flex-start;
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.4;
    animation: chatTyping 1.4s ease-in-out infinite;
}

.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
    0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Input bar */
.chatbot-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    flex-shrink: 0;
}

.chatbot-input-bar input {
    flex: 1;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 0.92em;
    background: var(--bg-input);
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input-bar input:focus {
    border-color: var(--primary);
}

.chatbot-input-bar button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.chatbot-input-bar button:hover {
    transform: scale(1.08);
}

.chatbot-input-bar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* Overlay detrás del drawer */
.chatbot-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 898;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.chatbot-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Prevenir scroll del body */
body.chatbot-open-noscroll {
    overflow: hidden;
}

/* Responsive */

@media (min-width: 768px) {
    .chatbot-drawer {
        max-width: 420px;
        left: 24px;
        right: auto;
        bottom: 90px;
        max-height: 70vh;
        border-radius: 20px;
        transform: translateY(20px) scale(0.95);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    }

    .chatbot-drawer.open {
        transform: translateY(0) scale(1);
        opacity: 1;
        pointer-events: auto;
    }

    .chatbot-overlay {
        display: none;
    }
}

/* Welcome message */
.chatbot-welcome {
    text-align: center;
    padding: 20px 10px;
}

.chatbot-welcome .welcome-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.chatbot-welcome h4 {
    color: var(--text-main);
    font-weight: 800;
    font-size: 1.1em;
    margin-bottom: 6px;
}

.chatbot-welcome p {
    color: var(--text-muted);
    font-size: 0.88em;
    line-height: 1.5;
    margin-bottom: 16px;
}

/* ========================================================================
   📊 Auditoría IA — Dashboard
   ======================================================================== */

/* Grid de KPIs */
.audit-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

@media (min-width: 768px) {
    .audit-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (max-width: 767px) {
    .audit-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .audit-kpi-card {
        padding: 10px 4px;
        border-radius: 12px;
    }
    .audit-kpi-value {
        font-size: 1.1rem;
    }
    .audit-kpi-label {
        font-size: 0.62rem;
        margin-top: 4px;
    }
    .audit-kpi-icon {
        font-size: 1rem;
        margin-bottom: 2px;
    }
    /* Prevenir desbordamiento horizontal */
    .audit-chart-card {
        padding: 14px 12px;
        overflow: hidden;
    }
    .audit-charts-grid {
        gap: 10px;
    }
    .audit-chart-title {
        font-size: 0.88rem;
        margin-bottom: 10px;
    }
    .audit-table {
        font-size: 0.8rem;
    }
    .audit-table th,
    .audit-table td {
        padding: 8px 6px;
    }
    .audit-spam-alert {
        padding: 12px 14px;
        font-size: 0.88rem;
    }
}

.audit-kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 16px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.audit-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.audit-kpi-warning {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.04);
}

.audit-kpi-info {
    border-color: rgba(249, 115, 22, 0.3);
    background: rgba(249, 115, 22, 0.04);
}

.audit-kpi-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.audit-kpi-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.audit-kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Alerta de Spam */
.audit-spam-alert {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 24px;
    color: var(--text-main);
}

/* Grid de gráficas */
.audit-charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .audit-charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.audit-chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
}

.audit-chart-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 16px 0;
}

/* Contenedor fijo para Chart.js — OBLIGATORIO para que responsive funcione */
.audit-chart-container {
    position: relative;
    height: 220px;
    width: 100%;
}

.audit-chart-container-sm {
    height: 200px;
}

@media (max-width: 767px) {
    .audit-chart-container {
        height: 180px;
    }
    .audit-chart-container-sm {
        height: 160px;
    }
}

/* Grid para tablas de top intents / top usuarios */
.audit-tables-grid {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .audit-tables-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Tablas de auditoría */
.audit-table-scroll {
    overflow-x: auto;
}

.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.audit-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--border-color);
}

.audit-table td {
    padding: 10px 12px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
}

.audit-table tr:hover td {
    background: var(--bg-app);
}

.audit-table tr:last-child td {
    border-bottom: none;
}

/* Badges */
.audit-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 700;
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary-contrast, #6366f1);
}

.audit-role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.78em;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.12);
    color: var(--secondary, #10b981);
    text-transform: capitalize;
}

.audit-source-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
}

.audit-source-local {
    background: rgba(16, 185, 129, 0.12);
    color: var(--secondary, #10b981);
}

.audit-source-cloud {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}