/* AiDataFusion custom styles */

/* ── App sidebar ─────────────────────────────── */
#app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background: #f0f4f8;
    border-right: 1px solid #dce3eb;
    display: flex;
    flex-direction: column;
    z-index: 1050;
}

.app-sidebar-brand {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dce3eb;
}

.app-sidebar-brand a {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a365d;
    text-decoration: none;
}

.app-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.app-sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.app-sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1.25rem;
    color: #3b506c;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.app-sidebar-nav li a:hover {
    background: rgba(0, 84, 166, 0.08);
    color: #0054a6;
}

.app-sidebar-nav li a.active,
.app-sidebar-nav li a[aria-current="page"] {
    background: rgba(0, 84, 166, 0.12);
    color: #0054a6;
    font-weight: 600;
    border-left-color: #0054a6;
}

.app-sidebar-nav li a i {
    font-size: 1.2rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

/* ── Mobile sidebar ──────────────────────────── */
@media (max-width: 991.98px) {
    #app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    #app-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    #app-sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1040;
    }

    #app-sidebar-overlay.open {
        display: block;
    }

    /* No sidebar offset on mobile */
    .adf-main {
        margin-left: 0 !important;
    }
}

@media (min-width: 992px) {
    #app-sidebar-toggle {
        display: none !important;
    }

    #app-sidebar-overlay {
        display: none !important;
    }

    .adf-main {
        margin-left: 240px;
    }
}

/* ── App header (fixed bar) ──────────────────── */
.app-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 240px;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #f0f4f8;
    border-bottom: 1px solid #dce3eb;
    height: 48px;
}

@media (max-width: 991.98px) {
    .app-header {
        left: 0;
    }
}

.app-header-title {
    font-weight: 700;
    font-size: 1rem;
    color: #1a365d;
}

/* ── Page layout (custom classes, no Tabler conflicts) ── */
.adf-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding-top: 48px;
}

.adf-body {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.adf-content {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    overflow: auto;
    min-height: 0;
    padding: 1rem;
}

/* On the chat page: no padding, no scroll on content wrapper */
.adf-content:has(.chat-page-container) {
    padding: 0;
    overflow: hidden;
}

/* ── Chat page layout ───────────────────────── */
.chat-page-container {
    flex: 1 1 0%;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

.chat-page-container #conv-sidebar {
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-area {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.chat-area #chat-messages {
    flex: 1 1 0%;
    overflow-y: auto;
    min-height: 0;
}

.chat-area .chat-input-bar {
    flex-shrink: 0;
}

/* ── Chat messages ───────────────────────────── */
.chat-message-assistant .message-content table {
    width: 100%;
    margin: 0.5rem 0;
    border-collapse: collapse;
}

.chat-message-assistant .message-content th,
.chat-message-assistant .message-content td {
    border: 1px solid var(--tblr-border-color);
    padding: 0.35rem 0.6rem;
    font-size: 0.875rem;
}

.chat-message-assistant .message-content th {
    background-color: var(--tblr-bg-surface-secondary);
    font-weight: 600;
}

.chat-message-assistant .message-content pre {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 0.375rem;
    padding: 0.75rem;
    overflow-x: auto;
    font-size: 0.8125rem;
}

.chat-message-assistant .message-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.chat-message-assistant .message-content code {
    font-size: 0.8125rem;
    background: #f1f5f9;
    color: #0f172a;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
}

.chat-message-assistant .message-content p:last-child {
    margin-bottom: 0;
}

.chat-message-user .message-content {
    white-space: pre-wrap;
}

/* ── Conversation sidebar (chat page) ────────── */
#conv-sidebar {
    background: #fbfbfc;
}

.conv-item {
    transition: background-color 0.15s;
}

.conv-item:hover {
    background-color: rgba(0, 84, 166, 0.05);
}

.conv-item.active {
    background-color: rgba(0, 84, 166, 0.1);
    border-left: 3px solid #0054a6 !important;
}

.conv-item.archived {
    opacity: 0.65;
}

/* ── Thinking indicator ──────────────────────── */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6c7a91;
    font-size: 0.8125rem;
    padding: 0.25rem 0;
}

.thinking-dots {
    display: inline-flex;
    gap: 3px;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6c7a91;
    animation: thinking-bounce 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes thinking-bounce {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Chat conversation sidebar toggle (mobile) ─ */
#sidebar-toggle {
    display: none;
}

#sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    #conv-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1050;
        width: 280px !important;
        min-width: 280px !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    #conv-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    }

    #sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1040;
    }

    #sidebar-overlay.open {
        display: block;
    }

    #sidebar-toggle {
        display: inline-flex;
    }
}

/* ── Typing indicator (legacy) ───────────────── */
.chat-bubble .spinner-border {
    width: 1rem;
    height: 1rem;
}
