@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-app: #f3f6fd;                  /* Fondo Gris-azul suave de la aplicación */
    --bg-card: #ffffff;                 /* Blanco puro para tarjetas y paneles */
    --border-color: #e2e8f0;            /* Bordes delgados elegantes */
    --text-primary: #1e293b;            /* Texto principal gris pizarra */
    --text-secondary: #475569;          /* Texto secundario */
    --text-muted: #5f6368;              /* Gris slate de barra lateral / inactivos */
    --brand-blue: #1a419c;              /* Azul corporativo oficial */
    --brand-blue-hover: #112e75;        /* Azul corporativo hover */
    --brand-blue-light: #eef2ff;        /* Fondo activo o hover suave */
    --accent-indigo: #4f46e5;           /* Índigo para efectos especiales e IA */
    --accent-indigo-light: #e0e7ff;     /* Fondo de acento IA */
    --color-green: #10b981;             /* Éxito verde moderno */
    --color-red: #ef4444;               /* Peligro/error rojo moderno */
    --font-titles: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --radius-lg: 18px;                  /* Esquinas redondeadas grandes */
    --radius-md: 12px;                  /* Esquinas redondeadas medianas */
    --radius-sm: 8px;                   /* Esquinas redondeadas pequeñas para inputs */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 12px -1px rgba(26, 65, 156, 0.06), 0 2px 6px -1px rgba(26, 65, 156, 0.04);
    --shadow-lg: 0 10px 25px -3px rgba(26, 65, 156, 0.08), 0 4px 12px -2px rgba(26, 65, 156, 0.04);
    --shadow-input: 0 0 0 3px rgba(26, 65, 156, 0.15);
    --shadow-input-ia: 0 0 0 3px rgba(79, 70, 229, 0.2);
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   ELEMENTOS GLOBALES
   ========================================================================== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--bg-app);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-titles);
    font-weight: 700;
    color: var(--brand-blue);
    margin-top: 0;
}

/* ==========================================================================
/* ==========================================================================
   NUEVA BARRA SUPERIOR FIJA (TOPBAR) - ALEinma
   ========================================================================== */

.app-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-menu-toggle {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #334155;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.topbar-menu-toggle:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

.topbar-brand {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.brand-title {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: #0b7952; /* Verde corporativo de ALEinma */
    letter-spacing: -0.3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-profile-widget {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.user-avatar-placeholder {
    background-color: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.user-name {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
}

.topbar-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: #475569;
    text-decoration: none;
    font-size: 18px;
    transition: background-color 0.2s, color 0.2s;
}

.topbar-logout-btn:hover {
    background-color: #fee2e2;
    color: #ef4444;
}

/* ==========================================================================
   NUEVA BARRA LATERAL (SIDEBAR) - ALEinma LOOK & FEEL
   ========================================================================== */

.app-sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 250px;
    background-color: #ffffff;
    border-right: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    z-index: 999;
    padding: 16px 12px;
    overflow-y: auto;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-nav-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.sidebar-bottom-section {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-divider {
    height: 1px;
    background-color: #f1f5f9;
    margin: 8px 4px;
}

/* Enlaces e ítems principales */
.nav-link-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 24px;
    color: #334155;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.nav-link-pill:hover {
    background-color: #f8fafc;
    color: #0f172a;
}

.nav-link-pill.active {
    background-color: #e8ecf4;
    color: #0f172a;
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #475569;
}

.nav-link-pill.active .nav-icon {
    color: #1e293b;
}

.nav-label {
    flex-grow: 1;
    text-align: left;
}

/* Grupo con acordeón (Flota, Confiabilidad, etc.) */
.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: #334155;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s, color 0.2s;
}

.nav-group-header:hover {
    background-color: #f8fafc;
    color: #0f172a;
}

.nav-group-header.active {
    color: #0b7952;
    font-weight: 600;
}

.nav-chevron {
    font-size: 11px;
    color: #94a3b8;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-group.expanded .nav-chevron {
    transform: rotate(90deg);
}

.nav-submenu {
    display: none;
    flex-direction: column;
    gap: 3px;
    padding-left: 36px;
    padding-top: 4px;
    padding-bottom: 6px;
}

.nav-group.expanded .nav-submenu {
    display: flex;
}

.nav-sublink {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    font-size: 13.5px;
    color: #64748b;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.nav-sublink i {
    font-size: 13px;
    width: 16px;
    text-align: center;
}

.nav-sublink:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

.nav-sublink.active {
    background-color: #e6f4ea;
    color: #0b7952;
    font-weight: 600;
}

.nav-sublink.disabled-link {
    opacity: 0.55;
    cursor: not-allowed;
    color: #94a3b8;
}

/* Compatibilidad con clases anteriores de sidebar si alguna vista no se ha actualizado */
.sidebar {
    display: none !important;
}
.menu-toggle {
    display: none !important;
}

/* ==========================================================================
   ESTADO COLAPSADO Y DISEÑO DE CONTENIDO PRINCIPAL
   ========================================================================== */

body.sidebar-collapsed .app-sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .main-content {
    margin-left: 0 !important;
}

.main-content {
    margin-left: 250px;
    margin-top: 60px;
    min-height: calc(100vh - 60px);
    padding: 30px 40px;
    background-color: var(--bg-app);
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-logo {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 25px;
}

.logo-empresa {
    width: 180px;
    height: auto;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.main-content h1 {
    color: var(--brand-blue);
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.subtitulo {
    font-size: 16px;
    color: var(--text-secondary);
    margin-top: 0;
    margin-bottom: 35px;
    font-weight: 500;
}

/* ==========================================================================
   TARJETAS Y PANELES (CONTENEDORES)
   ========================================================================== */

.status-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 30px;
    box-shadow: var(--shadow-md);
    margin-bottom: 35px;
    transition: var(--transition-smooth);
}

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

.status-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--brand-blue-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.status-icon i {
    font-size: 36px;
    color: var(--brand-blue);
}

.status-card h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--brand-blue);
    margin-bottom: 8px;
}

.status-card p {
    font-size: 15px;
    color: var(--text-secondary);
    margin: 6px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-green {
    color: var(--color-green) !important;
    font-size: 16px;
}

/* ==========================================================================
   BOTONES Y ACCIONES
   ========================================================================== */

button, .btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 14px;
    background-color: var(--brand-blue);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-sm);
}

button:hover, .btn-action:hover {
    background-color: var(--brand-blue-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

button:active, .btn-action:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--brand-blue-light);
    color: var(--brand-blue);
    box-shadow: none;
}

.btn-secondary:hover {
    background-color: #e0e7ff;
    color: var(--brand-blue);
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   FORMULARIOS E INPUTS
   ========================================================================== */

form {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 100%;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: 14px;
    color: var(--brand-blue);
}

input, select, textarea {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    box-sizing: border-box;
    width: 100%;
    padding: 12px 16px;
    margin-top: 4px;
    background-color: #fafbfc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: var(--transition-smooth);
}

input::placeholder, textarea::placeholder {
    color: #94a3b8;
}

input:hover, select:hover, textarea:hover {
    border-color: #cbd5e1;
    background-color: #ffffff;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--brand-blue);
    background-color: #ffffff;
    box-shadow: var(--shadow-input);
}

/* ==========================================================================
   FORMULARIO DE FALLAS (REGISTRAR FALLA)
   ========================================================================== */

.form-falla {
    margin-top: 20px;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.campo {
    display: flex;
    flex-direction: column;
}

.campo label {
    margin-bottom: 4px;
}

.campo textarea {
    resize: vertical;
}

.campo textarea[name="descripcion"],
.campo textarea[name="accion_correctiva"] {
    min-height: 120px;
}

.campo textarea[name="referencia"],
.campo textarea[name="tips"] {
    min-height: 80px;
}

.btn-guardar {
    margin-top: 25px;
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: #072b61;          /* Azul marino oscuro exacto */
    color: #ffffff;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.btn-guardar:hover {
    background-color: #051c4a;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.campo-corto input {
    width: 100%; /* Permitir que ocupe todo el grid cell de forma responsiva */
}

.campo-mel input {
    width: 100%;
}

/* ==========================================================================
   TABLA DE RESULTADOS (CONSULTAR FALLAS)
   ========================================================================== */

.table-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-top: 35px;
    overflow-x: auto;
}

.fallas-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.fallas-table th, .fallas-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.fallas-table th {
    background-color: #fafbfc;
    color: var(--brand-blue);
    font-family: var(--font-titles);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.2px;
}

.fallas-table tr {
    transition: var(--transition-smooth);
}

.fallas-table tr:hover {
    background-color: var(--brand-blue-light);
}

/* Celdas especiales de expandir y contraer */
.mel-cell, .text-truncate-3 {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-size: 13.5px;
    transition: var(--transition-smooth);
    color: var(--text-secondary);
}

.text-truncate-3 {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.mel-cell:hover, .text-truncate-3:hover {
    color: var(--brand-blue);
}

.mel-cell.expanded, .text-truncate-3.expanded {
    white-space: normal;
    word-break: break-word;
    max-width: none;
    display: block;
    -webkit-line-clamp: unset;
    padding: 4px 0;
}

/* ==========================================================================
   ASISTENTE IA - CHAT CON IA (VIBRANT & ALIVE)
   ========================================================================== */

/* Contenedor del Chat (Retoma su diseño original centrado) */
.chat-container {
    background-image: linear-gradient(rgba(15, 23, 42, 0.15), rgba(15, 23, 42, 0.30)), url('../images/fondo_mecanico.jpg');
    background-size: cover;
    background-position: center;
    background-color: #0f172a;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin: 30px auto 10px auto; /* 10px abajo para acercarlo a la barra de controles */
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    height: 68vh;
    min-height: 520px;
    max-height: 720px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

/* Fila de controles inferiores (Historial a la izquierda, Nueva conversación a la derecha) */
.chat-bottom-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1100px;
    margin: 10px auto 30px auto;
    position: relative;
    gap: 20px;
}

/* --- CONTROLES DE HISTORIAL DESPLEGABLE (DROP-UP) --- */
.chat-history-dropup {
    position: relative;
    display: inline-block;
}

/* Botón "Historial" (Blanco / Tarjeta) */
.history-toggle-btn {
    background-color: #ffffff;
    color: #5f6368;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 18px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    transition: all 0.25s ease;
}

.history-toggle-btn:hover {
    background-color: #f8fafc;
    color: #1a419c;
    border-color: #cbd5e1;
}

.chat-history-dropup.open .history-toggle-btn {
    background-color: #eef2ff;
    color: #1a419c;
    border-color: rgba(26, 65, 156, 0.2);
}

/* Contenido del Drop-up (Se expande hacia arriba) */
.history-dropup-content {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px); /* Abre hacia arriba */
    left: 0;
    width: 340px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.08);
    z-index: 100;
    overflow: hidden;
    animation: slideUpFade 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.chat-history-dropup.open .history-dropup-content {
    display: block;
}

/* Listado de chats */
.chat-history-list {
    max-height: 280px;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-history-list::-webkit-scrollbar {
    width: 4px;
}
.chat-history-list::-webkit-scrollbar-track {
    background: transparent;
}
.chat-history-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

/* Item de chat */
.chat-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    gap: 10px;
}

.chat-history-item:hover {
    background: #f3f6fd; /* Fondo gris-azul suave */
}

/* Estado activo (Fondo #eef2ff, textos #1a419c) */
.chat-history-item.active {
    background-color: #eef2ff;
    border-color: rgba(26, 65, 156, 0.1);
}

.chat-title-text {
    flex: 1;
    display: flex;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: #5f6368; /* Gris slate para inactivos */
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-title-text i {
    font-size: 13px;
    opacity: 0.7;
    margin-right: 8px;
}

.chat-history-item.active .chat-title-text {
    color: #1a419c; /* Azul corporativo */
    font-weight: 700;
}

.chat-title-text span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    max-width: 220px;
}

/* Botón borrar chat */
.delete-chat-btn {
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-chat-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* --- BOTÓN NUEVA CONVERSACIÓN (DERECHA) --- */
.new-chat-btn-bottom {
    background: linear-gradient(135deg, #1a419c 0%, #4f46e5 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(26, 65, 156, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.new-chat-btn-bottom:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.25);
    filter: brightness(1.1);
}

.new-chat-btn-bottom:active {
    transform: translateY(0);
}

.chat-box {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: rgba(15, 23, 42, 0.30);
    backdrop-filter: blur(2.5px);
}

/* Scrollbar personalizado para el chat */
.chat-box::-webkit-scrollbar {
    width: 6px;
}
.chat-box::-webkit-scrollbar-track {
    background: transparent;
}
.chat-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
.chat-box::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-message {
    max-width: 75%;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    line-height: 1.6;
    font-size: 14.5px;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    transition: var(--transition-smooth);
    animation: message-appear 0.3s ease-out;
}

/* Estilos de elementos Markdown renderizados en los mensajes */
.chat-message p {
    margin: 0 0 10px 0;
}
.chat-message p:last-child {
    margin-bottom: 0;
}
.chat-message ul, .chat-message ol {
    margin: 0 0 10px 0;
    padding-left: 20px;
}
.chat-message li {
    margin-bottom: 5px;
}
.chat-message li:last-child {
    margin-bottom: 0;
}
.chat-message strong {
    font-weight: 700;
    color: inherit;
}
.chat-message hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 12px 0;
}


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

.chat-message.bot {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.95);
    color: #0f172a;
    border-bottom-left-radius: 2px;
    border-left: 4px solid var(--accent-indigo);
}

.chat-message.user {
    align-self: flex-end;
    background-image: linear-gradient(135deg, var(--brand-blue) 0%, var(--accent-indigo) 100%);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.chat-input-area {
    display: flex;
    padding: 20px 30px 25px 30px;
    gap: 15px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    align-items: center;
}

.chat-input-area input {
    flex: 1;
    margin-top: 0;
    padding: 14px 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-radius: var(--radius-md);
    font-size: 14.5px;
    box-shadow: none;
}

.chat-input-area input:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.chat-input-area input:focus {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-indigo);
    box-shadow: var(--shadow-input-ia);
}

.chat-input-area button {
    margin-top: 0;
    border-radius: var(--radius-md);
    padding: 14px 24px;
    background-image: linear-gradient(135deg, var(--brand-blue) 0%, var(--accent-indigo) 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.chat-input-area button:hover {
    background-image: linear-gradient(135deg, var(--brand-blue-hover) 0%, #4338ca 100%);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

/* Botón de dictar con reconocimiento de voz */
.chat-input-area .dictate-btn {
    margin-top: 0;
    border-radius: var(--radius-md);
    padding: 14px 20px;
    background-color: var(--accent-indigo);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input-area .dictate-btn:hover {
    background-color: #4338ca;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.chat-input-area .dictate-btn:active {
    transform: translateY(0);
}

/* Estado de grabación activo */
.chat-input-area .dictate-btn.recording {
    background-color: var(--color-red) !important;
    background-image: none !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    animation: pulse-red 1.5s infinite;
}

.chat-input-area .dictate-btn.recording i {
    animation: blink 1s infinite;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7), 0 4px 12px rgba(239, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0), 0 4px 12px rgba(239, 68, 68, 0.4);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0), 0 4px 12px rgba(239, 68, 68, 0.4);
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

/* ==========================================================================
   DISEÑO DE ADMINISTRACIÓN
   ========================================================================== */

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.admin-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 30px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.admin-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--brand-blue);
}

.admin-card i {
    font-size: 44px;
    color: var(--brand-blue);
    margin-bottom: 20px;
    transition: var(--transition-smooth);
}

.admin-card:hover i,
.admin-card:hover .admin-card-img {
    transform: scale(1.08);
}

.admin-card h3 {
    font-size: 18px;
    color: var(--brand-blue);
    margin-bottom: 10px;
}

.admin-card p {
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.5;
    margin: 0;
}

/* ==========================================================================
   ALERTAS Y NOTIFICACIONES
   ========================================================================== */

.alert-success, .alert-danger {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 25px;
    font-size: 14.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: alert-appear 0.2s ease-out;
}

@keyframes alert-appear {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.alert-success {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ==========================================================================
   BANNER DE MANTENIMIENTO (FOOTER)
   ========================================================================== */

.footer-mantenimiento {
    text-align: center;
    margin-top: 50px;
    padding-bottom: 20px;
}

.mantenimiento-title {
    font-family: var(--font-titles);
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    letter-spacing: 1.5px;
}

.red-dashes {
    display: flex;
    gap: 6px;
}

.red-dash {
    width: 20px;
    height: 10px;
    background-color: var(--color-red);
    transform: skew(-25deg);
}

.mantenimiento-subtitle {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* ==========================================================================
   LOGIN / ACCESO (GLOW & PREMIUM EFFECT)
   ========================================================================== */

.login-body {
    background-color: var(--bg-app);   /* Fondo gris-azul suave de la aplicación */
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Orbes dinámicos de fondo en modo claro (más sutiles) */
.glow-orb-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    overflow: hidden;
    z-index: 1;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.15;                     /* Opacidad reducida para modo claro */
    animation: orb-bounce 20s infinite alternate ease-in-out;
}

.orb-primary {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(26, 65, 156, 0.4) 0%, rgba(26, 65, 156, 0) 70%);
    top: -100px;
    left: -100px;
}

.orb-secondary {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.3) 0%, rgba(79, 70, 229, 0) 70%);
    bottom: -150px;
    right: -100px;
    animation-delay: -10s;
}

@keyframes orb-bounce {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(120px, 80px) scale(1.15); }
}

.login-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 440px;                  /* Ajuste simétrico */
    padding: 20px;
}

.login-card {
    background: var(--bg-card);        /* Fondo blanco puro */
    border: 1px solid var(--border-color); /* Borde delgado gris elegante */
    border-radius: var(--radius-lg);   /* Redondeado corporativo de 18px */
    padding: 40px;
    box-shadow: var(--shadow-lg);      /* Sombra de alta gama muy suave */
    text-align: center;
}

.login-header {
    margin-bottom: 25px;
}

.brand-logo {
    display: inline-flex;
    justify-content: center;
    margin-bottom: 15px;
}

.brand-title {
    font-family: var(--font-titles);
    font-size: 32px;
    font-weight: 800;
    color: var(--brand-blue);          /* Título en azul de marca */
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.brand-subtitle {
    font-size: 13.5px;
    color: var(--text-secondary);      /* Subtítulo legible gris slate */
    margin: 0;
    font-weight: 600;
}

.login-content {
    margin-bottom: 30px;
}

.login-instruction {
    font-size: 14px;
    color: var(--text-secondary);      /* Texto legible */
    line-height: 1.5;
    margin-bottom: 25px;
}

.oauth-button-container {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.login-footer {
    border-top: 1px solid var(--border-color); /* Borde claro */
    padding-top: 20px;
}

.login-footer p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 12px 0;
}

.security-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-green);
    background-color: rgba(16, 185, 129, 0.08); /* Verde suave translúcido */
    padding: 5px 12px;
    border-radius: 20px;
}

.shield-icon {
    width: 12px;
    height: 12px;
}

/* ==========================================================================
   UTILIDADES Y PANTALLAS DE CARGA
   ========================================================================== */

.loader-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.spinner {
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid var(--accent-indigo);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s cubic-bezier(0.55, 0.055, 0.675, 0.19) infinite;
    margin-bottom: 15px;
}

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

/* AVION JET CONTAINER */
.jet-container {
    text-align: center;
    margin-top: 30px;
}

.jet-image {
    width: 750px;
    max-width: 90%;
    height: auto;
    object-fit: contain;
    mix-blend-mode: multiply;
}

/* ==========================================================================
   RESPONSIVIDAD Y MENÚ MÓVIL DESPLEGABLE
   ========================================================================== */

/* Botón flotante para menú (Oculto en escritorio) */
.menu-toggle {
    display: none;
}

@media (max-width: 1024px) {
    .main-content {
        padding: 30px;
    }
}

@media (max-width: 768px) {
    /* Comportamiento responsivo para la nueva barra lateral y contenido */
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }
    
    body.sidebar-mobile-open .app-sidebar {
        transform: translateX(0);
    }
    
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(2px);
        z-index: 998;
    }
    
    body.sidebar-mobile-open .sidebar-backdrop {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
        margin-top: 60px !important;
        padding: 24px 16px !important;
        width: 100% !important;
    }

    .user-name {
        display: none; /* En móviles sólo mostrar el avatar y logout */
    }
    
    .grid-form {
        grid-template-columns: 1fr;
    }

    /* Reglas Responsivas de la Barra de Chats en Móvil (Evita el amontonamiento) */
    .chat-container {
        height: 60vh;
        min-height: 440px;
        max-height: 580px;
        width: 100%;
        margin-top: 10px;
    }
    
    .chat-bottom-controls {
        margin: 12px auto;
        padding: 0 10px;
        gap: 12px;
    }

    .history-toggle-btn, .new-chat-btn-bottom {
        padding: 10px 14px;
        font-size: 13px;
        flex: 1;
        justify-content: center;
    }

    .history-dropup-content {
        width: calc(100vw - 32px);
        max-width: 320px;
        left: 0;
    }

    .chat-title-text span {
        max-width: 170px;
    }
}

/* Indicador de sesión activa en barra lateral */
.user-session-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    background-color: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px #22c55e, 0 0 16px #22c55e;
    display: inline-block;
    flex-shrink: 0;
}

.status-text {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Plus Jakarta Sans', sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* ==========================================================================
   MODO EMBEBIDO DENTRO DEL CONTENEDOR DERECHO DE SIGMA
   ========================================================================== */
html.in-iframe, body.in-iframe {
    background-color: #f8fafc !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.in-iframe .app-topbar,
body.in-iframe .app-sidebar,
body.in-iframe .sidebar-backdrop,
body.in-iframe .topbar-back-sigma {
    display: none !important;
}

body.in-iframe .app-layout {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

body.in-iframe .main-content,
body.in-iframe .main-container,
body.in-iframe .dashboard-container,
body.in-iframe .chat-layout-wrapper {
    margin-left: 0 !important;
    margin-top: 0 !important;
    padding: 20px 24px !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    min-height: auto !important;
}

/* Permitir que las tarjetas de búsqueda y totales en consultar_fallas aprovechen el 100% del ancho */
body.in-iframe .top-cards-container {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    gap: 20px !important;
}

body.in-iframe .search-card {
    flex: 1.3 1 450px !important;
    max-width: none !important;
    width: auto !important;
}

body.in-iframe .total-card {
    flex: 1 1 350px !important;
    max-width: none !important;
    width: auto !important;
}

