/* =================================================================
   WF Portal — Copilot Slide-Out Panel
   ================================================================= */

.copilot-panel {
    position: fixed;
    top: 3.5rem;
    right: 0;
    bottom: 0;
    width: 380px;
    z-index: 1025;
    background: var(--theme-background-raised);
    border-left: 1px solid var(--theme-border);
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform 200ms ease;
}

.copilot-panel.hidden {
    transform: translateX(100%);
}

.copilot-panel.show {
    transform: translateX(0);
}

/* Floating tab — always visible, sticks out from panel left edge */
.copilot-tab {
    position: absolute;
    left: -40px;
    top: 0.75rem;
    width: 40px;
    height: 40px;
    border: 1px solid var(--theme-border);
    border-right: none;
    border-radius: var(--theme-radius) 0 0 var(--theme-radius);
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    transition: background 150ms ease;
}

.copilot-tab:hover {
    background: var(--theme-primary-hover);
}

/* Header */
.copilot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--theme-border);
    flex-shrink: 0;
}

.copilot-title {
    font-weight: 600;
    font-size: var(--theme-font-size-base);
    color: var(--theme-text);
}

/* Messages area */
.copilot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Empty state */
.copilot-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--theme-text-muted);
    gap: 0.5rem;
}

.copilot-empty-icon {
    font-size: 2rem;
    opacity: 0.4;
}

.copilot-empty p {
    margin: 0;
    font-size: var(--theme-font-size-sm);
}

/* Message bubbles */
.copilot-msg {
    display: flex;
    max-width: 90%;
}

.copilot-msg-user {
    align-self: flex-end;
}

.copilot-msg-assistant {
    align-self: flex-start;
}

.copilot-msg-content {
    padding: 0.5rem 0.75rem;
    border-radius: var(--theme-radius);
    font-size: var(--theme-font-size-sm);
    line-height: 1.45;
    word-break: break-word;
}

.copilot-msg-user .copilot-msg-content {
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
}

.copilot-msg-assistant .copilot-msg-content {
    background: var(--theme-background-subtle);
    color: var(--theme-text);
}

/* Collapsible "Actions executed" disclosure. The raw tool-call results
   are long + noisy when Copilot chains scan_for_drift / validate_*,
   so they render as a <details> element the user can open on demand. */
.copilot-actions {
    margin: 0;
}

.copilot-actions > summary {
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--theme-text-muted);
    list-style: none;
    padding: 0.15rem 0;
    user-select: none;
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

.copilot-actions > summary:hover {
    opacity: 1;
    color: var(--theme-text);
}

/* Strip the default disclosure triangle + render a custom chevron so
   the bar stays visually quiet in the chat stream. */
.copilot-actions > summary::-webkit-details-marker {
    display: none;
}

.copilot-actions > summary::before {
    content: "▸ ";
    display: inline-block;
    width: 0.85em;
    transition: transform 0.15s ease;
}

.copilot-actions[open] > summary::before {
    content: "▾ ";
}

.copilot-actions-body {
    margin-top: 0.35rem;
    padding: 0.4rem 0.6rem;
    background: var(--theme-background);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    font-size: 0.8rem;
    color: var(--theme-text-muted);
}

.copilot-actions-body ul {
    margin: 0;
    padding-left: 1.2rem;
}

/* Typing indicator */
.copilot-typing {
    display: flex;
    gap: 0.25rem;
    padding: 0.65rem 0.75rem;
}

.copilot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--theme-text-muted);
    animation: copilot-bounce 1.2s infinite ease-in-out;
}

.copilot-typing span:nth-child(2) { animation-delay: 0.2s; }
.copilot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes copilot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Input area */
.copilot-input {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--theme-border);
    flex-shrink: 0;
    align-items: flex-end;
}

.copilot-input textarea {
    flex: 1;
    resize: none;
    font-size: var(--theme-font-size-sm);
    min-height: 80px;
    border-radius: 4px;
}

.copilot-input .btn {
    flex-shrink: 0;
    padding: 0.4rem 0.6rem;
}

/* Responsive — full width on mobile */
@media (max-width: 576px) {
    .copilot-panel {
        width: 100%;
    }
}
