/* Custom CSS for Chainlit - Override default styles */

/* ============================================
   CSS Custom Properties (Variables)
   ============================================ */

:root {
    /* Base font sizes */
    --font-size-base: 1rem;
    --font-size-xs: 0.6875rem;   /* 11px at 16px base */
    --font-size-sm: 0.75rem;     /* 12px at 16px base */
    --font-size-md: 0.875rem;    /* 14px at 16px base */
    --font-size-lg: 1rem;        /* 16px at 16px base */

    /* Line heights */
    --line-height-base: 1.75rem; /* matches .leading-7 (28px) */
    --line-height-tight: 1.25rem;
    --line-height-normal: 1.5rem;
    --line-height-relaxed: 1.625rem;

    /* Component-specific sizes */
    --font-size-icon: 1rem;
    --font-size-icon-sm: 0.875rem;
    --font-size-label: 0.75rem;
    --font-size-button: 0.6875rem;
    --font-size-content: 0.6875rem;


    --accent: 215 90% 55%;
    --accent-foreground: 215 50% 96%;
    --primary: 220 80% 50%;
    --primary-foreground: 0 0% 100%;
    --accent-hover: 215 90% 45%;
    --primary-hover: 220 80% 40%;
}

/* Responsive overrides for small screens */
@media (max-width: 599px) {
    :root {
        --font-size-base: 0.875rem;
        --font-size-xs: 0.5625rem;   /* 9px */
        --font-size-sm: 0.625rem;    /* 10px */
        --font-size-md: 0.6875rem;   /* 11px */
        --font-size-lg: 0.875rem;    /* 14px */

        --line-height-base: 1.25rem;  /* reduced from 1.75rem */
        --line-height-tight: 1.125rem;
        --line-height-normal: 1.375rem;
        --line-height-relaxed: 1.5rem;

        --font-size-icon: 0.875rem;
        --font-size-icon-sm: 0.75rem;
        --font-size-label: 0.6875rem;
        --font-size-button: 0.5625rem;
        --font-size-content: 0.625rem;
    }
}

/* ============================================
   Chainlit Mods
   ============================================ */

body .text-base {
    font-size: var(--font-size-base);
}

body div[data-step-type="user_message"] {
    font-size: var(--font-size-base);
}
body div[data-step-type="user_message"] .leading-7 {
    line-height: var(--line-height-base)
}

body div[data-step-type="assistant_message"] {
    font-size: var(--font-size-base);
}

body div[data-step-type="assistant_message"] .leading-7 {
    line-height: var(--line-height-base)
}

/* ============================================
   Custom Element Wrappers - Remove Card Styling
   ============================================ */

/* Remove card styling from FollowUpOptions custom element wrapper */
.step[data-custom-element-name="FollowUpOptions"] {
    padding: 0 !important;
    margin: 0.5rem 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Remove card styling from ViewOptions custom element wrapper */
.step[data-custom-element-name="ViewOptions"] {
    padding: 0 !important;
    margin: 0.5rem 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Remove card wrapper styling */
.step[data-custom-element-name="FollowUpOptions"] > div,
.step[data-custom-element-name="ViewOptions"] > div {
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Keep the options container minimal but functional */
.followup-options-container {
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Also target the old card class in case of caching */
.followup-options-card {
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    max-width: none !important;
}

/* Hide the options header if it exists */
.followup-options-header {
    display: none !important;
}

/* Make sure buttons remain clickable with proper spacing */
.followup-options-container button {
    pointer-events: auto !important;
    cursor: pointer !important;
}

.followup-options-container button:disabled {
    cursor: not-allowed !important;
}

/* ============================================
   Tool Calls and Thinking Instructions
   ============================================ */

/**
 * NOTE: Frontend hiding CSS has been removed.
 *
 * We now use BACKEND FILTERING instead of frontend CSS hiding.
 * Content is filtered during streaming in Python before being sent
 * to the browser.
 *
 * See: app/chainlit/utils/content_filters.py
 *      app/chainlit/utils/streaming_filtered.py
 */

/* ============================================
   Embedded Context Display
   ============================================ */

/* Container for embedded context cards */
.embedded-context-container {
    margin-bottom: 8px;
}

/* Header with title and clear all button */
.embedded-context-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.embedded-context-title {
    font-size: var(--font-size-label);
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.embedded-context-clear-all {
    font-size: var(--font-size-xs);
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.embedded-context-clear-all:hover {
    color: #ef4444;
    background-color: #fef2f2;
}

/* Cards container */
.embedded-context-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Individual context card */
.embedded-context-card {
    border: 1px solid;
    border-radius: 8px;
    max-width: 300px;
    min-width: 200px;
    overflow: hidden;
    transition: box-shadow 0.15s ease;
}

.embedded-context-card:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Card header */
.embedded-context-card-header {
    display: flex;
    align-items: center;
    gap: 0px;
    padding: 4px 5px;
}

.embedded-context-icon {
    font-size: var(--font-size-icon);
    flex-shrink: 0;
    padding: 0 5px;
}

.embedded-context-label {
    font-size: var(--font-size-label);
    font-weight: 500;
    color: #374151;
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Expand/collapse button */
.embedded-context-expand {
    font-size: var(--font-size-button);
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.embedded-context-expand:hover {
    color: #6b7280;
    background-color: rgba(0, 0, 0, 0.05);
}

/* Remove button */
.embedded-context-remove {
    font-size: var(--font-size-icon-sm);
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
    line-height: 1;
}

.embedded-context-remove:hover {
    color: #ef4444;
    background-color: #fef2f2;
}

/* Card content (expanded) */
.embedded-context-card-content {
    padding: 0 10px 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    font-size: var(--font-size-content);
    color: #4b5563;
}

/* Content fields */
.context-field {
    margin-top: 6px;
}

.context-field strong {
    color: #374151;
}

.context-body,
.context-code {
    margin: 4px 0 0;
    padding: 6px 8px;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
    font-size: var(--font-size-content);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 150px;
    overflow-y: auto;
}

.context-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background-color: #1f2937;
    color: #e5e7eb;
}

/* ============================================
   Embedded Mode Styles (iframe)
   ============================================ */
/* Reduce header padding in embedded mode */
body.embedded-mode header {
    padding: 8px 16px;
}

/* Provider-specific color overrides (applied via inline styles but can be enhanced here) */
.embedded-context-card[data-provider="outlook"] {
    background-color: #eff6ff !important;
    border-color: #bfdbfe !important;
}

.embedded-context-card[data-provider="chrome"] {
    background-color: #f0fdf4 !important;
    border-color: #bbf7d0 !important;
}

.embedded-context-card[data-provider="word"] {
    background-color: #eef2ff !important;
    border-color: #c7d2fe !important;
}

.embedded-context-card[data-provider="vscode"] {
    background-color: #faf5ff !important;
    border-color: #e9d5ff !important;
}

/* ============================================
   Message Embedded Context (in chat history)
   ============================================ */

/* Styled context card in message history */
.message-embedded-context {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid;
    font-size: var(--font-size-label);
    margin: 4px 0;
    background-color: #f9fafb;
    border-color: #e5e7eb;
}

.message-embedded-context-icon {
    font-size: var(--font-size-icon-sm);
}

.message-embedded-context-label {
    font-weight: 500;
    color: #374151;
}

/* Provider-specific colors for message context */
.message-embedded-context.provider-outlook {
    background-color: #eff6ff;
    border-color: #bfdbfe;
}

.message-embedded-context.provider-chrome {
    background-color: #f0fdf4;
    border-color: #bbf7d0;
}

.message-embedded-context.provider-word {
    background-color: #eef2ff;
    border-color: #c7d2fe;
}

.message-embedded-context.provider-vscode {
    background-color: #faf5ff;
    border-color: #e9d5ff;
}

.message-embedded-context.provider-generic {
    background-color: #f9fafb;
    border-color: #e5e7eb;
}

/* Dark mode support (if Chainlit has dark mode) */
@media (prefers-color-scheme: dark) {
    .embedded-context-container {
        border-bottom-color: #374151;
    }

    .embedded-context-title {
        color: #9ca3af;
    }

    .embedded-context-label {
        color: #e5e7eb;
    }

    .embedded-context-card-content {
        color: #d1d5db;
        border-top-color: rgba(255, 255, 255, 0.05);
    }

    .context-field strong {
        color: #e5e7eb;
    }

    .context-body {
        background-color: rgba(255, 255, 255, 0.05);
        color: #d1d5db;
    }
}

/* Light mode button */
:root.light .cl-action-button {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

/* Dark mode button */
:root.dark .cl-action-button {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* Hover effects */
:root.light .cl-action-button:hover {
  background-color: hsl(var(--accent-hover));
}

:root.dark .cl-action-button:hover {
  background-color: hsl(var(--primary-hover));
}

