/* ============================================================================
   CHATBOT WIDGET STYLES
   Matches the existing Pinoyshki dashboard theme
   ============================================================================ */

/* CSS Variables - Warm Gold Restaurant Theme */
:root {
    --chat-primary: #D4A574;
    --chat-user-bubble: #B8864E;
    --chat-secondary: #2ECC71;
    --chat-success: #2ECC71;
    --chat-warning: #F39C12;
    --chat-danger: #E74C3C;
    --chat-light: #F8F9FA;
    --chat-dark: #343A40;
    --chat-white: #FFFFFF;
    --chat-gray: #94a0ad;
    --chat-border: #DEE2E6;
    --chat-shadow: rgba(0, 0, 0, 0.15);
    --chat-radius: 12px;
    --chat-widget-width: 800px;
    --chat-widget-height: 550px;
}

/* ============================================================================
   FLOATING BUTTON
   ============================================================================ */

.chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 9999;
    overflow: visible;
    padding: 0;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
    fill: var(--chat-white);
}

/* Chibi toggle button - larger SVG for the cute avatar */
.chatbot-toggle svg.chibi-toggle {
    width: 48px;
    height: 48px;
}

/* Blinking animation for toggle button eyes */
.chatbot-toggle .toggle-bot-eye {
    animation: blink 4s ease-in-out infinite;
    transform-origin: center;
}

.chatbot-toggle.active {
    display: none;
}

.chatbot-toggle:not(.active) svg.close-icon {
    display: none;
}

/* Notification badge */
.chatbot-toggle .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--chat-danger);
    color: var(--chat-white);
    font-size: 12px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
}

/* ============================================================================
   CHAT WIDGET CONTAINER
   ============================================================================ */

.chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: var(--chat-widget-width);
    height: var(--chat-widget-height);
    background: var(--chat-white);
    border-radius: var(--chat-radius);
    box-shadow: 0 10px 40px var(--chat-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    animation: slideUp 0.3s ease;
}

.chatbot-widget *,
.chatbot-widget *::before,
.chatbot-widget *::after {
    box-sizing: border-box;
}

.chatbot-widget.visible {
    display: flex;
}

.chatbot-widget.fullscreen {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    max-width: none;
}

/* Dragged state: switch from bottom/right to top/left positioning */
.chatbot-widget.dragged {
    bottom: auto;
    right: auto;
}

/* Fullscreen overrides dragged positioning */
.chatbot-widget.fullscreen.dragged {
    top: 0;
    left: 0;
}

/* ============================================================================
   RESIZE HANDLES
   ============================================================================ */

.chatbot-resize-handle {
    position: absolute;
    z-index: 10;
}

.chatbot-resize-handle.resize-n {
    top: -3px;
    left: 10px;
    right: 10px;
    height: 6px;
    cursor: n-resize;
}

.chatbot-resize-handle.resize-s {
    bottom: -3px;
    left: 10px;
    right: 10px;
    height: 6px;
    cursor: s-resize;
}

.chatbot-resize-handle.resize-w {
    left: -3px;
    top: 10px;
    bottom: 10px;
    width: 6px;
    cursor: w-resize;
}

.chatbot-resize-handle.resize-e {
    right: -3px;
    top: 10px;
    bottom: 10px;
    width: 6px;
    cursor: e-resize;
}

.chatbot-resize-handle.resize-nw {
    top: -3px;
    left: -3px;
    width: 12px;
    height: 12px;
    cursor: nw-resize;
}

.chatbot-resize-handle.resize-ne {
    top: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    cursor: ne-resize;
}

.chatbot-resize-handle.resize-sw {
    bottom: -3px;
    left: -3px;
    width: 12px;
    height: 12px;
    cursor: sw-resize;
}

.chatbot-resize-handle.resize-se {
    bottom: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    cursor: se-resize;
}

/* Hide resize handles in fullscreen and on mobile */
.chatbot-widget.fullscreen .chatbot-resize-handle {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   CHAT HEADER
   ============================================================================ */

.chatbot-header {
    background: var(--chat-primary);
    color: var(--chat-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    cursor: move;
}

/* Don't show move cursor on header buttons */
.chatbot-header-btn {
    cursor: pointer;
}

/* Disable drag cursor on mobile (fullscreen anyway) */
@media (max-width: 768px) {
    .chatbot-header {
        cursor: default;
    }
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header-avatar {
    width: 36px;
    height: 36px;
    background: transparent;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-header-avatar svg {
    width: 20px;
    height: 20px;
    fill: var(--chat-white);
}

.chatbot-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-header-info p {
    margin: 0;
    font-size: 12px;
    opacity: 0.8;
}

.chatbot-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-token-usage {
    font-size: 10px;
    opacity: 0.9;
    white-space: nowrap;
}

.chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.chatbot-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chatbot-header-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--chat-white);
}

/* ============================================================================
   SESSION TABS (Chrome-style)
   ============================================================================ */

.chatbot-session-bar {
    background: #202124;
    padding: 8px 8px 0;
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
    border-bottom: 1px solid #3c4043;
}

/* Hide session bar when only one tab */
.chatbot-session-bar.single-tab {
    display: none;
}

.chatbot-session-tabs {
    display: flex;
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    min-width: 0;
    align-items: flex-end;
}

.chatbot-session-tabs::-webkit-scrollbar {
    height: 0;
}

.chatbot-session-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px 8px 0 0;
    background: transparent;
    border: none;
    color: #bfc8d1;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
    font-size: 12px;
    min-width: 120px;
    max-width: 200px;
    position: relative;
    margin-right: -1px;
}

.chatbot-session-tab:hover {
    background: #2d2e31;
    color: #f0f2f5;
    z-index: 2;
}

.chatbot-session-tab.active {
    background: var(--chat-white, #1e2533);
    color: #fff;
    z-index: 3;
    border-bottom: none;
}

.chatbot-session-tab.active::before,
.chatbot-session-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 8px;
    height: 8px;
    background: transparent;
}

.chatbot-session-tab.active::before {
    left: -8px;
    border-radius: 0 0 8px 0;
    box-shadow: 4px 0 0 0 var(--chat-white, #1e2533);
}

.chatbot-session-tab.active::after {
    right: -8px;
    border-radius: 0 0 0 8px;
    box-shadow: -4px 0 0 0 var(--chat-white, #1e2533);
}

.chatbot-session-tab:focus-within {
    box-shadow: none;
}

.chatbot-session-tab .session-select {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
    padding: 0;
    margin: 0;
    max-width: 150px;
    flex: 1;
    min-width: 0;
}

.chatbot-session-tab .session-icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    flex-shrink: 0;
}

.chatbot-session-tab .session-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-session-tab .session-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    border-radius: 50%;
    flex-shrink: 0;
}

.chatbot-session-tab:hover .session-close,
.chatbot-session-tab.active .session-close {
    opacity: 0.6;
}

.chatbot-session-tab .session-close svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.chatbot-session-tab .session-close:hover:not(:disabled) {
    opacity: 1;
    background: rgba(0, 0, 0, 0.15);
}

.chatbot-session-tab.active .session-close:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.1);
}

.chatbot-session-tab .session-close:disabled {
    opacity: 0;
    cursor: not-allowed;
}

/* New tab (+) button in tab bar */
.chatbot-session-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #bfc8d1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    margin-left: 4px;
    margin-bottom: 2px;
}

.chatbot-session-add:hover {
    background: #3a3a3a;
    color: #f0f2f5;
}

.chatbot-session-add svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

@media (max-width: 768px) {
    .chatbot-session-bar {
        padding: 4px 6px 0;
    }

    .chatbot-session-tabs {
        gap: 1px;
    }

    .chatbot-session-tab {
        flex: 0 0 auto;
        min-width: 80px;
    }
}

/* ============================================================================
   CHAT MESSAGES AREA
   ============================================================================ */

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--chat-light);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

/* Message bubbles */
.chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
    --chat-heading-color: var(--chat-dark);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    --chat-heading-color: #2d1a0a;
}

.chat-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: visible;
}

.chat-message.user .chat-message-avatar {
    background: transparent;
}

.chat-message-avatar svg {
    width: 28px;
    height: 28px;
    fill: var(--chat-white);
}

/* Chibi Avatar Styles */
.chat-message-avatar .chibi-avatar {
    width: 32px;
    height: 32px;
}

/* Blinking animation for bot eyes */
.chat-message-avatar .bot-eye {
    animation: blink 4s ease-in-out infinite;
    transform-origin: center;
}

/* Blinking animation for user eyes */
.chat-message-avatar .user-eye {
    animation: blink 5s ease-in-out infinite;
    animation-delay: 1s;
    transform-origin: center;
}

@keyframes blink {
    0%, 45%, 55%, 100% {
        transform: scaleY(1);
    }
    50% {
        transform: scaleY(0.1);
    }
}

/* Subtle floating animation for bot avatar */
.chat-message.assistant .chat-message-avatar .chibi-avatar {
    animation: float 3s ease-in-out infinite, blink-container 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-2px);
    }
}

/* Header chibi bot animation */
.chatbot-header-avatar .header-chibi-bot {
    width: 100%;
    height: 100%;
}

.chatbot-header-avatar .header-bot-eye {
    animation: blink 4s ease-in-out infinite;
    transform-origin: center;
}

/* Welcome chibi bot animation */
.chat-welcome-icon .welcome-chibi-bot {
    width: 100%;
    height: 100%;
}

.chat-welcome-icon .welcome-bot-eye {
    animation: blink 3s ease-in-out infinite;
    transform-origin: center;
}

/* Bounce animation for welcome icon */
.chat-welcome-icon {
    animation: welcomeBounce 2s ease-in-out infinite;
}

@keyframes welcomeBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.chat-message-content {
    background: var(--chat-white);
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message-actions {
    position: absolute;
    bottom: -20px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s, bottom 0.2s;
    pointer-events: none;
    z-index: 5;
}

.chat-message:hover .message-actions {
    opacity: 1;
    bottom: -18px;
    pointer-events: auto;
}

.chat-message.user .message-actions {
    right: auto;
    left: 8px;
}

.message-action-btn {
    background: var(--chat-white);
    border: 1px solid var(--chat-border);
    border-radius: 4px;
    padding: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-gray);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.message-action-btn:hover {
    color: var(--chat-primary);
    border-color: var(--chat-primary);
    background: var(--chat-light);
    transform: translateY(-1px);
}

.chat-message.user .message-action-btn {
    background: var(--chat-primary);
    color: white;
    border-color: rgba(255,255,255,0.2);
}

.chat-message.user .message-action-btn:hover {
    background: white;
    color: var(--chat-primary);
}

/* Inline edit mode */
.inline-edit-area {
    width: 100%;
}

.inline-edit-input {
    width: 100%;
    min-height: 40px;
    max-height: 200px;
    padding: 8px 10px;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    color: var(--chat-white);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    box-sizing: border-box;
}

.inline-edit-input:focus {
    border-color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.2);
}

.inline-edit-buttons {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    justify-content: flex-end;
}

.inline-edit-save,
.inline-edit-cancel {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.inline-edit-save {
    background: var(--chat-white);
    color: var(--chat-primary);
}

.inline-edit-save:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.inline-edit-cancel {
    background: transparent;
    color: var(--chat-white);
}

.inline-edit-cancel:hover {
    background: rgba(255,255,255,0.15);
}

.chat-message.user .chat-message-content {
    background: var(--chat-user-bubble);
    color: var(--chat-white);
}

.chat-message-content p {
    margin: 0;
    line-height: 1.5;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Markdown rendered content */
.chat-message-content .markdown-content {
    line-height: 1.6;
    font-size: 14px;
    word-break: break-word;
}

.chat-message-content .markdown-content h3 {
    margin: 16px 0 8px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--chat-heading-color, var(--chat-dark));
}

.chat-message-content .markdown-content h4 {
    margin: 14px 0 6px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--chat-heading-color, var(--chat-dark));
}

.chat-message-content .markdown-content h5 {
    margin: 12px 0 4px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--chat-heading-color, var(--chat-dark));
}

.dark-theme .chat-message-content .markdown-content h3,
.dark-theme .chat-message-content .markdown-content h4,
.dark-theme .chat-message-content .markdown-content h5 {
    color: #ffffff;
}

.dark-theme .chat-message.assistant {
    --chat-heading-color: var(--dark-accent);
}

.chat-message-content .markdown-content strong {
    font-weight: 600;
}

.chat-message-content .markdown-content em {
    font-style: italic;
}

.chat-message-content .markdown-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.chat-message-content .markdown-content pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.chat-message-content .markdown-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 13px;
}

.chat-message-content .markdown-content ul,
.chat-message-content .markdown-content ol {
    margin: 6px 0;
    padding-left: 20px;
}

.chat-message-content .markdown-content li {
    margin: 2px 0;
    line-height: 1.5;
}

.chat-message-content .markdown-content .md-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.chat-message-content .markdown-content .md-table th {
    background: #f8f9fa;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--chat-border);
}

.chat-message-content .markdown-content .md-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #eee;
}

.chat-message-content .markdown-content .md-table tr:hover {
    background: #f8f9fa;
}

/* Welcome message */
.chat-welcome {
    text-align: center;
    padding: 20px;
}

.chat-welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: transparent;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-welcome-icon svg {
    width: 32px;
    height: 32px;
    fill: var(--chat-white);
}

.chat-welcome h4 {
    margin: 0 0 8px;
    color: var(--chat-dark);
    font-size: 18px;
}

.chat-welcome p {
    margin: 0;
    color: var(--chat-gray);
    font-size: 14px;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chat-white);
    border-radius: 16px;
    width: fit-content;
    max-width: 320px;
}

/* Direct dot spans (fallback simple indicator) */
.chat-typing > span {
    width: 8px;
    height: 8px;
    background: var(--chat-gray);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.chat-typing > span:nth-child(1) { animation-delay: -0.32s; }
.chat-typing > span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Tool indicator (collapsed) */
.chat-tool-indicator {
    position: relative;
    display: inline-block;
    margin: 8px 0;
    cursor: default;
}

.chat-tool-indicator .tool-dots {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(46, 134, 171, 0.1);
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    color: var(--chat-primary);
    letter-spacing: 2px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.chat-tool-indicator .tool-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--chat-dark);
    color: var(--chat-white);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 100;
    margin-bottom: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s, visibility 0.2s;
}

.chat-tool-indicator .tool-tooltip.visible,
.chat-tool-indicator:hover .tool-tooltip {
    visibility: visible;
    opacity: 1;
}

.chat-tool-indicator .tool-tooltip code {
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    color: #7dd3fc;
}

/* Legacy tool calls indicator (kept for compatibility) */
.chat-tool-call {
    background: rgba(46, 134, 171, 0.1);
    border-left: 3px solid var(--chat-primary);
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--chat-gray);
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-tool-call .tool-icon {
    width: 16px;
    height: 16px;
    fill: var(--chat-primary);
    flex-shrink: 0;
    animation: spin 2s linear infinite;
}

.chat-tool-call code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    color: var(--chat-primary);
}

/* Graph container */
.chat-graph {
    background: var(--chat-white);
    border-radius: 8px;
    margin: 8px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: visible;
    animation: chartSlideIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
    min-height: 200px;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

@keyframes chartSlideIn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    60% {
        opacity: 1;
        transform: translateY(-4px) scale(1.005);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes chartHeaderGlow {
    0% {
        box-shadow: 0 0 12px rgba(212, 165, 116, 0.5);
    }
    100% {
        box-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-graph {
        animation: none;
        opacity: 1;
    }
    .chat-graph-header {
        animation: none;
    }
}

.chat-graph-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--chat-white);
    color: var(--chat-dark, #333);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid var(--chat-border, #e0e0e0);
    animation: chartHeaderGlow 1.2s ease-out;
}

.chat-graph-header .graph-icon {
    width: 16px;
    height: 16px;
    fill: var(--chat-primary, #D4A574);
}

.chat-graph-content {
    padding: 12px;
    min-height: 300px;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

.chat-graph-content > div {
    min-height: 300px;
}

.chat-graph .js-plotly-plot {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 300px;
}

.chat-graph .plotly-graph-div {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 300px;
}

.chat-graph .svg-container {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 300px;
}

.chat-graph .main-svg {
    max-width: 100% !important;
}

/* Mermaid diagrams */
.mermaid-container {
    background: var(--chat-white, #1e2533);
    border-radius: 8px;
    margin: 10px 0;
    padding: 16px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.mermaid-rendered {
    display: flex;
    justify-content: center;
}

.mermaid-rendered svg {
    max-width: 100%;
    height: auto;
}

.mermaid-pending {
    font-family: monospace;
    white-space: pre;
    color: var(--chat-text-secondary, #bfc8d1);
    font-size: 0.85rem;
}

.mermaid-error {
    background: rgba(220, 53, 69, 0.1);
    border-left: 3px solid #dc3545;
    padding: 10px;
    border-radius: 4px;
    color: #dc3545;
    font-size: 0.85rem;
}

/* Graph container for mermaid via create_chart */
.chat-graph .mermaid-rendered {
    min-height: auto;
}

/* Error message */
.chat-error {
    background: rgba(220, 53, 69, 0.1);
    border-left: 3px solid var(--chat-danger);
    padding: 12px 14px;
    border-radius: 4px;
    color: var(--chat-danger);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-error .error-icon {
    width: 20px;
    height: 20px;
    fill: var(--chat-danger);
    flex-shrink: 0;
}

.chat-cooldown {
    background: rgba(255, 193, 7, 0.15);
    border-left: 3px solid var(--chat-warning);
    padding: 12px 16px;
    border-radius: 4px;
    color: #856404;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
}

.chat-cooldown .cooldown-icon {
    width: 20px;
    height: 20px;
    fill: var(--chat-warning);
    flex-shrink: 0;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.chat-cooldown .cooldown-text {
    flex: 1;
}

.chat-cooldown .cooldown-time {
    font-weight: 600;
    color: #856404;
}

/* Tool error notice (amber, subtle) */
.chat-tool-error {
    background: rgba(243, 156, 18, 0.1);
    border-left: 3px solid var(--chat-warning);
    padding: 8px 12px;
    border-radius: 4px;
    color: #856404;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
}

.chat-tool-error .tool-error-icon {
    width: 16px;
    height: 16px;
    fill: var(--chat-warning);
    flex-shrink: 0;
}

.chat-tool-error .tool-error-name {
    font-weight: 600;
}

/* Report Issue banner (appears after 2+ tool errors) */
.chat-tool-error-report {
    background: rgba(243, 156, 18, 0.08);
    border: 1px solid rgba(243, 156, 18, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.3s, transform 0.3s;
}

.chat-tool-error-report.dismissed {
    opacity: 0;
    transform: translateY(-10px);
}

.chat-tool-error-report .report-icon {
    width: 18px;
    height: 18px;
    fill: var(--chat-warning);
    flex-shrink: 0;
}

.chat-tool-error-report .report-text {
    flex: 1;
    font-size: 12px;
    color: #856404;
}

.chat-tool-error-report .report-btn {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--chat-warning);
    background: rgba(243, 156, 18, 0.15);
    color: #856404;
    white-space: nowrap;
    transition: all 0.2s;
}

.chat-tool-error-report .report-btn:hover {
    background: rgba(243, 156, 18, 0.3);
}

/* ============================================================================
   CHAT TABLES
   ============================================================================ */

.chat-table-container {
    margin: 12px 0;
    background: var(--chat-white);
    border-radius: 8px;
    border: 1px solid var(--chat-border);
    overflow: hidden;
}

.chat-table-title {
    padding: 12px 16px;
    background: var(--chat-primary);
    color: var(--chat-white);
    font-weight: 600;
    font-size: 14px;
}

.chat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.chat-table thead {
    background: #f8f9fa;
}

.chat-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--chat-dark);
    border-bottom: 2px solid var(--chat-border);
    white-space: nowrap;
}

.chat-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--chat-border, #dee2e6);
    color: var(--chat-dark, #343A40);
}

.chat-table tbody tr:hover {
    background: #f8f9fa;
}

.chat-table tbody tr:last-child td {
    border-bottom: none;
}

/* Responsive table scroll */
.chat-table-container {
    overflow-x: auto;
    max-width: 100%;
}

/* Alternating row colors */
.chat-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.chat-table tbody tr:nth-child(even):hover {
    background: #f0f0f0;
}

/* ============================================================================
   CHAT INPUT AREA
   ============================================================================ */

.chatbot-input-area {
    padding: 16px 20px;
    background: var(--chat-white);
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chatbot-input-wrapper {
    flex: 1;
    position: relative;
}

.chatbot-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--chat-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 62px;
    overflow: hidden;
    line-height: 1.4;
    font-family: inherit;
    background: var(--chat-white);
    color: var(--chat-dark);
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: var(--chat-primary);
}

.chatbot-input::placeholder {
    color: var(--chat-gray);
}

.chatbot-input::selection {
    background: rgba(212, 165, 116, 0.3);
    color: inherit;
}

.chatbot-input::-moz-selection {
    background: rgba(212, 165, 116, 0.3);
    color: inherit;
}

/* Remove spinner arrows from input */
.chatbot-input::-webkit-outer-spin-button,
.chatbot-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.chatbot-input[type=number] {
    -moz-appearance: textfield;
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
    background: var(--chat-secondary);
    transform: scale(1.05);
}

.chatbot-send-btn:disabled {
    background: var(--chat-gray);
    cursor: not-allowed;
}

.chatbot-send-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--chat-white);
}

/* ============================================================================
   HISTORY SIDEBAR
   ============================================================================ */

.chatbot-history {
    position: absolute;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--chat-white);
    border-right: 1px solid var(--chat-border);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.chatbot-history.visible {
    transform: translateX(0);
}

.chatbot-history-header {
    padding: 16px;
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-history-header .history-header-icon {
    width: 20px;
    height: 20px;
    fill: var(--chat-primary);
    flex-shrink: 0;
}

.chatbot-history-header h4 {
    margin: 0;
    font-size: 16px;
    color: var(--chat-dark);
    flex: 1;
}

.chatbot-history-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.chatbot-history-close:hover {
    background: var(--chat-light);
}

.chatbot-history-close svg {
    width: 20px;
    height: 20px;
    fill: var(--chat-gray);
}

/* History Search */
.chatbot-history-search {
    padding: 12px;
    border-bottom: 1px solid var(--chat-border);
}

.chatbot-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.chatbot-search-input {
    width: 100%;
    padding: 10px 36px 10px 12px;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-search-input:focus {
    border-color: var(--chat-primary);
}

.chatbot-search-input::placeholder {
    color: var(--chat-gray);
}

.chatbot-search-icon {
    position: absolute;
    right: 10px;
    width: 18px;
    height: 18px;
    fill: var(--chat-gray);
    pointer-events: none;
}

.chatbot-search-clear {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    display: none;
}

.chatbot-search-clear.visible {
    display: block;
}

.chatbot-search-clear svg {
    width: 16px;
    height: 16px;
    fill: var(--chat-gray);
}

.chatbot-search-clear:hover svg {
    fill: var(--chat-dark);
}

/* Search Results */
.chatbot-search-results {
    padding: 8px 12px;
    background: var(--chat-light);
    border-bottom: 1px solid var(--chat-border);
    font-size: 12px;
    color: var(--chat-gray);
}

.chatbot-search-result {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
    background: var(--chat-white);
    border: 1px solid var(--chat-border);
}

.chatbot-search-result:hover {
    background: rgba(46, 134, 171, 0.05);
    border-color: var(--chat-primary);
}

.chatbot-search-result-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--chat-dark);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-search-result-excerpt {
    font-size: 12px;
    color: var(--chat-gray);
    line-height: 1.4;
}

.chatbot-search-result-excerpt mark {
    background: rgba(255, 193, 7, 0.4);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.chatbot-search-result-meta {
    font-size: 11px;
    color: var(--chat-gray);
    margin-top: 4px;
    display: flex;
    gap: 8px;
}

.chatbot-search-result-meta .role {
    text-transform: capitalize;
    color: var(--chat-primary);
}

.chatbot-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Empty history state */
.history-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--chat-gray);
}

.history-empty-icon {
    width: 48px;
    height: 48px;
    fill: var(--chat-border);
    margin-bottom: 12px;
}

.history-empty p {
    margin: 0;
    font-size: 14px;
}

.chatbot-history-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.chatbot-history-item:hover {
    background: var(--chat-light);
}

.chatbot-history-item.active {
    background: rgba(46, 134, 171, 0.1);
}

.chatbot-history-item .history-item-icon {
    width: 20px;
    height: 20px;
    fill: var(--chat-gray);
    flex-shrink: 0;
    margin-top: 2px;
}

.chatbot-history-item.active .history-item-icon {
    fill: var(--chat-primary);
}

.chatbot-history-item .history-item-content {
    flex: 1;
    min-width: 0;
}

.chatbot-history-item h5 {
    margin: 0 0 4px;
    font-size: 14px;
    color: var(--chat-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-history-item p {
    margin: 0;
    font-size: 11px;
    color: var(--chat-gray);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.chatbot-history-item .history-meta-icon {
    width: 12px;
    height: 12px;
    fill: var(--chat-gray);
}

.chatbot-history-actions {
    padding: 12px;
    border-top: 1px solid var(--chat-border);
}

.chatbot-new-chat-btn {
    width: 100%;
    padding: 12px;
    background: var(--chat-primary);
    color: var(--chat-white);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.chatbot-new-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 134, 171, 0.3);
}

.chatbot-new-chat-btn .new-chat-icon {
    width: 18px;
    height: 18px;
    fill: var(--chat-white);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

/* Tablets and small desktops: constrain widget to viewport */
@media (max-width: 860px) {
    .chatbot-widget {
        width: calc(100vw - 48px);
        max-width: var(--chat-widget-width);
    }
}

/* Mobile: full-screen chat */
@media (max-width: 768px) {
    .chatbot-widget {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: none;
        border-radius: 0;
        animation: none;
    }

    .chatbot-toggle {
        bottom: 16px;
        right: 16px;
    }

    /* Hide resize handles — fullscreen on mobile */
    .chatbot-resize-handle {
        display: none;
    }

    /* Disable dragged positioning on mobile */
    .chatbot-widget.dragged {
        top: auto !important;
        left: auto !important;
        bottom: 0;
        right: 0;
    }

    /* Hide fullscreen button — already fullscreen on mobile */
    #fullscreen-btn {
        display: none;
    }

    .chatbot-header {
        padding: 12px 16px;
    }

    .chatbot-messages {
        padding: 12px;
    }

    .chatbot-input-area {
        padding: 12px 16px;
        /* Keep input above the on-screen keyboard / bottom safe area */
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .chat-message {
        max-width: 92%;
    }

    .chatbot-history {
        width: 100%;
    }

    /* Stack recipe form rows vertically on mobile */
    .recipe-form-row {
        flex-direction: column;
        gap: 8px;
    }

    /* Let ingredient fields wrap on small screens */
    .ingredient-row {
        flex-wrap: wrap;
    }

    .ingredient-row .ingredient-name {
        flex: 1 1 100%;
    }

    .ingredient-row .ingredient-qty,
    .ingredient-row .ingredient-unit {
        flex: 1 1 40%;
        max-width: none;
    }

    /* Wider message bubbles for proposal cards */
    .chat-message .chat-recipe-proposal,
    .chat-message .chat-navigation-card {
        max-width: 100%;
    }

    /* Suggestion chips scroll horizontally on mobile */
    .chat-suggestions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .suggestion-chip {
        flex-shrink: 0;
    }
}

/* ============================================================================
   DARK MODE OVERRIDES
   Ensures the chatbot matches the main Pinoyshki dark theme
   ============================================================================ */

.dark-theme .chatbot-widget {
    --chat-light: #0f1419;
    --chat-white: #1e2533;
    --chat-dark: #e7e9ea;
    --chat-border: #2f3944;
    --chat-gray: #d0d8e0;
    --chat-shadow: rgba(0, 0, 0, 0.5);
    --chat-user-bubble: #7a5a30;
    background: var(--chat-white);
    border: 1px solid var(--chat-border);
}

.dark-theme .chatbot-messages {
    background: var(--chat-light);
}

.dark-theme .chat-message-content {
    background: var(--chat-white);
    color: var(--chat-dark);
    box-shadow: 0 2px 8px var(--chat-shadow);
}

.dark-theme .chat-message.user .chat-message-content {
    background: var(--chat-user-bubble);
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.dark-theme .chat-message.user .chat-message-content p,
.dark-theme .chat-message.user .chat-message-content span,
.dark-theme .chat-message.user .chat-message-content a {
    color: #fff !important;
}

.dark-theme .chat-message.user .chat-message-content::selection {
    background: rgba(45, 26, 10, 0.3);
    color: #2d1a0a;
}

.dark-theme .chat-message.user .chat-message-content::-moz-selection {
    background: rgba(45, 26, 10, 0.3);
    color: #2d1a0a;
}

.dark-theme .chatbot-input-area {
    background: var(--chat-white);
    border-top-color: var(--chat-border);
}

.dark-theme .chatbot-input {
    background: #1a2230;
    border-color: #3d4a5c;
    color: #f0f2f5;
}

.dark-theme .chatbot-input::placeholder {
    color: #8899aa;
}

.dark-theme .chatbot-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.15);
}

.dark-theme .chatbot-history {
    background: var(--chat-white);
    border-right-color: var(--chat-border);
}

.dark-theme .chatbot-history-header,
.dark-theme .chatbot-history-search {
    border-bottom-color: var(--chat-border);
}

.dark-theme .chatbot-search-input {
    background: var(--chat-light);
    border-color: var(--chat-border);
    color: var(--chat-dark);
}

.dark-theme .chatbot-history-item:hover {
    background: var(--chat-bg-tertiary, #252d3d);
}

.dark-theme .chatbot-history-item.active {
    background: rgba(212, 165, 116, 0.15);
}

.dark-theme .chatbot-history-item h5 {
    color: var(--chat-dark);
}

.dark-theme .chat-welcome h4 {
    color: var(--chat-dark);
}

.dark-theme .chat-typing {
    background: var(--chat-white);
}

.dark-theme .chat-typing > span {
    background: var(--chat-gray);
}

.dark-theme .chat-message-avatar svg {
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.5));
}

/* Dark theme: chat tables */
.dark-theme .chat-table thead,
.dark-theme .chat-message-content .markdown-content .md-table th {
    background: var(--chat-light, #0f1419);
    color: var(--chat-dark, #e7e9ea);
}

.dark-theme .chat-table td,
.dark-theme .chat-message-content .markdown-content .md-table td {
    border-bottom-color: var(--chat-border, #2f3944);
    color: var(--chat-dark, #e7e9ea);
}

.dark-theme .chat-table tbody tr:hover,
.dark-theme .chat-message-content .markdown-content .md-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.dark-theme .chat-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

.dark-theme .chat-table tbody tr:nth-child(even):hover {
    background: rgba(255, 255, 255, 0.06);
}

.dark-theme .chat-table-container {
    background: var(--chat-white, #1e2533);
    border-color: var(--chat-border, #2f3944);
}

.dark-theme .chat-table th {
    color: var(--chat-dark, #e7e9ea);
    border-bottom-color: var(--chat-border, #2f3944);
}

@media (prefers-color-scheme: dark) {
    .chatbot-widget.dark-mode {
        --chat-light: #0f1419;
        --chat-white: #1e2533;
        --chat-dark: #e7e9ea;
        --chat-border: #2f3944;
        --chat-gray: #bfc8d1;
        --chat-user-bubble: #7a5a30;
    }
}

/* ============================================================================
   RECIPE PROPOSAL CARDS
   Interactive cards for add/modify/delete recipe approvals
   ============================================================================ */

/* Proposal Stack Container */
.proposal-stack-container {
    position: relative;
    min-height: 100px;
    margin: 12px 0;
    perspective: 1000px;
}

.proposal-stack-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--chat-light);
    border-radius: 8px 8px 0 0;
    border: 1px solid var(--chat-border);
    border-bottom: none;
}

.proposal-stack-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--chat-gray);
}

.proposal-stack-indicator .nav-btn {
    background: none;
    border: 1px solid var(--chat-border);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--chat-gray);
    transition: all 0.2s;
}

.proposal-stack-indicator .nav-btn:hover:not(:disabled) {
    background: var(--chat-white);
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

.proposal-stack-indicator .nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.proposal-stack-actions .btn-reject-all {
    background: none;
    border: 1px solid var(--chat-danger);
    color: var(--chat-danger);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.proposal-stack-actions .btn-reject-all:hover {
    background: var(--chat-danger);
    color: white;
}

/* Recipe Proposal Card */
.chat-recipe-proposal {
    position: relative;
    z-index: 1;
    background: var(--chat-white);
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, opacity 0.3s ease;
    border: 1px solid var(--chat-border);
    overflow: visible;
}

.chat-recipe-proposal.standalone {
    border-radius: 10px;
    margin: 12px 0;
}

.chat-recipe-proposal.stacked {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(8px) scale(0.98);
    opacity: 0.7;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.chat-recipe-proposal.stacked:nth-child(3) {
    transform: translateY(16px) scale(0.96);
    opacity: 0.5;
    z-index: -2;
}

/* Card fly-away animations */
.chat-recipe-proposal.accepted {
    overflow: hidden;
    animation: flyAwayRight 0.4s ease-out forwards;
}

.chat-recipe-proposal.rejected {
    overflow: hidden;
    animation: flyAwayLeft 0.4s ease-out forwards;
}

@keyframes flyAwayRight {
    0% { transform: translateX(0) rotate(0); opacity: 1; }
    100% { transform: translateX(100%) rotate(10deg); opacity: 0; }
}

@keyframes flyAwayLeft {
    0% { transform: translateX(0) rotate(0); opacity: 1; }
    100% { transform: translateX(-100%) rotate(-10deg); opacity: 0; }
}

/* Proposal Header with Type Badge */
.proposal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--chat-primary);
    color: white;
}

.chat-recipe-proposal.standalone .proposal-header {
    border-radius: 10px 10px 0 0;
}

.proposal-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.proposal-type-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.proposal-type-badge.add {
    background: rgba(46, 204, 113, 0.9);
    color: white;
}

.proposal-type-badge.modify {
    background: rgba(243, 156, 18, 0.9);
    color: white;
}

.proposal-type-badge.delete {
    background: rgba(231, 76, 60, 0.9);
    color: white;
}

.proposal-title {
    font-weight: 600;
    font-size: 15px;
}

/* Proposal Message */
.proposal-message {
    padding: 10px 16px;
    background: rgba(46, 134, 171, 0.05);
    border-bottom: 1px solid var(--chat-border);
    font-size: 13px;
    color: var(--chat-gray);
    font-style: italic;
}

/* Recipe Form */
.recipe-card-form {
    padding: 16px;
    max-height: 280px;
    overflow-y: auto;
}

.recipe-card-form::-webkit-scrollbar {
    width: 6px;
}

.recipe-card-form::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

.recipe-form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.recipe-form-group {
    flex: 1;
    min-width: 0;
}

.recipe-form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--chat-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.recipe-form-group input,
.recipe-form-group select,
.recipe-form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--chat-border);
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.2s;
}

.recipe-form-group input:focus,
.recipe-form-group select:focus,
.recipe-form-group textarea:focus {
    outline: none;
    border-color: var(--chat-primary);
}

.recipe-form-group textarea {
    min-height: 60px;
    resize: vertical;
}

.recipe-form-group.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-direction: row;
}

.recipe-form-group.checkbox-group input[type="checkbox"] {
    width: auto;
}

.recipe-form-group.checkbox-group label {
    margin-bottom: 0;
    text-transform: none;
    font-weight: normal;
    font-size: 13px;
}

/* Diff Field Styling for Modify */
.diff-field {
    position: relative;
}

.diff-field .current-value {
    /* Normal input styling inherited */
}

.diff-field .old-value {
    font-size: 11px;
    color: var(--chat-gray, #94a0ad);
    text-decoration: line-through;
    margin-top: 4px;
    padding-left: 2px;
}

.diff-field.changed input,
.diff-field.changed select,
.diff-field.changed textarea {
    background: rgba(255, 243, 205, 0.3);
    border-color: #ffc107;
}

/* Ingredients Section */
.ingredients-section {
    margin-top: 16px;
    border-top: 1px solid var(--chat-border);
    padding-top: 12px;
}

.ingredients-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ingredients-header h5 {
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.btn-add-ingredient {
    background: none;
    border: 1px dashed var(--chat-primary);
    color: var(--chat-primary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-ingredient:hover {
    background: rgba(212, 165, 116, 0.1);
}

.ingredients-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ingredient-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px;
    background: var(--chat-light);
    border-radius: 6px;
}

.ingredient-row .ingredient-name {
    flex: 2;
    position: relative;
}

.ingredient-row .ingredient-qty {
    flex: 1;
    max-width: 80px;
}

.ingredient-row .ingredient-unit {
    flex: 1;
    max-width: 100px;
}

.ingredient-row input,
.ingredient-row select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--chat-border);
    border-radius: 4px;
    font-size: 12px;
}

.ingredient-row input:focus,
.ingredient-row select:focus {
    outline: none;
    border-color: var(--chat-primary);
}

.btn-remove-ingredient {
    background: none;
    border: none;
    color: var(--chat-danger);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-remove-ingredient:hover {
    background: rgba(231, 76, 60, 0.1);
}

.btn-remove-ingredient svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Ingredient diff highlighting */
.ingredient-row.diff-added {
    background: rgba(46, 204, 113, 0.12);
    border-left: 3px solid #2ecc71;
    padding-left: 6px;
}

.ingredient-row.diff-removed {
    background: rgba(231, 76, 60, 0.08);
    border-left: 3px solid #e74c3c;
    padding-left: 6px;
    opacity: 0.7;
    pointer-events: none;
}

.ingredient-row.diff-removed span {
    text-decoration: line-through;
    color: var(--chat-gray, #94a0ad);
    font-size: 12px;
}

/* Cost Display Slot (container for RecipeComponents cost display) */
.cost-display-slot {
    margin-top: 12px;
}

/* Live Cost Display */
.proposal-cost-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--chat-light);
    padding: 10px 16px;
    border-top: 1px solid var(--chat-border);
}

.cost-label {
    font-size: 12px;
    color: var(--chat-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cost-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--chat-primary);
}

.cost-value.calculating {
    color: var(--chat-gray);
    font-style: italic;
}

/* Delete Proposal Specific */
.delete-proposal-content {
    padding: 20px;
    text-align: center;
}

.delete-warning {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.delete-warning-icon {
    width: 48px;
    height: 48px;
    fill: var(--chat-danger);
}

.delete-warning h4 {
    margin: 0;
    color: var(--chat-dark);
    font-size: 16px;
}

.delete-warning p {
    margin: 0;
    color: var(--chat-gray);
    font-size: 13px;
}

.delete-reason {
    margin-top: 12px;
    padding: 10px;
    background: rgba(231, 76, 60, 0.05);
    border-radius: 6px;
    border-left: 3px solid var(--chat-danger);
}

.delete-reason label {
    font-size: 11px;
    color: var(--chat-gray);
    display: block;
    margin-bottom: 4px;
}

.delete-reason p {
    margin: 0;
    color: var(--chat-dark);
    font-size: 13px;
}

/* Action Buttons */
.proposal-actions {
    position: relative;
    z-index: 2;
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-light);
    border-radius: 0 0 10px 10px;
}

.proposal-actions button {
    flex: 1;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    position: relative;
    z-index: 5;
}

.proposal-actions .btn-accept {
    background: var(--chat-success);
    color: white;
}

.proposal-actions .btn-accept:hover {
    background: #27ae60;
    transform: translateY(-1px);
}

.proposal-actions .btn-reject {
    background: var(--chat-danger);
    color: white;
}

.proposal-actions .btn-reject:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.proposal-actions .btn-skip {
    background: var(--chat-gray);
    color: white;
    flex: 0.5;
}

.proposal-actions .btn-skip:hover {
    background: #5a6268;
}

/* Rejection Reason Modal */
.rejection-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.rejection-modal-content {
    background: var(--chat-white);
    border-radius: 10px;
    padding: 20px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.rejection-modal h4 {
    margin: 0 0 16px;
    font-size: 16px;
    color: var(--chat-dark);
}

.rejection-modal textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--chat-border);
    border-radius: 6px;
    font-size: 13px;
    min-height: 80px;
    resize: vertical;
    margin-bottom: 16px;
}

.rejection-modal textarea:focus {
    outline: none;
    border-color: var(--chat-primary);
}

.rejection-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.rejection-modal-actions button {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.rejection-modal-actions .btn-cancel {
    background: none;
    border: 1px solid var(--chat-border);
    color: var(--chat-gray);
}

.rejection-modal-actions .btn-confirm {
    background: var(--chat-danger);
    border: none;
    color: white;
}

.rejection-modal-actions .btn-cancel:hover {
    background: var(--chat-light);
}

.rejection-modal-actions .btn-confirm:hover {
    background: #c0392b;
}

/* ============================================================================
   NAVIGATION CARDS
   Confirmation cards for page navigation suggestions
   ============================================================================ */

.chat-navigation-card {
    background: var(--chat-white);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--chat-border);
    overflow: hidden;
    margin: 12px 0;
    animation: fadeIn 0.3s ease;
}

.nav-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--chat-primary) 0%, #C4956A 100%);
    color: var(--chat-white);
}

.nav-card-icon {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-card-icon svg {
    width: 20px;
    height: 20px;
    fill: var(--chat-white);
}

.nav-card-info {
    flex: 1;
    min-width: 0;
}

.nav-card-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.nav-card-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.85;
}

.nav-card-message {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--chat-gray);
    line-height: 1.5;
    border-bottom: 1px solid var(--chat-border);
    background: rgba(212, 165, 116, 0.04);
}

.nav-card-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--chat-light);
}

.nav-btn-accept {
    flex: 1;
    padding: 10px 16px;
    background: var(--chat-success);
    color: var(--chat-white);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.nav-btn-accept:hover {
    background: #27ae60;
    transform: translateY(-1px);
}

.nav-btn-decline {
    flex: 0.6;
    padding: 10px 16px;
    background: none;
    color: var(--chat-gray);
    border: 1px solid var(--chat-border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn-decline:hover {
    background: var(--chat-white);
    border-color: var(--chat-gray);
    color: var(--chat-dark);
}

.chat-navigation-card.declined {
    opacity: 0.6;
}

.chat-navigation-card.declined .nav-card-actions {
    padding: 8px 16px;
}

.chat-navigation-card.declined .nav-declined-note {
    font-size: 12px;
    color: var(--chat-gray);
    font-style: italic;
}

/* ============================================================================
   QUICK-ACTION CHIPS
   Contextual suggestion pills inline in conversation
   ============================================================================ */

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 0 4px;
}

.quick-action-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: var(--chat-light);
    color: var(--chat-dark);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    user-select: none;
}

.quick-action-chip:hover {
    background: rgba(212, 165, 116, 0.15);
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

.quick-action-chip:active {
    transform: scale(0.96);
}

.quick-action-debug {
    border-color: rgba(212, 165, 116, 0.35);
    background: rgba(212, 165, 116, 0.08);
    color: var(--chat-primary);
}

.quick-action-debug:hover {
    background: rgba(212, 165, 116, 0.2);
}

/* ============================================================================
   GRAPH EXPORT BUTTON
   Download button in chart header
   ============================================================================ */

.graph-export-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.graph-export-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.graph-export-btn svg {
    width: 16px;
    height: 16px;
    fill: var(--chat-white);
}

/* ============================================================================
   BOT SUGGESTION CHIPS
   Contextual follow-up suggestions from the bot
   ============================================================================ */

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0 4px;
}

.suggestion-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px 8px 14px;
    background: rgba(212, 165, 116, 0.10);
    border: 1px solid rgba(212, 165, 116, 0.30);
    border-radius: 10px;
    font-size: 13px;
    color: var(--chat-dark);
    cursor: default;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    /* animation start state - JS adds .chip-visible */
    opacity: 0;
    transform: translateY(12px) scale(0.92);
}

.suggestion-chip.chip-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.suggestion-chip:hover {
    background: rgba(212, 165, 116, 0.22);
    border-color: rgba(212, 165, 116, 0.55);
    box-shadow: 0 4px 16px rgba(212, 165, 116, 0.18);
    transform: translateY(-1px) scale(1);
}

.suggestion-chip:active {
    transform: translateY(0) scale(0.97);
}

.suggestion-chip .chip-text {
    line-height: 1.3;
}

.suggestion-chip .chip-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: rgba(212, 165, 116, 0.12);
    color: var(--chat-gray);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.suggestion-chip .chip-action:hover {
    background: var(--chat-primary);
    color: #fff;
}

.suggestion-chip .chip-action svg {
    fill: currentColor;
}

/* Dark theme overrides for suggestion chips */
.dark-theme .suggestion-chip {
    background: rgba(212, 165, 116, 0.08);
    border-color: rgba(212, 165, 116, 0.22);
    color: var(--dark-text-primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.dark-theme .suggestion-chip:hover {
    background: rgba(212, 165, 116, 0.18);
    border-color: rgba(212, 165, 116, 0.45);
    box-shadow: 0 4px 20px rgba(212, 165, 116, 0.15);
}

.dark-theme .suggestion-chip .chip-action {
    background: rgba(212, 165, 116, 0.10);
    color: var(--dark-text-secondary);
}

.dark-theme .suggestion-chip .chip-action:hover {
    background: var(--dark-accent);
    color: #fff;
}

/* Data quality badge */
.data-quality-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    line-height: 1.4;
    background: rgba(212, 165, 116, 0.15);
    color: #b08050;
    cursor: help;
    margin-left: auto;
    margin-right: 6px;
    white-space: nowrap;
    transition: background 0.2s;
}

.data-quality-badge:hover {
    background: rgba(212, 165, 116, 0.3);
}

.dark-theme .data-quality-badge {
    background: rgba(212, 165, 116, 0.2);
    color: #d4a574;
}

.dark-theme .data-quality-badge:hover {
    background: rgba(212, 165, 116, 0.35);
}

/* Debug suggestion chip variant */
.suggestion-chip.suggestion-chip-debug {
    border-left: 3px solid var(--chat-primary);
    background: rgba(212, 165, 116, 0.14);
}

.suggestion-chip.suggestion-chip-debug:hover {
    background: rgba(212, 165, 116, 0.26);
}

.dark-theme .suggestion-chip.suggestion-chip-debug {
    border-left-color: var(--dark-accent, #D4A574);
    background: rgba(212, 165, 116, 0.12);
}

.dark-theme .suggestion-chip.suggestion-chip-debug:hover {
    background: rgba(212, 165, 116, 0.22);
}

@media (prefers-reduced-motion: reduce) {
    .suggestion-chip {
        opacity: 1;
        transform: none;
        transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    }
}

/* ============================================================================
   PAGE CHANGE NOTICE
   Inline notice shown when user navigates to a new page with chat open
   ============================================================================ */

.chat-page-notice {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(212, 165, 116, 0.10);
    border: 1px solid rgba(212, 165, 116, 0.25);
    border-radius: 20px;
    font-size: 12px;
    color: var(--chat-gray);
    align-self: center;
    animation: fadeIn 0.3s ease;
    white-space: nowrap;
}

.chat-page-notice svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.chat-page-notice strong {
    color: var(--chat-dark);
    font-weight: 600;
}

/* ============================================================================
   BOT THINKING ANIMATIONS (30 variations)
   Applied randomly to bot avatar while thinking/loading
   All animations are smooth, oscillatory, and return to origin each cycle
   ============================================================================ */

.thinking-avatar {
    will-change: transform, filter;
    transform-origin: center center;
}

/* 1. Gentle full spin */
@keyframes think-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 2. Bob up and down */
@keyframes think-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

/* 3. Shake head side to side */
@keyframes think-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-3px); }
    75%      { transform: translateX(3px); }
}

/* 4. Breathe / scale pulse */
@keyframes think-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.14); }
}

/* 5. Tilt left and right */
@keyframes think-tilt {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(-10deg); }
    75%      { transform: rotate(10deg); }
}

/* 6. Figure-8 path */
@keyframes think-figure8 {
    0%, 100% { transform: translate(0, 0); }
    25%      { transform: translate(3px, -3px); }
    50%      { transform: translate(0, 0); }
    75%      { transform: translate(-3px, 3px); }
}

/* 7. Wobble with slight scale */
@keyframes think-wobble {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25%      { transform: rotate(-6deg) scale(1.03); }
    75%      { transform: rotate(6deg) scale(1.03); }
}

/* 8. Nod forward (scaleY squash) */
@keyframes think-nod {
    0%, 100% { transform: scaleY(1) translateY(0); }
    50%      { transform: scaleY(0.88) translateY(2px); }
}

/* 9. Jelly deformation */
@keyframes think-jelly {
    0%, 100% { transform: scale(1, 1); }
    25%      { transform: scale(1.08, 0.92); }
    50%      { transform: scale(0.95, 1.05); }
    75%      { transform: scale(1.05, 0.96); }
}

/* 10. Small circular orbit */
@keyframes think-orbit {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(3px, -2px); }
    50%  { transform: translate(0, -4px); }
    75%  { transform: translate(-3px, -2px); }
    100% { transform: translate(0, 0); }
}

/* 11. Bounce with squash/stretch */
@keyframes think-squash {
    0%, 100% { transform: translateY(0) scaleX(1) scaleY(1); }
    30%      { transform: translateY(-5px) scaleX(0.95) scaleY(1.08); }
    60%      { transform: translateY(2px) scaleX(1.06) scaleY(0.92); }
}

/* 12. Pendulum swing */
@keyframes think-pendulum {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(12deg); }
    75%      { transform: rotate(-12deg); }
}

/* 13. Micro vibrate/buzz */
@keyframes think-buzz {
    0%, 50%, 100% { transform: translate(0, 0); }
    10%           { transform: translate(-1px, 1px); }
    20%           { transform: translate(1px, -1px); }
    30%           { transform: translate(-1px, 0); }
    40%           { transform: translate(1px, 1px); }
}

/* 14. Rock side to side (origin at bottom) */
@keyframes think-rock {
    0%, 100% { transform: rotate(0deg); }
    33%      { transform: rotate(-7deg); }
    66%      { transform: rotate(7deg); }
}

/* 15. Zoom with half-spin */
@keyframes think-zoom-spin {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50%      { transform: scale(1.1) rotate(180deg); }
}

/* 16. Sway with translation */
@keyframes think-sway {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    50%      { transform: translateX(4px) rotate(4deg); }
}

/* 17. Heartbeat double pulse */
@keyframes think-heartbeat {
    0%, 100% { transform: scale(1); }
    14%      { transform: scale(1.15); }
    28%      { transform: scale(1); }
    42%      { transform: scale(1.1); }
    56%      { transform: scale(1); }
}

/* 18. Counter-clockwise spin */
@keyframes think-spin-ccw {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

/* 19. Diagonal bounce */
@keyframes think-diagonal {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(3px, -3px); }
}

/* 20. Gentle breathe (very subtle) */
@keyframes think-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.07); }
}

/* 21. Skew wave */
@keyframes think-wave {
    0%, 100% { transform: skewX(0deg); }
    25%      { transform: skewX(-5deg); }
    75%      { transform: skewX(5deg); }
}

/* 22. Occasional pop */
@keyframes think-pop {
    0%, 70%, 100% { transform: scale(1); }
    80%           { transform: scale(1.2); }
    90%           { transform: scale(0.95); }
}

/* 23. Quick flutter rotations */
@keyframes think-flutter {
    0%, 100% { transform: rotate(0deg); }
    20%      { transform: rotate(6deg); }
    40%      { transform: rotate(-6deg); }
    60%      { transform: rotate(4deg); }
    80%      { transform: rotate(-4deg); }
}

/* 24. Slow horizontal drift */
@keyframes think-drift {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(4px); }
}

/* 25. Hue/brightness color pulse */
@keyframes think-color-pulse {
    0%, 100% { filter: hue-rotate(0deg) brightness(1); }
    50%      { filter: hue-rotate(40deg) brightness(1.2); }
}

/* 26. Glow with drop-shadow and scale */
@keyframes think-glow {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0px transparent); }
    50%      { transform: scale(1.06); filter: drop-shadow(0 0 8px rgba(212, 165, 116, 0.7)); }
}

/* 27. Lean to one side */
@keyframes think-lean {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    50%      { transform: rotate(-10deg) translateY(-2px); }
}

/* 28. Jump with squash on landing */
@keyframes think-jump {
    0%, 100% { transform: translateY(0) scaleX(1) scaleY(1); }
    15%      { transform: translateY(0) scaleX(1.1) scaleY(0.88); }
    35%      { transform: translateY(-6px) scaleX(0.94) scaleY(1.06); }
    55%      { transform: translateY(0) scaleX(1.06) scaleY(0.94); }
    70%      { transform: translateY(0) scaleX(1) scaleY(1); }
}

/* 29. 3D twist on Y axis */
@keyframes think-twist {
    0%, 100% { transform: perspective(200px) rotateY(0deg); }
    50%      { transform: perspective(200px) rotateY(25deg); }
}

/* 30. Color spin - rotate with hue shift */
@keyframes think-color-spin {
    0%   { transform: rotate(0deg); filter: hue-rotate(0deg); }
    50%  { transform: rotate(180deg); filter: hue-rotate(45deg); }
    100% { transform: rotate(360deg); filter: hue-rotate(0deg); }
}

/* ============================================================================
   FINDINGS PANEL
   Interactive selectable findings cards from present_findings tool
   ============================================================================ */

.chat-findings-panel {
    background: var(--chat-white);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--chat-border);
    overflow: hidden;
    margin: 12px 0;
    animation: fadeIn 0.3s ease;
}

.chat-findings-panel.dismissed {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    max-height: 0;
    overflow: hidden;
    margin: 0;
    border: none;
}

.findings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--chat-primary);
    color: var(--chat-white);
}

.findings-title {
    font-weight: 600;
    font-size: 15px;
}

.findings-count {
    font-size: 12px;
    opacity: 0.85;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 10px;
    border-radius: 12px;
}

.findings-summary {
    padding: 10px 16px;
    margin: 0;
    font-size: 13px;
    color: var(--chat-gray);
    line-height: 1.5;
    background: rgba(212, 165, 116, 0.04);
    border-bottom: 1px solid var(--chat-border);
}

.findings-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.findings-list::-webkit-scrollbar {
    width: 5px;
}

.findings-list::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

.findings-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    margin-bottom: 6px;
    border: 1px solid var(--chat-border);
    background: var(--chat-white);
}

.findings-item:hover {
    background: rgba(212, 165, 116, 0.06);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.findings-item input[type="checkbox"] {
    margin-top: 4px;
    flex-shrink: 0;
    accent-color: var(--chat-primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.findings-item-content {
    flex: 1;
    min-width: 0;
}

.findings-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.findings-severity-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.4;
}

.findings-severity-badge.severity-critical {
    background: rgba(231, 76, 60, 0.15);
    color: #c0392b;
}

.findings-severity-badge.severity-warning {
    background: rgba(243, 156, 18, 0.15);
    color: #d68910;
}

.findings-severity-badge.severity-info {
    background: rgba(52, 152, 219, 0.15);
    color: #2980b9;
}

.findings-severity-badge.severity-success {
    background: rgba(46, 204, 113, 0.15);
    color: #27ae60;
}

.findings-category {
    font-size: 11px;
    color: var(--chat-gray);
}

.findings-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--chat-dark);
    margin-bottom: 2px;
}

.findings-item-desc {
    font-size: 13px;
    color: var(--chat-gray);
    line-height: 1.5;
}

.findings-item-data {
    margin-top: 6px;
}

.findings-item-data.collapsed .findings-data-content {
    display: none;
}

.findings-data-toggle {
    background: none;
    border: none;
    color: var(--chat-primary);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.findings-data-toggle:hover {
    opacity: 0.8;
}

.findings-data-content {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 8px 10px;
    margin-top: 4px;
    font-size: 11px;
    font-family: 'Consolas', 'Monaco', monospace;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto;
    color: var(--chat-dark);
}

/* Findings Action Bar */
.findings-action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-light);
}

.findings-btn,
.findings-btn-secondary,
.findings-btn-primary {
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--chat-border);
    background: var(--chat-white);
    color: var(--chat-dark);
}

.findings-btn:hover {
    background: var(--chat-light);
    border-color: var(--chat-gray);
}

.findings-btn-secondary {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
    background: rgba(212, 165, 116, 0.08);
}

.findings-btn-secondary:hover {
    background: rgba(212, 165, 116, 0.18);
}

.findings-btn-primary {
    background: var(--chat-primary);
    color: var(--chat-white);
    border-color: var(--chat-primary);
}

.findings-btn-primary:hover {
    background: #C4956A;
    transform: translateY(-1px);
}

/* Persistent Findings Icon */
#findings-master-icon {
    position: fixed;
    top: 16px;
    right: 64px;
    width: 36px;
    height: 36px;
    background: var(--chat-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    color: var(--chat-white);
}

#findings-master-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

#findings-master-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.findings-icon-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--chat-danger);
    color: var(--chat-white);
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* Mobile responsive for findings */
@media (max-width: 768px) {
    .findings-action-bar {
        flex-direction: column;
    }

    .findings-action-bar button {
        width: 100%;
    }

    #findings-master-icon {
        top: 10px;
        right: 50px;
        width: 32px;
        height: 32px;
    }
}

/* Dark theme overrides */
.dark-theme .chat-findings-panel {
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-theme .findings-item {
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-theme .findings-data-content {
    background: rgba(0, 0, 0, 0.3);
    color: #cdd6f4;
}

/* ============================================================================
   CHOICE PROMPT
   Inline choice buttons from present_choices tool
   ============================================================================ */

.chat-choice-prompt {
    background: var(--chat-white);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--chat-border);
    overflow: hidden;
    margin: 12px 0;
    animation: choiceSlideIn 0.3s ease;
}

@keyframes choiceSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-choice-prompt.choice-prompt-dismissed {
    opacity: 0;
    transform: scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-choice-prompt.choice-prompt-resolved {
    border-color: transparent;
    box-shadow: none;
    background: transparent;
}

.choice-prompt-header {
    padding: 12px 16px 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--chat-dark);
}

.choice-prompt-buttons {
    padding: 4px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.choice-prompt-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    background: var(--chat-white);
    cursor: pointer;
    text-align: left;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    animation: choiceBtnEnter 0.3s ease both;
}

@keyframes choiceBtnEnter {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.choice-prompt-btn:hover:not(:disabled) {
    transform: translateX(4px);
    border-color: var(--chat-primary);
    background: rgba(212, 165, 116, 0.06);
    box-shadow: 0 2px 8px rgba(212, 165, 116, 0.15);
}

.choice-prompt-btn:active:not(:disabled) {
    transform: translateX(2px);
}

.choice-prompt-btn.choice-selected {
    background: rgba(212, 165, 116, 0.15);
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.2);
}

.choice-prompt-btn.choice-disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.choice-prompt-btn.choice-disabled.choice-selected {
    opacity: 1;
}

.choice-btn-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-dark);
    flex-shrink: 0;
}

.choice-btn-desc {
    font-size: 12px;
    color: var(--chat-gray);
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.choice-prompt-result {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(46, 204, 113, 0.12);
    color: #27ae60;
    border: 1px solid rgba(46, 204, 113, 0.25);
    animation: choiceSlideIn 0.2s ease;
}

.choice-prompt-result.result-yes {
    background: rgba(46, 204, 113, 0.12);
    color: #27ae60;
    border-color: rgba(46, 204, 113, 0.25);
}

.choice-prompt-result.result-no {
    background: rgba(231, 76, 60, 0.10);
    color: #c0392b;
    border-color: rgba(231, 76, 60, 0.25);
}

/* Embedded content slot for action results (graphs, tables) */
.choice-content-slot:empty { display: none; }
.choice-content-slot {
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
}

/* ---- Confirm box (Yes/No) ---- */
.chat-confirm-box {
    text-align: center;
}

.confirm-box-header {
    padding: 14px 16px 10px;
    font-weight: 600;
    font-size: 14px;
    color: var(--chat-dark);
}

.confirm-box-buttons {
    display: flex;
    gap: 10px;
    padding: 4px 16px 14px;
    justify-content: center;
}

.confirm-btn {
    padding: 10px 28px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.confirm-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.confirm-btn:active:not(:disabled) { transform: translateY(0); }
.confirm-btn:disabled { opacity: 0.5; cursor: default; }

.confirm-btn-yes {
    background: var(--chat-primary, #D4A574);
    color: white;
}

.confirm-btn-no {
    background: transparent;
    border-color: var(--chat-border, #dee2e6);
    color: var(--chat-gray, #94a0ad);
}

.confirm-btn-no:hover:not(:disabled) {
    border-color: var(--chat-primary, #D4A574);
    color: var(--chat-dark);
}

/* ---- Multi-select mode ---- */
.chat-multi-select .choice-prompt-header {
    padding-bottom: 4px;
}

.multi-select-options {
    padding: 4px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 320px;
    overflow-y: auto;
}

.multi-select-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    animation: choiceBtnEnter 0.3s ease both;
}

.multi-select-option:hover {
    border-color: var(--chat-primary);
    background: rgba(212, 165, 116, 0.06);
}

.multi-select-cb {
    width: 16px;
    height: 16px;
    accent-color: var(--chat-primary, #D4A574);
    flex-shrink: 0;
}

.multi-select-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.multi-select-actions {
    padding: 8px 12px 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.multi-select-submit {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    background: var(--chat-primary, #D4A574);
    color: white;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.multi-select-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(212, 165, 116, 0.3);
}

.multi-select-submit:disabled {
    opacity: 0.5;
    cursor: default;
}

.chat-message.user.queued .chat-message-content {
    background: rgba(212, 165, 116, 0.4);
    border: 1px dashed var(--chat-primary);
    opacity: 0.8;
}

.queued-badge {
    position: absolute;
    top: -10px;
    right: 12px;
    background: var(--chat-primary);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
}

/* Chrome-style tabs density */
.chatbot-session-tabs.dense .chatbot-session-tab {
    min-width: 60px;
    padding: 8px 10px;
}

.chatbot-session-tabs.dense .session-title {
    display: none;
}

.chatbot-session-tabs.dense .chatbot-session-tab.active .session-title {
    display: inline;
}


/* Dark theme overrides */
.dark-theme .chat-choice-prompt {
    background: var(--dark-card, #1e1e2e);
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-theme .choice-prompt-header,
.dark-theme .confirm-box-header {
    color: var(--dark-text, #cdd6f4);
}

.dark-theme .choice-prompt-btn {
    background: var(--dark-card, #1e1e2e);
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-theme .choice-prompt-btn:hover:not(:disabled) {
    background: rgba(212, 165, 116, 0.1);
    border-color: var(--chat-primary);
}

.dark-theme .choice-btn-label {
    color: var(--dark-text, #cdd6f4);
}

.dark-theme .choice-btn-desc {
    color: var(--dark-subtext, #a6adc8);
}

.dark-theme .choice-prompt-result {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.3);
}

.dark-theme .choice-prompt-result.result-no {
    background: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.3);
}

.dark-theme .confirm-btn-no {
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--dark-subtext, #a6adc8);
}

.dark-theme .confirm-btn-no:hover:not(:disabled) {
    border-color: var(--chat-primary);
    color: var(--dark-text, #cdd6f4);
}

.dark-theme .multi-select-option {
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-theme .multi-select-option:hover {
    background: rgba(212, 165, 116, 0.08);
    border-color: var(--chat-primary);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .thinking-avatar {
        animation: none !important;
    }
    .chat-choice-prompt,
    .choice-prompt-btn {
        animation: none !important;
    }
}

/* =========================================================================
   INLINE DEBUG REPORT CARDS
   ========================================================================= */

.chat-inline-debug-report {
    background: var(--chat-white, #1e2533);
    border: 1px solid #2f3944;
    border-radius: 12px;
    padding: 16px;
    margin: 8px 0;
    animation: proposalSlideIn 0.3s ease-out;
    transition: opacity 0.3s, transform 0.3s;
}

.chat-inline-debug-report.dismissed {
    opacity: 0;
    transform: translateY(-10px);
}

.chat-inline-debug-report.submitted {
    border-color: var(--chat-success, #2ECC71);
}

.inline-debug-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.inline-debug-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inline-debug-badge.bug {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.inline-debug-badge.feature {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
}

.inline-debug-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--chat-text, #e7e9ea);
}

.inline-debug-field {
    margin-bottom: 12px;
}

.inline-debug-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-secondary, #bfc8d1);
    margin-bottom: 4px;
}

.inline-debug-hint {
    font-weight: 400;
    opacity: 0.7;
}

.inline-debug-desc {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid #2f3944;
    border-radius: 8px;
    padding: 10px;
    font-size: 13px;
    color: var(--chat-text, #e7e9ea);
    resize: vertical;
    font-family: inherit;
    line-height: 1.4;
    box-sizing: border-box;
}

.inline-debug-desc:focus {
    outline: none;
    border-color: var(--chat-primary, #3498db);
}

.inline-debug-type-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-debug-type-row label {
    margin-bottom: 0;
}

.inline-debug-type-btn {
    padding: 4px 12px;
    border: 1px solid #2f3944;
    border-radius: 6px;
    background: transparent;
    color: var(--chat-secondary, #bfc8d1);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.inline-debug-type-btn:hover {
    border-color: var(--chat-primary, #3498db);
    color: var(--chat-text, #e7e9ea);
}

.inline-debug-type-btn.active {
    background: rgba(52, 152, 219, 0.15);
    border-color: var(--chat-primary, #3498db);
    color: var(--chat-primary, #3498db);
}

.inline-debug-sections {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.inline-debug-section-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid #2f3944;
    border-radius: 6px;
    font-size: 12px;
    color: var(--chat-text, #e7e9ea);
    cursor: pointer;
    transition: background 0.2s;
}

.inline-debug-section-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.inline-debug-section-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
}

.inline-debug-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.inline-debug-option {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--chat-secondary, #bfc8d1);
    cursor: pointer;
}

.inline-debug-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
}

.inline-debug-cli {
    gap: 6px;
}

.inline-debug-cli-label {
    font-weight: 600;
}

.inline-debug-cli-select {
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid #2f3944;
    background: rgba(0, 0, 0, 0.2);
    color: var(--chat-text, #e7e9ea);
    font-size: 12px;
}

.inline-debug-cli-select:focus {
    outline: none;
    border-color: var(--chat-primary, #3498db);
}

.inline-debug-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #2f3944;
}

.inline-debug-btn {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.inline-debug-btn.cancel {
    background: transparent;
    border-color: #2f3944;
    color: var(--chat-secondary, #bfc8d1);
}

.inline-debug-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--chat-text, #e7e9ea);
}

.inline-debug-btn.submit {
    background: rgba(52, 152, 219, 0.15);
    border-color: var(--chat-primary, #3498db);
    color: var(--chat-primary, #3498db);
}

.inline-debug-btn.submit:hover {
    background: rgba(52, 152, 219, 0.3);
}

.inline-debug-btn.submit-launch {
    background: var(--chat-primary, #3498db);
    color: white;
}

.inline-debug-btn.submit-launch:hover {
    background: #2980b9;
}

.inline-debug-submitting {
    font-size: 12px;
    color: var(--chat-secondary, #bfc8d1);
}

.inline-debug-success {
    font-size: 12px;
    color: var(--chat-success, #2ECC71);
    font-weight: 600;
}

.inline-debug-launched {
    font-size: 12px;
    color: var(--chat-primary, #3498db);
}

.inline-debug-error {
    font-size: 12px;
    color: #e74c3c;
}

.inline-debug-stack-nav {
    display: flex;
    justify-content: center;
    padding: 6px 0;
    font-size: 12px;
    color: var(--chat-secondary, #bfc8d1);
}

/* ============================================================================
   LOADING INDICATOR ENHANCEMENTS (Baking Theme)
   ============================================================================ */

/* Bubbling Animation for Icons */
@keyframes bubbling {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-5px) rotate(-5deg); }
    75% { transform: translateY(5px) rotate(5deg); }
}

@keyframes bubbling-reverse {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(5px) rotate(5deg); }
    75% { transform: translateY(-5px) rotate(-5deg); }
}

.bubbling-icon {
    display: inline-block;
    animation: bubbling 3s ease-in-out infinite;
    width: 24px;
    height: 24px;
    vertical-align: middle;
}

.bubbling-icon.reverse {
    animation-name: bubbling-reverse;
}

/* Transition Effects for Messages and Icons */
.transition-fade-enter { opacity: 0; }
.transition-fade-enter-active { opacity: 1; transition: opacity 0.5s ease-in; }
.transition-fade-exit { opacity: 1; }
.transition-fade-exit-active { opacity: 0; transition: opacity 0.5s ease-out; }

.transition-scale-enter { transform: scale(0.8); opacity: 0; }
.transition-scale-enter-active { transform: scale(1); opacity: 1; transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.transition-scale-exit { transform: scale(1); opacity: 1; }
.transition-scale-exit-active { transform: scale(0.8); opacity: 0; transition: all 0.5s ease-in; }

.transition-translate-enter { transform: translateY(10px); opacity: 0; }
.transition-translate-enter-active { transform: translateY(0); opacity: 1; transition: all 0.5s ease-out; }
.transition-translate-exit { transform: translateY(0); opacity: 1; }
.transition-translate-exit-active { transform: translateY(-10px); opacity: 0; transition: all 0.5s ease-in; }

/* Enhanced Loading Container Styles */
.loading-container {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 8px 4px;
}

.loading-icon-wrapper {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Loading icon shake & pulse animations — applied randomly via JS */
@keyframes icon-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px) rotate(-4deg); }
    40% { transform: translateX(3px) rotate(4deg); }
    60% { transform: translateX(-2px) rotate(-2deg); }
    80% { transform: translateX(2px) rotate(2deg); }
}
@keyframes icon-rattle {
    0%, 100% { transform: rotate(0deg); }
    15% { transform: rotate(6deg); }
    30% { transform: rotate(-6deg); }
    45% { transform: rotate(4deg); }
    60% { transform: rotate(-4deg); }
    75% { transform: rotate(2deg); }
    90% { transform: rotate(-1deg); }
}
@keyframes icon-wobble {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    15% { transform: translateX(-4px) rotate(-5deg); }
    30% { transform: translateX(3px) rotate(3deg); }
    45% { transform: translateX(-2px) rotate(-3deg); }
    60% { transform: translateX(2px) rotate(2deg); }
    75% { transform: translateX(-1px) rotate(-1deg); }
}
@keyframes icon-jitter {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-1px, 1px); }
    20% { transform: translate(1px, -1px); }
    30% { transform: translate(-1px, -1px); }
    40% { transform: translate(1px, 1px); }
    50% { transform: translate(-1px, 0); }
    60% { transform: translate(1px, -1px); }
    70% { transform: translate(0, 1px); }
    80% { transform: translate(-1px, -1px); }
    90% { transform: translate(1px, 0); }
}
@keyframes icon-bounce-y {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Color pulse animations — cycle through 1-5 hues */
@keyframes icon-pulse-warm {
    0%, 100% { filter: hue-rotate(0deg) brightness(1); }
    25% { filter: hue-rotate(20deg) brightness(1.15); }
    50% { filter: hue-rotate(-15deg) brightness(1.25); }
    75% { filter: hue-rotate(10deg) brightness(1.1); }
}
@keyframes icon-pulse-cool {
    0%, 100% { filter: hue-rotate(0deg) brightness(1); }
    33% { filter: hue-rotate(40deg) brightness(1.2); }
    66% { filter: hue-rotate(-30deg) brightness(1.15); }
}
@keyframes icon-pulse-rainbow {
    0% { filter: hue-rotate(0deg) brightness(1); }
    20% { filter: hue-rotate(72deg) brightness(1.1); }
    40% { filter: hue-rotate(144deg) brightness(1.2); }
    60% { filter: hue-rotate(216deg) brightness(1.15); }
    80% { filter: hue-rotate(288deg) brightness(1.1); }
    100% { filter: hue-rotate(360deg) brightness(1); }
}
@keyframes icon-pulse-flash {
    0%, 100% { filter: brightness(1); transform: scale(1); }
    50% { filter: brightness(1.4); transform: scale(1.1); }
}
@keyframes icon-pulse-glow {
    0%, 100% { filter: brightness(1) drop-shadow(0 0 0 transparent); }
    50% { filter: brightness(1.2) drop-shadow(0 0 6px rgba(255, 200, 60, 0.5)); }
}

.loading-icon-animated {
    display: inline-block;
}

.loading-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    min-width: 0;
}

.loading-message {
    font-size: 14px;
    color: var(--chat-dark);
    font-weight: 500;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: fadeInMsg 0.4s ease-in-out;
}

@keyframes fadeInMsg {
    0% { opacity: 0; transform: translateY(4px); }
    100% { opacity: 1; transform: translateY(0); }
}

.loading-tip {
    font-size: 11px;
    color: var(--chat-gray);
    margin: 2px 0 0 0;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tool Tooltip overrides for the new loader */
.chat-tool-indicator .tool-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    min-width: 280px;
}

.loader-progress-dots {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.loader-dot {
    width: 6px;
    height: 6px;
    background: var(--chat-primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.loader-dot:nth-child(2) { animation-delay: 0.2s; }
.loader-dot:nth-child(3) { animation-delay: 0.4s; }

/* Icon SVG Styles */
.loading-icon-svg {
    width: 24px;
    height: 24px;
    stroke: var(--chat-primary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.loading-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.tip-icon-svg {
    stroke: var(--chat-secondary);
}

/* ============================================================================
   RAW / DEBUG MODE
   Developer view showing system prompt, tool calls, and raw conversation
   ============================================================================ */

.chatbot-raw-mode {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0d1117;
}

.raw-mode-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}

.raw-mode-label {
    font-size: 12px;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.raw-mode-close-btn {
    padding: 4px 12px;
    border: 1px solid #30363d;
    border-radius: 6px;
    background: transparent;
    color: #8b949e;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.raw-mode-close-btn:hover {
    background: #21262d;
    color: #c9d1d9;
    border-color: #8b949e;
}

.raw-mode-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 12px;
    line-height: 1.5;
}

.raw-mode-content::-webkit-scrollbar {
    width: 6px;
}

.raw-mode-content::-webkit-scrollbar-track {
    background: transparent;
}

.raw-mode-content::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

/* Raw mode button active state */
#raw-mode-btn.active {
    background: rgba(212, 165, 116, 0.2);
    color: var(--chat-primary);
}

/* Sections */
.raw-section {
    margin-bottom: 8px;
    border: 1px solid #30363d;
    border-radius: 6px;
    overflow: hidden;
}

.raw-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #161b22;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.raw-section-header::-webkit-details-marker {
    display: none;
}

.raw-section-header::before {
    content: '\25B6';
    font-size: 10px;
    color: #484f58;
    transition: transform 0.15s;
}

details[open] > .raw-section-header::before {
    transform: rotate(90deg);
}

.raw-section-title {
    font-weight: 600;
    color: #c9d1d9;
    font-size: 12px;
}

.raw-section-body {
    padding: 12px;
    background: #0d1117;
    border-top: 1px solid #21262d;
}

/* Badges */
.raw-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.raw-badge-system {
    background: rgba(136, 132, 216, 0.2);
    color: #a5a0e8;
}

.raw-badge-user {
    background: rgba(212, 165, 116, 0.2);
    color: #D4A574;
}

.raw-badge-assistant {
    background: rgba(46, 134, 171, 0.2);
    color: #58a6c7;
}

.raw-badge-tool {
    background: rgba(238, 130, 238, 0.15);
    color: #d183d1;
}

.raw-badge-graph {
    background: rgba(80, 200, 120, 0.15);
    color: #6bce8a;
}

.raw-meta {
    font-size: 11px;
    color: #484f58;
    margin-left: auto;
}

/* Pre-formatted text */
.raw-prompt-text,
.raw-message-text,
.raw-tool-args {
    margin: 0;
    padding: 10px;
    background: #0d1117;
    color: #c9d1d9;
    border-radius: 4px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 11px;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

.raw-prompt-text {
    max-height: 500px;
    border: 1px solid #21262d;
}

.raw-tools-list {
    margin-top: 10px;
    padding: 8px 10px;
    background: #161b22;
    border-radius: 4px;
    color: #8b949e;
    font-size: 11px;
}

.raw-tools-list code {
    background: rgba(110, 118, 129, 0.15);
    padding: 1px 5px;
    border-radius: 3px;
    color: #79c0ff;
    font-size: 10px;
}

/* Messages */
.raw-message {
    margin-bottom: 6px;
    border: 1px solid #21262d;
    border-radius: 6px;
    overflow: hidden;
}

.raw-message-user {
    border-left: 3px solid #D4A574;
}

.raw-message-assistant {
    border-left: 3px solid #58a6c7;
}

.raw-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #161b22;
}

.raw-message-index {
    font-size: 10px;
    color: #484f58;
    font-weight: 600;
}

.raw-message-text {
    margin: 0;
    border-radius: 0;
    border-top: 1px solid #21262d;
}

/* Tool calls */
.raw-tool-call,
.raw-graph-entry {
    margin: 0;
    border-top: 1px solid #21262d;
}

.raw-tool-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #0d1117;
    cursor: pointer;
    font-size: 11px;
    color: #8b949e;
    list-style: none;
}

.raw-tool-header::-webkit-details-marker {
    display: none;
}

.raw-tool-header code {
    background: rgba(110, 118, 129, 0.15);
    padding: 1px 5px;
    border-radius: 3px;
    color: #d2a8ff;
    font-size: 11px;
}

.raw-tool-args {
    border-radius: 0;
    border-top: 1px solid #21262d;
    max-height: 300px;
}

.raw-loading {
    padding: 20px;
    text-align: center;
    color: #484f58;
}

.raw-empty {
    padding: 30px 20px;
    text-align: center;
    color: #484f58;
    font-style: italic;
}

