/* ══════════════════════════════════════════════════════════════
   Shared Chat UI Styles
   Used by: ChatBotWindow.razor, AiAgentEditor.razor (builder)
   ══════════════════════════════════════════════════════════════ */

/* ── Chat Shell ───────────────────────────────────────────── */

.chat-shell {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* ── Transcript Area ──────────────────────────────────────── */

.chat-transcript {
    flex: 0 0 80%;
    min-height: 200px;
    overflow-y: auto;
    padding: 2rem;
    background: white;
}

.chat-transcript-resize-handle {
    height: 8px;
    cursor: row-resize;
    background: transparent;
    border-top: 1px solid var(--bs-border-color);
    position: relative;
    flex: 0 0 auto;
}

.chat-transcript-resize-handle:hover {
    background: rgba(var(--bs-primary-rgb), 0.08);
    border-top-color: rgba(var(--bs-primary-rgb), 0.35);
}

.chat-transcript-resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 4px;
    background: var(--bs-border-color);
    border-radius: 2px;
}

/* ── Chat Bubbles ─────────────────────────────────────────── */

.chat-bubble {
    max-width: 900px;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    padding: 0.75rem 0.9rem;
    background: var(--bs-white);
}

.chat-bubble-user {
    background: rgba(var(--bs-primary-rgb), 0.08);
    border-color: rgba(var(--bs-primary-rgb), 0.25);
}

.chat-bubble-assistant {
    background: var(--bs-white);
    border-color: var(--bs-border-color);
}

.chat-bubble-error {
    background: rgba(var(--bs-danger-rgb), 0.06);
    border-color: rgba(var(--bs-danger-rgb), 0.45);
}

.chat-message-content {
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Composer ─────────────────────────────────────────────── */

.chat-composer {
    background: white;
    flex: 1 1 auto;
    min-height: 90px;
    overflow-y: auto;
    border-top: 1px solid #f1f5f9;
}

.input-wrapper {
    padding: 1.5rem;
}

.input-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    position: relative;
    padding: 8px;
    transition: border-color 0.3s;
}

.input-box:focus-within {
    border-color: var(--primary-color, #CC9933);
    box-shadow: 0 0 0 3px rgba(204, 153, 51, 0.15);
}

.chat-textarea {
    width: 100%;
    border: none !important;
    background: transparent !important;
    resize: none;
    max-height: 160px;
}

.chat-textarea .k-input,
.chat-textarea .k-input-inner,
.chat-textarea .k-textarea,
.chat-textarea textarea {
    border: none !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 10px !important;
    padding-right: 96px !important;
    padding-bottom: 12px !important;
}

.chat-textarea .k-input:focus,
.chat-textarea .k-input-inner:focus,
.chat-textarea .k-textarea:focus,
.chat-textarea textarea:focus {
    border: none !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Auto-resizing native textarea for config chat */
.chat-textarea-auto {
    width: 100%;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    box-shadow: none;
    padding: 10px;
    padding-right: 96px;
    padding-bottom: 12px;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
    min-height: 1.5em;
    max-height: calc(1.5em * 3 + 22px);
    overflow-y: auto;
}

.chat-textarea-auto:focus {
    outline: none;
    box-shadow: none;
}

.chat-textarea-auto::placeholder {
    color: #94a3b8;
}

.chat-textarea-auto:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.send-btn-wrapper {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

.send-btn {
    padding: 10px 20px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 0.9rem !important;
    background: var(--primary-color, #CC9933) !important;
    border-color: var(--primary-color, #CC9933) !important;
    min-height: 40px !important;
}

.send-btn:hover {
    background: var(--primary-hover, #B8862E) !important;
    border-color: var(--primary-hover, #B8862E) !important;
}

.send-btn:active {
    transform: scale(0.95);
}

.db-status {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 8px;
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ── Suggestions / Welcome ────────────────────────────────── */

.chat-suggestions {
    padding: 2rem;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.suggestions-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
    text-align: center;
}

.suggestions-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1rem;
    width: 100%;
}

.suggestion-category-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    text-align: left;
    transition: border-color 0.2s;
}

.suggestion-category-card:hover {
    border-color: #cbd5e1;
}

.suggestion-category-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid #f1f5f9;
}

.suggestion-category-icon {
    font-size: 1.1rem;
    color: var(--primary-color, #CC9933);
}

.suggestion-category-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.suggestion-category-prompts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.prompt-chip {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.84rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #1e293b;
    text-align: left;
    line-height: 1.4;
}

.prompt-chip:hover {
    border-color: var(--primary-color, #CC9933);
    color: var(--primary-color, #CC9933);
    background: rgba(204, 153, 51, 0.06);
}

.show-more-link {
    display: inline-block;
    background: none;
    border: none;
    color: var(--primary-color, #CC9933);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 0.25rem;
    text-align: left;
}

.show-more-link:hover {
    text-decoration: underline;
    color: var(--primary-hover, #B8862E);
}

/* ── Summary formatting ───────────────────────────────────── */

.formatted-summary {
    white-space: normal;
}

.formatted-summary p.summary-line {
    margin: 0 0 4px 0;
    line-height: 1.5;
}

.formatted-summary p.summary-line:last-child {
    margin-bottom: 0;
}

.formatted-summary strong {
    color: #1a202c;
    font-weight: 600;
}

.formatted-summary .insight-callout {
    margin-top: 8px;
    padding: 8px 12px;
    background: #fffbea;
    border-left: 3px solid #d69e2e;
    border-radius: 4px;
    font-size: 0.88rem;
    line-height: 1.45;
    color: #744210;
}

.formatted-summary .insight-callout i {
    margin-right: 6px;
    color: #d69e2e;
}

.formatted-summary .insight-callout strong {
    color: #744210;
}

.formatted-summary .summary-table-scroll {
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.formatted-summary .summary-table {
    width: auto;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88rem;
    border-radius: 8px;
}

.formatted-summary .summary-table thead th,
.formatted-summary .summary-table tbody td {
    padding: 7px 14px;
    white-space: nowrap;
    text-align: left;
    vertical-align: middle;
}

.formatted-summary .summary-table thead th {
    background: #f8fafc;
    font-weight: 600;
    color: #1a202c;
    border-bottom: 2px solid #e2e8f0;
}

.formatted-summary .summary-table tbody td {
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.formatted-summary .summary-table tbody tr:last-child td {
    border-bottom: none;
}

.formatted-summary .summary-table tbody tr:hover {
    background: #f8fafc;
}

/* ── Suggested follow-up prompts ──────────────────────────── */

.suggested-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 4px;
}

.suggested-prompt-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    font-size: 0.82rem;
    line-height: 1.3;
    color: #4a5568;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.suggested-prompt-chip:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
    color: #2d3748;
}

.suggested-prompt-chip:active {
    background: #e2e8f0;
}

/* ── Pending / status indicator ───────────────────────────── */

.pending-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
    min-width: 300px;
    font-size: 0.95rem;
    padding: 0.25rem 0;
}

.pending-event-icon {
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
}

/* ── Source toggle badges ─────────────────────────────────── */

.source-toggle {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    line-height: 1.4;
}

.source-toggle-active {
    background-color: var(--primary-color, #CC9933) !important;
    color: white !important;
    border-color: var(--primary-color, #CC9933) !important;
}

.source-toggle-inactive {
    background-color: #f1f5f9 !important;
    color: #64748b !important;
    border-color: #e2e8f0 !important;
}

.source-toggle-inactive:hover {
    background-color: #e2e8f0 !important;
    border-color: #cbd5e1 !important;
}

.source-toggle-auto {
    background-color: #f8f4eb !important;
    color: var(--primary-color, #CC9933) !important;
    border-color: #e8dcc8 !important;
}

/* ── Typing dots animation ────────────────────────────────── */

.chat-thinking-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #9ca3af;
    animation: chat-dot-bounce 1.4s infinite ease-in-out both;
}

.chat-thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-thinking-dot:nth-child(2) { animation-delay: -0.16s; }
.chat-thinking-dot:nth-child(3) { animation-delay: 0s; }

@keyframes chat-dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 576px) {
    .chat-transcript {
        padding: 0.75rem;
    }

    .suggestions-categories {
        grid-template-columns: 1fr;
    }
}

/* ── Query Results Detail Table ── */
.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.detail-table thead th {
    position: sticky;
    top: 0;
    background: #f7fafc;
    border-bottom: 2px solid #e2e8f0;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-table tbody td {
    padding: 6px 12px;
    border-bottom: 1px solid #edf2f7;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-table tbody tr:hover td {
    background: #f7fafc;
}
