:root {
    --ueh-deep-blue: #16372C;
    --ueh-blue: #638766;
    --ueh-yellow: #D6A429;
    --ueh-orange: #D66F29;
    --ueh-red-orange: #AD4F29;

    --bg-color: #f4f6f8;
    --text-main: #202124;
    --text-muted: #5f6368;
    --border-color: #dadce0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Navbar Styling */
.navbar {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding-top: 10px;
    padding-bottom: 10px;
}

.navbar-brand img {
    height: 45px;
    object-fit: contain;
}

.notebook-title-nav {
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-main);
    border-left: 1px solid var(--border-color);
    padding-left: 16px;
    margin-left: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

/* Nút trên Navbar */
.btn-create-dark {
    background-color: #1f1f1f;
    color: #fff;
    border-radius: 24px;
    padding: 8px 20px;
    font-weight: 500;
    border: none;
    transition: opacity 0.2s;
    font-size: 0.9rem;
}

.btn-create-dark:hover {
    opacity: 0.85;
    color: #fff;
}

.btn-outline-share {
    background-color: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 8px 16px;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-outline-share:hover {
    background-color: #f1f3f4;
}

/* Main Workspace Layout */
.main-workspace {
    flex: 1;
    padding-top: 24px;
    padding-bottom: 40px;
}

/* Sidebar: Nguồn (Sources) */
.sidebar-sources {
    background-color: #ffffff;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 20px;
    height: calc(100vh - 120px);
    min-height: 540px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-add-source {
    width: 100%;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 24px;
    padding: 10px;
    font-weight: 500;
    margin-bottom: 16px;
    transition: all 0.2s;
}

.btn-add-source:hover {
    background-color: #f1f3f4;
}

.source-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.source-list::-webkit-scrollbar {
    width: 6px;
}

.source-list::-webkit-scrollbar-thumb {
    background-color: #cbd0d6;
    border-radius: 10px;
}

.source-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    background-color: #f8f9fa;
}

.source-item:hover {
    background-color: #f1f3f4;
    border-color: var(--border-color);
}

.source-item-info {
    display: flex;
    align-items: center;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.source-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background-color: #e8f0fe;
    color: #1a73e8;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.source-item-info > div:not(.source-item-icon) {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.source-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-item-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
}

.source-item:hover .source-item-delete {
    opacity: 1;
}

.source-item-delete:hover {
    background-color: #fce8e6;
    color: #d93025;
}

/* ── Search box ─────────────────────────────────────────────────────── */
.source-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f3f4;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 6px 12px;
    margin-bottom: 8px;
    transition: border-color .15s, background .15s;
}

.source-search:focus-within {
    border-color: var(--ueh-blue);
    background: #fff;
}

.source-search .fa-magnifying-glass {
    color: #aaa;
    font-size: .75rem;
    flex-shrink: 0;
}

.source-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: .82rem;
    width: 100%;
    color: var(--text-main);
}

.source-search input::placeholder { color: #aaa; }

/* ── Sort button ─────────────────────────────────────────────────────── */
.source-sort-btn {
    border: 1px solid #dadce0;
    background: #f8f9fa;
    color: #5f6368;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.source-sort-btn:hover,
.source-sort-btn[aria-expanded="true"] {
    background: #e8f0fe;
    color: var(--ueh-deep-blue);
    border-color: #c6d4f0;
}

/* ── Status bar ─────────────────────────────────────────────────────── */
.source-status-bar {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
    margin-top: 4px;
}

.source-status-bar .lbl {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.source-status-bar .cnt {
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-main);
}

.source-sync-bar {
    height: 4px;
    border-radius: 4px;
    background: #eee;
    overflow: hidden;
    margin-bottom: 4px;
}

.source-sync-bar .progress-bar {
    height: 100%;
    transition: width .4s ease, background-color .4s;
}

.source-status-hint {
    font-size: .7rem;
    color: var(--text-muted);
}

.file-progress {
    font-size: .68rem;
    line-height: 1.2;
    width: 100%;
}

.file-progress-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    color: #664d03;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-progress-label .fa-spinner {
    font-size: .63rem;
    flex-shrink: 0;
}

.file-progress-bar {
    height: 3px;
    background: rgba(0, 0, 0, .1);
    border-radius: 2px;
    overflow: hidden;
    width: 100%;
}

.file-progress-bar .progress-bar {
    background: #005f69;
    border-radius: 2px;
    min-width: 6px;
    transition: width .6s ease;
}

.btn-retry-file {
    background: transparent;
    border: 1px solid #dadce0;
    color: #005f69;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .6rem;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.btn-retry-file:hover {
    background-color: #e6f4ea;
    border-color: #005f69;
}

.btn-retry-file:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Chat Area */
.chat-container {
    background-color: #ffffff;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    height: calc(100vh - 120px);
    min-height: 540px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: #cbd0d6;
    border-radius: 10px;
}

.welcome-emoji {
    font-size: 3rem;
    margin-bottom: 16px;
}

.welcome-title {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-main);
}

.welcome-subtitle {
    color: var(--text-muted);
    margin: 0 auto 32px;
    line-height: 1.6;
    max-width: 600px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    justify-content: center;
}

.chip {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.2s;
}

.chip:hover {
    background-color: #f8f9fa;
}

/* Input Chat */
.chat-input-wrapper {
    padding: 20px 24px;
    background-color: #ffffff;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

.chat-input-box {
    display: flex;
    align-items: center;
    background-color: #f1f3f4;
    border-radius: 30px;
    padding: 8px 16px 8px 24px;
    border: 1px solid transparent;
    transition: box-shadow 0.2s, background 0.2s;
}

.chat-input-box:focus-within {
    background-color: #ffffff;
    border-color: var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.chat-input-box input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 1rem;
    padding: 8px 0;
    color: var(--text-main);
}

.chat-send-btn {
    background-color: #e8eaed;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 12px;
}

.chat-input-box:focus-within .chat-send-btn {
    background-color: var(--ueh-deep-blue);
    color: #ffffff;
}

/* --- DIALOG / MODAL CUSTOM STYLING --- */
.modal-content {
    border-radius: 16px;
}

.nav-tabs-custom {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.nav-tabs-custom .nav-link {
    border: none;
    color: var(--text-muted);
    font-weight: 500;
    padding: 12px 16px;
    border-bottom: 2px solid transparent;
}

.nav-tabs-custom .nav-link.active {
    color: var(--ueh-orange);
    border-bottom-color: var(--ueh-orange);
    background: transparent;
}

/* Drag & Drop Area */
.drag-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    background-color: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
}

.drag-drop-zone.dragover {
    border-color: var(--ueh-orange);
    background-color: rgba(214, 111, 41, 0.05);
}

.share-option-box {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

/* Footer */
.ueh-footer {
    background-color: var(--ueh-deep-blue);
    color: #ffffff;
    padding: 40px 0 20px;
    font-size: 0.9rem;
}

.ueh-footer a {
    color: #ffffff;
    text-decoration: none;
    transition: color 0.2s;
}

.ueh-footer a:hover {
    color: var(--ueh-yellow);
}

.copyright-list,
.footer_link {
    list-style-type: none;
    padding-left: 0;
    margin-bottom: 0;
}

.ueh-footer-title {
    margin-bottom: 12px;
    line-height: 1.5;
}

.ueh_logo img {
    height: 50px;
    margin-bottom: 15px;
    filter: brightness(0) invert(1);
}

/* ── Chat Messages ──────────────────────────────────────────── */
.msg {
    display: flex;
    margin-bottom: 20px;
    gap: 12px;
    max-width: 100%;
}

.msg-user {
    flex-direction: column;
    align-items: flex-end;
}

.msg-assistant {
    flex-direction: row;
    align-items: flex-start;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #f1f3f4;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.msg-body {
    flex: 1;
    min-width: 0;
}

.msg-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.65;
    word-break: break-word;
}

.msg-user .msg-bubble {
    background-color: var(--ueh-deep-blue);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    max-width: 80%;
    margin-left: auto;
}

.msg-assistant .msg-bubble {
    background-color: #f1f3f4;
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

/* Markdown inside assistant bubble */
.msg-bubble.markdown-body {
    padding: 12px 16px;
    background-color: #f1f3f4;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

.msg-bubble.markdown-body > *:first-child { margin-top: 0; }
.msg-bubble.markdown-body > *:last-child  { margin-bottom: 0; }

.msg-bubble.markdown-body h2,
.msg-bubble.markdown-body h3,
.msg-bubble.markdown-body h4 {
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.4rem;
}

.msg-bubble.markdown-body h2 { font-size: 1.1rem; }
.msg-bubble.markdown-body h3 { font-size: 1rem; }

.msg-bubble.markdown-body p { margin-bottom: 0.55rem; }

.msg-bubble.markdown-body ul,
.msg-bubble.markdown-body ol {
    padding-left: 1.25rem;
    margin-bottom: 0.55rem;
}

.msg-bubble.markdown-body li { margin-bottom: 0.2rem; }

.msg-bubble.markdown-body code {
    background-color: rgba(0, 0, 0, 0.07);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: 'Fira Code', 'Consolas', monospace;
}

.msg-bubble.markdown-body pre {
    background-color: #1e1e1e;
    color: #d4d4d4;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 0.55rem;
}

.msg-bubble.markdown-body pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: 0.85rem;
}

.msg-bubble.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-bottom: 0.55rem;
}

.msg-bubble.markdown-body th,
.msg-bubble.markdown-body td {
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    text-align: left;
}

.msg-bubble.markdown-body th {
    background-color: #e8eaed;
    font-weight: 600;
}

.msg-bubble.markdown-body blockquote {
    border-left: 3px solid var(--ueh-blue);
    padding-left: 1rem;
    color: var(--text-muted);
    margin: 0.5rem 0;
}

/* Timestamps — div block, nằm trong bubble, góc phải dưới cùng */
.msg-time {
    font-size: 0.7rem;
    text-align: right;
    margin-top: 4px;
    line-height: 1;
    user-select: none;
}

.msg-user .msg-bubble .msg-time {
    color: rgba(255, 255, 255, 0.55);
}

.msg-assistant .msg-bubble .msg-time-end {
    color: rgba(0, 0, 0, 0.28);
}

/* Citations */
.msg-citations {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.citation-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    width: 100%;
    margin-bottom: 2px;
}

.citation-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background-color: #e8f0fe;
    color: #1a73e8;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 0.8rem;
    text-decoration: none;
    border: 1px solid #c5d8f9;
    transition: background 0.2s;
    max-width: 220px;
    overflow: hidden;
}

.citation-chip .chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.citation-chip:hover {
    background-color: #d2e3fc;
    color: #1a73e8;
}

.citation-snippet-tip {
    position: fixed;
    z-index: 9999;
    max-width: 320px;
    background: #fff;
    border: 1px solid #dadce0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: .78rem;
    color: #3c4043;
    line-height: 1.5;
    box-shadow: 0 4px 16px rgba(0,0,0,.14);
    white-space: pre-wrap;
    word-break: break-word;
    pointer-events: none;
}

/* Action buttons */
.msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.msg-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.msg-action-btn:hover {
    background-color: #f1f3f4;
    color: var(--text-main);
}

.like-btn.active {
    color: #1e8a44;
    background-color: #e6f4ea;
}

.dislike-btn.active {
    color: #c5221f;
    background-color: #fce8e6;
}

/* Typing indicator */
.typing-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--text-muted);
    border-radius: 50%;
    margin: 0 2px;
    animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0);   opacity: 0.5; }
    30%            { transform: translateY(-6px); opacity: 1;   }
}

/* Textarea in chat input */
.chat-input-box textarea {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 1rem;
    padding: 8px 0;
    color: var(--text-main);
    resize: none;
    font-family: inherit;
    overflow-y: auto;
    max-height: 160px;
    line-height: 1.5;
}

.chat-send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar-sources {
        height: auto;
        min-height: unset;
        margin-bottom: 24px;
    }

    .sidebar-sources .source-list {
        max-height: 320px;
        overflow-y: auto;
    }

    .chat-container {
        height: 600px;
    }

    .notebook-title-nav {
        display: none;
    }
}

.dropdown-item:hover,
.dropdown-item:focus,
.dropdown-item:active,
.dropdown-item.active {
    background-color: #f26f33 !important;
    color: #fff !important;
}

.dropdown-item:hover i,
.dropdown-item:focus i,
.dropdown-item:active i,
.dropdown-item.active i {
    color: #fff !important;
}