/**
 * AscensorDocs AI Real — Chat CSS
 */

/* ── Botón toggle ────────────────────────────────────────────────────────────── */
.ascdocs-chat-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}
.ascdocs-chat-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-accent);
    border-color: var(--color-accent-dim);
}

/* ── Tooltip flotante ────────────────────────────────────────────────────────── */
.acm-tooltip {
    position: fixed;
    bottom: calc(var(--header-height) + 12px);
    right: 60px;
    background: var(--color-accent);
    color: #fff;
    font-size: 12px;
    font-family: var(--font-ui);
    padding: 7px 12px;
    border-radius: var(--radius);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s, transform 0.2s;
    z-index: calc(var(--z-chat) + 1);
    box-shadow: var(--shadow-md);
}
.acm-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.acm-tooltip-arrow {
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 5px solid var(--color-accent);
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.ascdocs-chat-modal {
    position: fixed;
    bottom: calc(var(--header-height) + 12px);
    right: 16px;
    width: var(--chat-modal-width, 360px);
    max-height: var(--chat-modal-height, 520px);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: var(--z-chat);
    opacity: 0;
    transform: translateY(10px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}
.ascdocs-chat-modal.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
.acm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}
.acm-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.acm-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.acm-header-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.acm-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
    font-family: var(--font-ui);
    line-height: 1;
}
.acm-context-badge {
    font-size: 11px;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    line-height: 1;
}
.acm-context-badge--active {
    color: var(--color-accent);
}
.acm-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    flex-shrink: 0;
}
.acm-close:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

/* ── Barra de expediente activo ──────────────────────────────────────────────── */
.acm-expediente-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: color-mix(in srgb, var(--color-accent) 8%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 15%, transparent);
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--color-accent);
    flex-shrink: 0;
}

/* ── Mensajes ────────────────────────────────────────────────────────────────── */
.acm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-scrollbar) transparent;
}
.acm-message {
    display: flex;
    animation: acm-fadein 0.2s ease;
}
.acm-message--user {
    justify-content: flex-end;
}
@keyframes acm-fadein {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.acm-bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    font-family: var(--font-ui);
}
.acm-message--ai .acm-bubble {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-light);
    color: var(--color-text-primary);
    border-bottom-left-radius: 3px;
}
.acm-message--user .acm-bubble {
    background: var(--color-accent);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.acm-message--error .acm-bubble {
    background: var(--color-error-bg, #fef2f2);
    border: 1px solid var(--color-error, #ef4444);
    color: var(--color-error, #ef4444);
}

/* Animación de puntos "pensando" */
.acm-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 16px;
}
.acm-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-text-muted);
    animation: acm-bounce 1.2s infinite ease-in-out;
}
.acm-dots span:nth-child(2) { animation-delay: 0.2s; }
.acm-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes acm-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* ── Footer / input ──────────────────────────────────────────────────────────── */
.acm-footer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--color-border-light);
    flex-shrink: 0;
}
.acm-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text-primary);
    font-size: 13px;
    font-family: var(--font-ui);
    resize: none;
    line-height: 1.5;
    transition: border-color 0.15s;
    outline: none;
}
.acm-input:focus {
    border-color: var(--color-accent);
}
.acm-input::placeholder {
    color: var(--color-text-muted);
}
.acm-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: var(--color-accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}
.acm-send:hover:not(:disabled) { background: var(--color-accent-hover); }
.acm-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Separador de contexto ───────────────────────────────────────────────────── */
.acm-separator {
    text-align: center;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--color-text-muted);
    padding: 4px 0;
}

/* ── Link de navegación ──────────────────────────────────────────────────────── */
.acm-nav-link {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 12px;
    background: var(--color-accent);
    color: #fff;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s;
}
.acm-nav-link:hover { opacity: 0.85; }

.acm-bullet {
    display: block;
    margin: 2px 0;
}

/* ── Bloque de navegación a expediente ───────────────────────────────────────── */
.acm-nav-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding: 8px 10px;
    background: color-mix(in srgb, var(--color-accent) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-accent) 20%, transparent);
    border-radius: var(--radius);
    gap: 8px;
}
.acm-nav-label {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--color-accent);
    flex: 1;
}
.acm-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--color-accent);
    color: #fff;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.acm-nav-link:hover { opacity: 0.85; }

/* ── Acción de expediente (botón tras respuesta) ─────────────────────────────── */
.acm-expediente-action {
    display: flex;
    justify-content: flex-start;
    padding: 0 0 4px 0;
    animation: acm-fadein 0.2s ease;
}

.acm-share-link {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    border-radius: var(--radius);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    margin-right: 6px;
}
.acm-share-link:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}
