/* ===== Global Chat Panel (GlobalAssistantPanel) ===== */
/*
 * This file provides global (non-scoped) CSS for the chat panel.
 * The panel uses position:fixed and overlays all pages, so it must
 * not be scoped to a single component. Duplicates the rules from
 * ChatPanel.razor.css which is kept for backward compatibility until
 * the old ChatPanel is removed.
 *
 * z-index 2000: above the wizard background (z-index 1000) and
 * all other app content.
 */

/* Floating chat panel */
.chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 420px;
    height: 560px;
    background: var(--klync-dark-bg);
    border: 1.5px solid var(--klync-dark-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    z-index: 2000;
    overflow: hidden;
}

/* FAB button (minimized state) */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--klync-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(var(--klync-primary-rgb), 0.4);
    z-index: 2000;
    border: none;
    transition: transform 0.15s ease;
}

.chat-fab:hover {
    transform: scale(1.05);
}

/* Title bar / drag handle */
.chat-handle {
    height: 48px;
    background: var(--klync-dark-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    cursor: grab;
    user-select: none;
    border-bottom: 1px solid var(--klync-dark-border);
    font-weight: 600;
    font-size: 14px;
    color: var(--klync-dark-text);
    flex-shrink: 0;
}

.chat-minimize-btn {
    background: none;
    border: none;
    color: var(--klync-dark-text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s ease;
}

.chat-minimize-btn:hover {
    color: var(--klync-dark-text);
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

/* Chat bubbles */
.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-bubble-user {
    background: var(--klync-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-bubble-ai {
    background: var(--klync-dark-border);
    color: var(--klync-dark-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Action card bubble */
.chat-action-card {
    background: transparent !important;
    border: 1.5px solid var(--klync-success);
    color: var(--klync-success) !important;
    font-size: 13px;
}

.chat-action-icon {
    margin-right: 6px;
    font-weight: bold;
}

/* Suggestion chips */
.chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.chat-chip {
    background: transparent;
    border: 1.5px solid var(--klync-primary);
    color: var(--klync-primary);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.chat-chip:hover {
    background: rgba(var(--klync-primary-rgb), 0.1);
}

.chat-chip-disabled {
    border-color: var(--klync-dark-border-subtle);
    color: var(--klync-dark-text-faint);
    cursor: default;
    opacity: 0.5;
}

.chat-chip-disabled:hover {
    background: transparent;
}

/* Thinking dots */
.chat-thinking {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 12px 18px;
}

.chat-thinking .dot {
    width: 8px;
    height: 8px;
    background: var(--klync-dark-text-muted);
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: chatBounce 1.4s infinite;
}

.chat-thinking .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-thinking .dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Tool execution status text shown alongside thinking dots */
.chat-tool-status {
    font-size: 0.8rem;
    color: var(--klync-dark-text-secondary);
    font-style: italic;
    margin-right: 6px;
    white-space: nowrap;
}

.chat-tool-status ~ .dot:nth-of-type(1) {
    animation-delay: 0s;
}

.chat-tool-status ~ .dot:nth-of-type(2) {
    animation-delay: 0.2s;
}

.chat-tool-status ~ .dot:nth-of-type(3) {
    animation-delay: 0.4s;
}

@keyframes chatBounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-6px);
    }
}

/* Input area */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--klync-dark-border);
    flex-shrink: 0;
}

.chat-input-area .chat-input-memo textarea {
    min-height: 72px !important;
    height: auto !important;
}

/* Resize grip */
.chat-resize-grip {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: nesw-resize;
    opacity: 0.3;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease;
}

.chat-resize-grip:hover {
    opacity: 0.7;
}

/* Coverage dot indicators in chat handle bar */
.chat-coverage-row {
    display: flex;
    gap: 4px;
    align-items: center;
    margin: 0 8px;
}

.chat-coverage-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--klync-dark-border-subtle);
    transition: background 0.3s ease;
    cursor: default;
}

.chat-coverage-dot.covered {
    background: var(--klync-success);
}

/* Message wrapper for hover action buttons */
.chat-message-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
}

.user-wrapper {
    align-items: flex-end;
}

.ai-wrapper {
    align-items: flex-start;
}

/* Hover-reveal action buttons (edit, retry) on user messages */
.chat-message-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.chat-message-wrapper:hover .chat-message-actions {
    opacity: 1;
}

.chat-action-btn {
    background: var(--klync-dark-border-subtle);
    border: none;
    border-radius: 4px;
    color: var(--klync-dark-text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    transition: background 0.1s ease, color 0.1s ease;
}

.chat-action-btn:hover {
    background: var(--klync-dark-text-faint);
    color: var(--klync-dark-text);
}

/* Degradation banner */
.chat-degraded-banner {
    background: var(--klync-warning-bg);
    color: var(--klync-warning-text);
    padding: 8px 16px;
    font-size: 13px;
    text-align: center;
    border-bottom: 1px solid var(--klync-warning-border);
    flex-shrink: 0;
}

/* Budget warning bar */
.chat-budget-warning {
    background: var(--klync-warning-bg);
    color: var(--klync-warning);
    padding: 6px 12px;
    font-size: 12px;
    text-align: center;
    border-top: 1px solid var(--klync-warning-border);
    flex-shrink: 0;
}

/* Error card bubble */
.chat-error-card {
    background: var(--klync-danger-bg) !important;
    border-left: 3px solid var(--klync-danger) !important;
    color: var(--klync-danger-text) !important;
}

/* System notice bubble */
.chat-system-notice {
    background: var(--klync-primary-subtle-bg) !important;
    border-left: 3px solid var(--klync-primary) !important;
    color: var(--klync-primary-light) !important;
    font-style: italic;
}

/* Try Again button inside error cards */
.chat-try-again-btn {
    margin-top: 6px;
    padding: 4px 12px;
    font-size: 12px;
    background: var(--klync-danger-bg);
    border: 1px solid var(--klync-danger);
    border-radius: 4px;
    cursor: pointer;
    color: var(--klync-danger-text);
    display: block;
}

.chat-try-again-btn:hover {
    background: var(--klync-danger-border);
    color: var(--klync-danger-text);
}

/* Custom scrollbar for messages */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--klync-dark-border-subtle);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--klync-dark-text-faint);
}

/* ===== Write-action confirmation cards ===== */
.confirmation-card {
    background: var(--klync-dark-border);
    border-left: 3px solid #f59e0b;
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    font-size: 14px;
    color: var(--klync-dark-text);
    max-width: 85%;
}

.confirmation-card.confirmed {
    border-left-color: #10b981;
}

.confirmation-card.rejected {
    border-left-color: #ef4444;
}

.confirmation-card .action-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1;
}

.confirmation-card .action-content {
    flex: 1;
    min-width: 0;
}

.confirmation-fields {
    margin: 0.5rem 0;
}

.confirmation-field {
    display: flex;
    gap: 0.5rem;
    font-size: 13px;
    line-height: 1.6;
}

.field-label {
    font-weight: 500;
    color: var(--klync-dark-text-muted);
    white-space: nowrap;
}

.field-value {
    color: var(--klync-dark-text);
}

.confirmation-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.confirmation-result {
    font-size: 0.85rem;
    color: var(--klync-dark-text-muted);
    font-style: italic;
}
