/* ─── Copilot widget — vanilla, sin dependencias ─────────────────────
 * Estilos del panel flotante. Todas las clases bajo `.adcp-` para
 * minimizar colisión cuando el widget se monta en el sistema del cliente.
 * ----------------------------------------------------------------- */

:root {
    --adcp-primary: #4f46e5;
    --adcp-primary-fg: #ffffff;
    --adcp-bg: #ffffff;
    --adcp-fg: #0f172a;
    --adcp-muted: #64748b;
    --adcp-border: #e2e8f0;
    --adcp-bubble-assistant: #f1f5f9;
    --adcp-bubble-user: #4f46e5;
    --adcp-bubble-user-fg: #ffffff;
    --adcp-tool: #fef3c7;
    --adcp-tool-fg: #78350f;
    --adcp-error: #fee2e2;
    --adcp-error-fg: #991b1b;
    --adcp-shadow: 0 10px 30px rgba(15, 23, 42, .15), 0 4px 6px rgba(15, 23, 42, .05);
    --adcp-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Container — fixed bottom-right; en modo embedded (iframe full-page) lo
   sobrescribimos a 100% ancho/alto. */
.adcp-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2147483000;
    font-family: var(--adcp-font);
    font-size: 14px;
    color: var(--adcp-fg);
    line-height: 1.45;
}

.adcp-root--inline {
    position: static;
    inset: auto;
    width: 100%;
    height: 100%;
    bottom: auto;
    right: auto;
}

/* Floating action button */
.adcp-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--adcp-primary);
    color: var(--adcp-primary-fg);
    border: none;
    box-shadow: var(--adcp-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: transform .12s ease;
}
.adcp-fab:hover { transform: scale(1.05); }
.adcp-fab--hidden { display: none; }

/* Panel */
.adcp-panel {
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background: var(--adcp-bg);
    border: 1px solid var(--adcp-border);
    border-radius: 16px;
    box-shadow: var(--adcp-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.adcp-panel--open { display: flex; }

.adcp-root--inline .adcp-panel {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: none;
    box-shadow: none;
    display: flex;
}

.adcp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--adcp-primary);
    color: var(--adcp-primary-fg);
}
.adcp-header__title {
    font-weight: 600;
    font-size: 14px;
}
.adcp-header__subtitle {
    opacity: .85;
    font-size: 12px;
    font-weight: 400;
}
.adcp-header__close {
    background: transparent;
    border: none;
    color: var(--adcp-primary-fg);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.adcp-header__left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.adcp-header__menu {
    background: transparent;
    border: none;
    color: var(--adcp-primary-fg);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.adcp-header__menu:hover { opacity: .85; }

/* Body — wrapper para mensajes + drawer absoluto */
.adcp-body {
    position: relative;
    flex: 1;
    display: flex;
    overflow: hidden;
}

.adcp-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafbfc;
}

/* Drawer de historial — overlay sobre la zona de mensajes */
.adcp-drawer {
    position: absolute;
    inset: 0;
    background: var(--adcp-bg);
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.adcp-drawer[hidden] { display: none; }
.adcp-drawer__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--adcp-border);
}
.adcp-drawer__back {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 6px;
    color: var(--adcp-fg);
}
.adcp-drawer__title {
    font-weight: 600;
    color: var(--adcp-fg);
}
.adcp-drawer__new {
    margin: 10px 14px;
    padding: 8px 12px;
    background: var(--adcp-bubble-assistant);
    color: var(--adcp-fg);
    border: 1px dashed var(--adcp-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
}
.adcp-drawer__new:hover { background: #e2e8f0; }
.adcp-drawer__list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.adcp-drawer__empty {
    color: var(--adcp-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px 12px;
}
.adcp-drawer__row {
    display: flex;
    align-items: stretch;
    border-radius: 8px;
    overflow: hidden;
}
.adcp-drawer__row:hover { background: var(--adcp-bubble-assistant); }
.adcp-drawer__row--active { background: #e0e7ff; }
.adcp-drawer__row-main {
    flex: 1;
    padding: 8px 10px;
    cursor: pointer;
    min-width: 0;
}
.adcp-drawer__row-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--adcp-fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.adcp-drawer__row-meta {
    font-size: 11px;
    color: var(--adcp-muted);
    margin-top: 2px;
}
.adcp-drawer__row-del {
    background: transparent;
    border: none;
    color: var(--adcp-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0 10px;
    line-height: 1;
}
.adcp-drawer__row-del:hover { color: var(--adcp-error-fg); }

.adcp-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.adcp-msg--assistant {
    background: var(--adcp-bubble-assistant);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.adcp-msg--user {
    background: var(--adcp-bubble-user);
    color: var(--adcp-bubble-user-fg);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.adcp-msg--tool {
    background: var(--adcp-tool);
    color: var(--adcp-tool-fg);
    align-self: flex-start;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    padding: 6px 10px;
}
.adcp-msg--error {
    background: var(--adcp-error);
    color: var(--adcp-error-fg);
    align-self: stretch;
}
.adcp-msg__caret {
    display: inline-block;
    width: 6px;
    height: 14px;
    background: currentColor;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: adcp-blink 1s steps(2) infinite;
}
@keyframes adcp-blink { 50% { opacity: 0; } }

/* Typing indicator — 3 puntos animados mientras esperamos al LLM. */
.adcp-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 2px;
}
.adcp-typing__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--adcp-muted);
    opacity: .35;
    animation: adcp-bounce 1.2s ease-in-out infinite;
}
.adcp-typing__dot:nth-child(2) { animation-delay: .15s; }
.adcp-typing__dot:nth-child(3) { animation-delay: .30s; }
@keyframes adcp-bounce {
    0%, 80%, 100% { opacity: .35; transform: translateY(0); }
    40%           { opacity: 1;   transform: translateY(-3px); }
}

.adcp-form {
    border-top: 1px solid var(--adcp-border);
    padding: 10px;
    display: flex;
    gap: 8px;
    background: var(--adcp-bg);
}
.adcp-input {
    flex: 1;
    border: 1px solid var(--adcp-border);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    min-height: 36px;
    max-height: 120px;
    color: var(--adcp-fg);
    background: var(--adcp-bg);
}
.adcp-input:focus { outline: 2px solid var(--adcp-primary); outline-offset: -1px; }
.adcp-send {
    background: var(--adcp-primary);
    color: var(--adcp-primary-fg);
    border: none;
    border-radius: 8px;
    padding: 0 14px;
    cursor: pointer;
    font-weight: 600;
}
.adcp-send:disabled { opacity: .5; cursor: not-allowed; }

.adcp-footer {
    font-size: 11px;
    color: var(--adcp-muted);
    text-align: center;
    padding: 4px 0 8px;
    background: var(--adcp-bg);
}
