/* ==============================================
   AsistenteIA - Chat Interface Styles
   Panel Cliente
   ============================================== */

.asistente-ia-container {
    display: flex;
    height: calc(100vh - 180px);
    min-height: 400px;
    gap: 0;
    position: relative;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #f8fafc;
}

.dark .asistente-ia-container {
    border-color: #334155;
    background: #0f172a;
}

/* ---- Sidebar Toggle (Mobile) ---- */

.asistente-sidebar-toggle {
    display: none;
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 20;
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    cursor: pointer;
    transition: background 0.15s;
}

.asistente-sidebar-toggle:hover {
    background: #e2e8f0;
}

.dark .asistente-sidebar-toggle {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

@media (max-width: 768px) {
    .asistente-sidebar-toggle {
        display: flex;
    }
}

/* ---- Sidebar ---- */

.asistente-sidebar {
    width: 280px;
    min-width: 280px;
    border-right: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dark .asistente-sidebar {
    border-right-color: #334155;
    background: rgba(30, 41, 59, 0.5);
}

@media (max-width: 768px) {
    .asistente-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 15;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: none;
    }

    .asistente-sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    }
}

.asistente-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.dark .asistente-sidebar-header {
    border-bottom-color: #334155;
}

.asistente-sidebar-header h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.dark .asistente-sidebar-header h3 {
    color: #cbd5e1;
}

/* ---- New Conversation Button ---- */

.asistente-btn-new {
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    background: #0ea5e9;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.asistente-btn-new:hover {
    background: #0369a1;
}

/* ---- Conversation List ---- */

.asistente-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.asistente-conv-item {
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    margin-bottom: 2px;
    padding-right: 2.25rem;
}

.asistente-conv-item:hover {
    background: #f1f5f9;
}

.dark .asistente-conv-item:hover {
    background: rgba(51, 65, 85, 0.5);
}

.asistente-conv-active {
    background: rgba(14, 165, 233, 0.08);
    border-left: 3px solid #0ea5e9;
}

.dark .asistente-conv-active {
    background: rgba(14, 165, 233, 0.15);
}

.asistente-conv-titulo {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.3;
    word-break: break-word;
}

.dark .asistente-conv-titulo {
    color: #e2e8f0;
}

.asistente-conv-fecha {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 0.125rem;
}

/* ---- Delete Button (always visible) ---- */

.asistente-conv-delete {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    padding: 0.3rem;
    border-radius: 0.375rem;
    background: #f1f5f9;
    color: #94a3b8;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.dark .asistente-conv-delete {
    background: #1e293b;
    border-color: #334155;
    color: #64748b;
}

.asistente-conv-delete:hover {
    color: #ef4444;
    background: #fef2f2;
    border-color: #fecaca;
}

.dark .asistente-conv-delete:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.asistente-empty-text {
    text-align: center;
    color: #94a3b8;
    font-size: 0.8rem;
    padding: 1rem;
    margin: 0;
}

/* ---- Main Chat ---- */

.asistente-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---- Messages ---- */

.asistente-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ---- Welcome ---- */

.asistente-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
    gap: 0.75rem;
}

.asistente-welcome-icon {
    width: 4rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    background: rgba(14, 165, 233, 0.1);
}

.asistente-welcome h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.dark .asistente-welcome h2 {
    color: #e2e8f0;
}

.asistente-welcome p {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0;
}

.asistente-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.5rem;
    max-width: 500px;
}

.asistente-suggestion {
    padding: 0.5rem 0.875rem;
    border-radius: 1rem;
    font-size: 0.8125rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s;
}

.asistente-suggestion:hover {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.3);
    color: #0369a1;
}

.dark .asistente-suggestion {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

/* ---- Messages ---- */

.asistente-msg {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: asistente-fade-in 0.2s ease;
}

@keyframes asistente-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.asistente-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.asistente-msg-assistant {
    align-self: flex-start;
}

.asistente-msg-avatar {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.asistente-msg-user .asistente-msg-avatar {
    background: #0ea5e9;
    color: white;
}

.asistente-msg-assistant .asistente-msg-avatar {
    background: #e2e8f0;
    color: #475569;
}

.dark .asistente-msg-assistant .asistente-msg-avatar {
    background: #334155;
    color: #cbd5e1;
}

.asistente-msg-content {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
}

.asistente-msg-user .asistente-msg-content {
    background: #0ea5e9;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.asistente-msg-assistant .asistente-msg-content {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 0.25rem;
}

.dark .asistente-msg-assistant .asistente-msg-content {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

/* Markdown inside messages */
.asistente-msg-content p {
    margin: 0 0 0.5rem;
}

.asistente-msg-content p:last-child {
    margin-bottom: 0;
}

.asistente-msg-content strong {
    font-weight: 600;
}

.asistente-msg-content ul,
.asistente-msg-content ol {
    margin: 0.25rem 0;
    padding-left: 1.25rem;
}

.asistente-msg-content li {
    margin-bottom: 0.125rem;
}

.asistente-msg-content h1,
.asistente-msg-content h2,
.asistente-msg-content h3,
.asistente-msg-content h4 {
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
    line-height: 1.3;
}

.asistente-msg-content h1 { font-size: 1.05em; }
.asistente-msg-content h2 { font-size: 1em; }
.asistente-msg-content h3 { font-size: 0.95em; }
.asistente-msg-content h4 { font-size: 0.9em; }

.asistente-msg-content table {
    border-collapse: collapse;
    width: max-content;
    max-width: 100%;
    font-size: 0.8125rem;
    margin: 0.5rem 0;
    display: block;
    overflow-x: auto;
}

.asistente-msg-content th,
.asistente-msg-content td {
    border: 1px solid #94a3b8;
    padding: 0.35rem 0.75rem;
    text-align: left;
    white-space: nowrap;
}

.asistente-msg-content th {
    background: #e2e8f0;
    font-weight: 600;
    color: #334155;
}

.asistente-msg-content tr:nth-child(even) td {
    background: #f1f5f9;
}

.dark .asistente-msg-content th {
    background: #1e293b;
    color: #94a3b8;
    border-color: #475569;
}

.dark .asistente-msg-content td {
    border-color: #334155;
}

.dark .asistente-msg-content tr:nth-child(even) td {
    background: #0f172a;
}

/* ---- Typing Indicator ---- */

.asistente-typing {
    display: flex;
    gap: 4px;
    padding: 0.25rem 0;
}

.asistente-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: asistente-bounce 1.2s infinite;
}

.asistente-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.asistente-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes asistente-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ---- Estado Tags ---- */

.asistente-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0.5rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background: white;
}

.dark .asistente-tags {
    border-top-color: #334155;
    background: #0f172a;
}

.asistente-tag {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.asistente-tag:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.asistente-tag-sin_asignar {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}
.asistente-tag-sin_asignar:hover:not(:disabled) {
    background: #e2e8f0;
    border-color: #94a3b8;
}
.dark .asistente-tag-sin_asignar {
    background: #1e293b;
    border-color: #475569;
    color: #94a3b8;
}

.asistente-tag-asignado {
    background: #fefce8;
    border-color: #fde047;
    color: #854d0e;
}
.asistente-tag-asignado:hover:not(:disabled) {
    background: #fef9c3;
    border-color: #facc15;
}
.dark .asistente-tag-asignado {
    background: rgba(250, 204, 21, 0.1);
    border-color: rgba(250, 204, 21, 0.4);
    color: #fde047;
}

.asistente-tag-confirmado {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}
.asistente-tag-confirmado:hover:not(:disabled) {
    background: #dbeafe;
    border-color: #60a5fa;
}
.dark .asistente-tag-confirmado {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.4);
    color: #93c5fd;
}

.asistente-tag-en_ruta {
    background: #f0f9ff;
    border-color: #7dd3fc;
    color: #0369a1;
}
.asistente-tag-en_ruta:hover:not(:disabled) {
    background: #e0f2fe;
    border-color: #38bdf8;
}
.dark .asistente-tag-en_ruta {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.4);
    color: #7dd3fc;
}

.asistente-tag-completado {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}
.asistente-tag-completado:hover:not(:disabled) {
    background: #dcfce7;
    border-color: #4ade80;
}
.dark .asistente-tag-completado {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.4);
    color: #86efac;
}

.asistente-tag-cancelado {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}
.asistente-tag-cancelado:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #f87171;
}
.dark .asistente-tag-cancelado {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.asistente-tag-ausente {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}
.asistente-tag-ausente:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #f87171;
}
.dark .asistente-tag-ausente {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

/* ---- Input Area ---- */

.asistente-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background: white;
}

.dark .asistente-input-area {
    border-top-color: #334155;
    background: #0f172a;
}

.asistente-input-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.asistente-input {
    flex: 1;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    background: #f8fafc;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    max-height: 120px;
    font-family: inherit;
}

.asistente-input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.15);
}

.dark .asistente-input {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

.asistente-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.asistente-btn-send {
    padding: 0.625rem;
    border-radius: 0.75rem;
    background: #0ea5e9;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
}

.asistente-btn-send:hover:not(:disabled) {
    background: #0369a1;
}

.asistente-btn-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.asistente-disclaimer {
    font-size: 0.7rem;
    color: #94a3b8;
    text-align: center;
    margin: 0.5rem 0 0;
}

/* ==============================================
   Chat Flotante — Floating Widget
   ============================================== */

.chat-flotante-wrapper {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
}

/* ---- Trigger Button ---- */

.chat-flotante-btn {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.chat-flotante-btn:hover {
    background: transparent;
    transform: translateY(-2px);
}

.chat-flotante-btn-label {
    display: none;
}

/* ---- Modal Panel ---- */

.chat-flotante-modal {
    width: 380px;
    max-width: calc(100vw - 2rem);
    height: 520px;
    max-height: calc(100vh - 6rem);
    border-radius: 1rem;
    background: white;
    border: 1px solid #e2e8f0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
}

.dark .chat-flotante-modal {
    background: #0f172a;
    border-color: #334155;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ---- Header ---- */

.chat-flotante-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: #0ea5e9;
    color: white;
    flex-shrink: 0;
}

.chat-flotante-header-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.chat-flotante-header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-flotante-btn-icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.chat-flotante-btn-icon:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ---- Messages ---- */

.chat-flotante-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

/* ---- Welcome State ---- */

.chat-flotante-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    gap: 0.75rem;
    padding: 1.5rem;
    color: #64748b;
}

.dark .chat-flotante-welcome {
    color: #94a3b8;
}

.chat-flotante-welcome svg {
    color: #0ea5e9;
    opacity: 0.7;
}

.chat-flotante-welcome p {
    font-size: 0.8125rem;
    margin: 0;
    color: #475569;
}

.dark .chat-flotante-welcome p {
    color: #94a3b8;
}

.chat-flotante-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    width: 100%;
    margin-top: 0.25rem;
}

.chat-flotante-suggestion {
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.chat-flotante-suggestion:hover {
    background: rgba(14, 165, 233, 0.08);
    border-color: rgba(14, 165, 233, 0.3);
    color: #0369a1;
}

.dark .chat-flotante-suggestion {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

/* ---- Message Bubbles ---- */

.chat-flotante-msg {
    display: flex;
    animation: asistente-fade-in 0.2s ease;
}

.chat-flotante-msg-user {
    justify-content: flex-end;
}

.chat-flotante-msg-assistant {
    justify-content: flex-start;
}

.chat-flotante-msg-content {
    max-width: 85%;
    padding: 0.625rem 0.875rem;
    border-radius: 1rem;
    font-size: 0.8125rem;
    line-height: 1.55;
}

.chat-flotante-msg-user .chat-flotante-msg-content {
    background: #0ea5e9;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.chat-flotante-msg-assistant .chat-flotante-msg-content {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 0.25rem;
}

.dark .chat-flotante-msg-assistant .chat-flotante-msg-content {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

.chat-flotante-msg-content p {
    margin: 0 0 0.4rem;
}

.chat-flotante-msg-content p:last-child {
    margin-bottom: 0;
}

.chat-flotante-msg-content ul,
.chat-flotante-msg-content ol {
    margin: 0.25rem 0;
    padding-left: 1.1rem;
}

.chat-flotante-msg-content li {
    margin-bottom: 0.1rem;
}

.chat-flotante-msg-content strong {
    font-weight: 600;
}

.chat-flotante-msg-content h1,
.chat-flotante-msg-content h2,
.chat-flotante-msg-content h3,
.chat-flotante-msg-content h4 {
    font-weight: 600;
    margin: 0.4rem 0 0.2rem;
    line-height: 1.3;
}

.chat-flotante-msg-content h1 { font-size: 1em; }
.chat-flotante-msg-content h2 { font-size: 0.95em; }
.chat-flotante-msg-content h3 { font-size: 0.9em; }
.chat-flotante-msg-content h4 { font-size: 0.875em; }

.chat-flotante-msg-content table {
    border-collapse: collapse;
    width: max-content;
    max-width: 100%;
    font-size: 0.75rem;
    margin: 0.4rem 0;
    display: block;
    overflow-x: auto;
}

.chat-flotante-msg-content th,
.chat-flotante-msg-content td {
    border: 1px solid #94a3b8;
    padding: 0.3rem 0.6rem;
    text-align: left;
    white-space: nowrap;
}

.chat-flotante-msg-content th {
    background: #cbd5e1;
    font-weight: 600;
    color: #334155;
}

.chat-flotante-msg-content tr:nth-child(even) td {
    background: #f1f5f9;
}

.dark .chat-flotante-msg-content th {
    background: #1e293b;
    color: #94a3b8;
    border-color: #475569;
}

.dark .chat-flotante-msg-content td {
    border-color: #334155;
}

.dark .chat-flotante-msg-content tr:nth-child(even) td {
    background: #0f172a;
}

/* ---- Input Area ---- */

.chat-flotante-input-area {
    padding: 0.75rem;
    border-top: 1px solid #e2e8f0;
    background: white;
    flex-shrink: 0;
}

.dark .chat-flotante-input-area {
    border-top-color: #334155;
    background: #0f172a;
}

.chat-flotante-input-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-flotante-input {
    flex: 1;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 0.625rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    background: #f8fafc;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    max-height: 80px;
    font-family: inherit;
}

.chat-flotante-input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.15);
}

.dark .chat-flotante-input {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

.chat-flotante-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-flotante-btn-send {
    padding: 0.5rem;
    border-radius: 0.625rem;
    background: #0ea5e9;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
}

.chat-flotante-btn-send:hover:not(:disabled) {
    background: #0284c7;
}

.chat-flotante-btn-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---- Mobile ---- */

@media (max-width: 640px) {
    .chat-flotante-wrapper {
        bottom: 1rem;
        right: 1rem;
    }

    .chat-flotante-modal {
        width: calc(100vw - 2rem);
        height: 75vh;
        max-height: 75vh;
    }
}

/* ---- Robot Character — Floating Button ---- */

.robot-character {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    animation: robot-idle-float 2.8s ease-in-out infinite;
    pointer-events: none;
    filter: drop-shadow(0 4px 10px rgba(14, 165, 233, 0.55)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
}

.robot-antenna-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.robot-antenna-ball {
    width: 5px;
    height: 5px;
    background: #0ea5e9;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(14, 165, 233, 0.8);
}

.robot-antenna-stem {
    width: 3px;
    height: 5px;
    background: #7dd3fc;
    border-radius: 0 0 2px 2px;
}

.robot-head {
    width: 30px;
    height: 23px;
    background: #f0f9ff;
    border-radius: 6px;
    border: 1.5px solid #bae6fd;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.robot-visor {
    background: #1e293b;
    border-radius: 3px;
    padding: 2px 4px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.robot-eye {
    width: 5px;
    height: 5px;
    background: #38bdf8;
    border-radius: 50%;
    animation:
        robot-eye-glow 1.8s ease-in-out infinite alternate,
        robot-eye-blink 4s ease-in-out infinite;
}

.robot-eye:nth-child(2) {
    animation-delay: 0.35s, 0.15s;
}

.robot-mouth {
    display: flex;
    gap: 2px;
}

.robot-mouth span {
    width: 4px;
    height: 2px;
    background: #94a3b8;
    border-radius: 1px;
}

/* Idle float */
@keyframes robot-idle-float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

/* Eye glow pulse */
@keyframes robot-eye-glow {
    from { background: #7dd3fc; box-shadow: 0 0 2px rgba(56, 189, 248, 0.5); }
    to   { background: #0ea5e9; box-shadow: 0 0 7px rgba(56, 189, 248, 1), 0 0 12px rgba(56, 189, 248, 0.4); }
}

/* Eye blink */
@keyframes robot-eye-blink {
    0%, 88%, 100% { transform: scaleY(1); }
    91%, 95%      { transform: scaleY(0.06); }
}

/* Hover wiggle — overrides idle float */
@keyframes robot-wiggle {
    0%   { transform: rotate(0deg) scale(1); }
    15%  { transform: rotate(-15deg) scale(1.1); }
    35%  { transform: rotate(12deg) scale(1.05); }
    55%  { transform: rotate(-8deg) scale(1.08); }
    75%  { transform: rotate(5deg) scale(1.03); }
    100% { transform: rotate(0deg) scale(1); }
}

.chat-flotante-btn:hover .robot-character {
    animation: robot-wiggle 0.5s ease forwards;
    filter: drop-shadow(0 6px 14px rgba(14, 165, 233, 0.75)) drop-shadow(0 2px 5px rgba(0, 0, 0, 0.2));
}

/* Estado thinking — ojos naranja/ámbar */
.robot-thinking .robot-eye {
    animation:
        robot-eye-think 0.5s ease-in-out infinite alternate,
        robot-eye-blink 4s ease-in-out infinite;
}

@keyframes robot-eye-think {
    from { background: #f97316; box-shadow: 0 0 3px rgba(249, 115, 22, 0.6); }
    to   { background: #fbbf24; box-shadow: 0 0 8px rgba(251, 191, 36, 1), 0 0 14px rgba(251, 191, 36, 0.4); }
}

/* Estado thinking — cabeza también se mueve */
.robot-character.robot-thinking {
    animation: robot-head-think 0.7s ease-in-out infinite;
}

@keyframes robot-head-think {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(-10deg); }
    75%      { transform: rotate(10deg); }
}

/* ---- Robot Mini (header del modal) ---- */

.robot-mini.robot-character {
    animation: none;
    gap: 0;
    filter: none;
    flex-shrink: 0;
}

.robot-mini .robot-head {
    width: 22px;
    height: 16px;
    border-radius: 4px;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.18);
    gap: 2px;
}

.robot-mini .robot-visor {
    padding: 1px 3px;
    gap: 3px;
    border-radius: 2px;
}

.robot-mini .robot-eye {
    width: 4px;
    height: 4px;
}

.robot-mini .robot-mouth span {
    width: 3px;
    height: 1.5px;
    background: rgba(255, 255, 255, 0.6);
}

.robot-mini.robot-thinking {
    animation: robot-head-think 0.7s ease-in-out infinite;
}

/* Bounce al abrir modal */
@keyframes robot-bounce-open {
    0%   { transform: scale(0.5) rotate(-15deg); opacity: 0.4; }
    40%  { transform: scale(1.35) rotate(10deg); opacity: 1; }
    65%  { transform: scale(0.88) rotate(-5deg); }
    85%  { transform: scale(1.1) rotate(3deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.robot-mini.robot-open {
    animation: robot-bounce-open 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

/* ---- Agent Header ---- */

.asistente-agent-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
    position: relative;
}

.dark .asistente-agent-header {
    color: #94a3b8;
    border-color: #1e293b;
    background: #0f172a;
}

/* ---- Agent selector dropdown (en el header del chat) ---- */

.asistente-agent-header-dropdown {
    position: relative;
}

.asistente-agent-selector-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.25rem 0.625rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.asistente-agent-selector-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #1e293b;
}

.dark .asistente-agent-selector-btn {
    color: #94a3b8;
    border-color: #334155;
}

.dark .asistente-agent-selector-btn:hover {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

.asistente-agent-chevron {
    display: flex;
    align-items: center;
    transition: transform 0.15s;
}

.asistente-agent-chevron-open {
    transform: rotate(180deg);
}

.asistente-agent-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.375rem);
    left: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    min-width: 220px;
    z-index: 50;
    overflow: hidden;
}

.dark .asistente-agent-dropdown-menu {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
}

[x-cloak] {
    display: none !important;
}

.asistente-agent-dropdown-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-align: left;
    padding: 0.625rem 0.875rem;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #f1f5f9;
}

.asistente-agent-dropdown-item:last-child {
    border-bottom: none;
}

.asistente-agent-dropdown-item:hover {
    background: #f8fafc;
}

.dark .asistente-agent-dropdown-item {
    border-bottom-color: #334155;
}

.dark .asistente-agent-dropdown-item:hover {
    background: #0f172a;
}

.asistente-agent-dropdown-item-active {
    background: #eff6ff;
}

.dark .asistente-agent-dropdown-item-active {
    background: rgba(29, 78, 216, 0.15);
}

.asistente-agent-dropdown-item-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1e293b;
    display: block;
}

.dark .asistente-agent-dropdown-item-name {
    color: #e2e8f0;
}

.asistente-agent-dropdown-item-active .asistente-agent-dropdown-item-name {
    color: #1d4ed8;
}

.dark .asistente-agent-dropdown-item-active .asistente-agent-dropdown-item-name {
    color: #60a5fa;
}

.asistente-agent-dropdown-item-desc {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 0.125rem;
    display: block;
    font-weight: 400;
}

/* ---- Agent locked badge (conversación activa) ---- */

.asistente-agent-locked {
    display: inline-flex;
    align-items: center;
    color: #94a3b8;
    cursor: help;
    margin-left: 0.125rem;
}

.dark .asistente-agent-locked {
    color: #475569;
}

/* ---- SVG Icon Size Normalization ----
   Plugin views are not scanned by Tailwind JIT, so Tailwind utility classes
   like w-4 h-4 on heroicons are not compiled. These rules provide explicit
   fallback sizes for every heroicon container in this plugin.
   ----------------------------------------- */

.asistente-agent-header > svg,
.asistente-agent-selector-btn svg,
.asistente-agent-chevron svg,
.asistente-agent-locked svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.asistente-agent-chevron svg,
.asistente-agent-locked svg {
    width: 0.75rem;
    height: 0.75rem;
}

.asistente-msg-avatar svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.asistente-welcome-icon {
    overflow: hidden;
}

.asistente-welcome-icon svg {
    width: 2.5rem;
    height: 2.5rem;
}

.asistente-sidebar-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.asistente-btn-new svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.asistente-conv-delete svg {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
}

.asistente-btn-send svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.asistente-btn-send-spin {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: asistente-spin 1s linear infinite;
}

@keyframes asistente-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.chat-flotante-btn-icon svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.chat-flotante-welcome svg {
    width: 2rem;
    height: 2rem;
}

.chat-flotante-btn-send svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* ---- Agent Dropdown (floating chat header) ---- */

.chat-flotante-agent-dropdown {
    position: relative;
}

.chat-flotante-agent-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 0.375rem;
    color: white;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.chat-flotante-agent-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chat-flotante-agent-chevron {
    display: flex;
    align-items: center;
    transition: transform 0.15s;
}

.chat-flotante-agent-chevron svg {
    width: 0.75rem;
    height: 0.75rem;
    flex-shrink: 0;
}

.chat-flotante-agent-chevron.rotate-180 {
    transform: rotate(180deg);
}

.chat-flotante-agent-menu {
    position: absolute;
    top: calc(100% + 0.375rem);
    left: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    z-index: 50;
    overflow: hidden;
}

.dark .chat-flotante-agent-menu {
    background: #1e293b;
    border-color: #334155;
}

.chat-flotante-agent-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: #334155;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.1s;
}

.chat-flotante-agent-item:hover {
    background: #f1f5f9;
}

.dark .chat-flotante-agent-item {
    color: #e2e8f0;
}

.dark .chat-flotante-agent-item:hover {
    background: #334155;
}

.chat-flotante-agent-item-active {
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
}

.dark .chat-flotante-agent-item-active {
    background: rgba(29, 78, 216, 0.2);
    color: #60a5fa;
}
