/* Brand Variables */
:root {
    --navy: #112D61;
    --coral: #FF5A5F;
    --teal: #B1EDE8;
    --teal-dark: #345C72;
    --peach: #FF9E7A;
    --white: #ffffff;
    --light-bg: #f8f9fc;
    --text-dark: #1a1a2e;
    --text-muted: #6c757d;
    --topbar-height: 56px;
    --tagline-blue: #4A7C96;
}

/* Base */
html, body {
    font-family: 'Heebo', Arial, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-dark);
    height: 100%;
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--navy);
}

a, .btn-link {
    color: var(--coral);
}

/* Top Bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background-color: var(--white);
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 101;
    box-sizing: border-box;
}

.avatar-btn {
    cursor: pointer;
    line-height: 0;
}

.avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(0,0,0,0.08);
}

.avatar-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    border: 2px solid rgba(0,0,0,0.08);
    user-select: none;
}

.avatar-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 0.4rem 0;
    z-index: 200;
}

.avatar-dropdown-menu.avatar-menu-open {
    display: block;
}

.avatar-dropdown-header {
    padding: 0.35rem 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.avatar-dropdown-item {
    display: block;
    padding: 0.45rem 1rem;
    font-size: 0.83rem;
    color: var(--text-dark);
    text-decoration: none;
    transition: background 0.15s;
}

.avatar-dropdown-item:hover {
    background: var(--light-bg);
    color: var(--text-dark);
}

.avatar-dropdown-item.text-danger:hover {
    background: #fff5f5;
}

.top-bar-greeting {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--coral);
    letter-spacing: 0.01em;
}

/* Page Body */
.page-body {
    margin-top: var(--topbar-height);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--navy);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: width 0.3s ease;
    overflow-y: auto;
}

.sidebar.mini {
    width: 64px;
    overflow: hidden;
}

/* Main */
main {
    margin-left: 260px;
    transition: margin-left 0.3s ease;
}

main.sidebar-mini {
    margin-left: 64px;
}

.nav-icon {
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

.sidebar.mini .nav-label {
    display: none;
}

.sidebar.mini .navbar-brand-custom {
    padding: 1rem 0.5rem;
    display: flex;
    justify-content: center;
}

.sidebar.mini .navbar-brand-custom img {
    margin-bottom: 0;
}

.sidebar.mini .nav-link-custom {
    display: flex;
    justify-content: center;
    padding: 0.6rem 0;
    margin: 0.2rem 0.5rem;
}

/* Content */
.content {
    padding: 2rem;
}

/* Hamburger */
.hamburger-btn {
    background: none;
    border: none;
    color: var(--navy);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
}

.hamburger-btn:hover {
    color: var(--coral);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
}

/* Buttons */
.btn-primary {
    background-color: var(--coral);
    border-color: var(--coral);
    color: var(--white);
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background-color: #e04e53;
    border-color: #e04e53;
}

.btn-primary:disabled {
    background-color: var(--peach);
    border-color: var(--peach);
}

.btn:focus, .btn:active.focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 90, 95, 0.25);
}

/* Toggle Switch */
.form-check-input:checked {
    background-color: var(--coral);
    border-color: var(--coral);
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(17, 45, 97, 0.08);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: var(--navy);
    color: var(--white);
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    border-radius: 10px 10px 0 0 !important;
    padding: 0.75rem 1.25rem;
}

.card-body {
    padding: 1.5rem;
}

.thread-card:hover {
    box-shadow: 0 4px 12px rgba(17, 45, 97, 0.15);
    transition: box-shadow 0.2s ease;
}

/* Forms */
.form-control {
    border-radius: 6px;
    border: 1px solid #d0d7e3;
    font-family: 'Heebo', sans-serif;
}

.form-control:focus {
    border-color: var(--coral);
}

.form-label {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--navy);
}

/* Nav */
.navbar-brand-custom {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    color: var(--white) !important;
    font-size: 1.1rem;
    padding: 1.5rem 1rem 1rem 1rem;
    display: block;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.5rem;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.75rem 1.75rem 0.25rem;
    margin-top: 0.25rem;
}

.nav-link-custom {
    color: rgba(255, 255, 255, 0.75) !important;
    font-family: 'Heebo', sans-serif;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    margin: 0.2rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.nav-link-custom:hover, .nav-link-custom.active {
    background-color: rgba(255, 90, 95, 0.2);
    color: var(--white) !important;
}

.nav-accent {
    width: 3px;
    background-color: var(--coral);
    border-radius: 2px;
    height: 20px;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

/* Markdown output */
.markdown-output h1, .markdown-output h2, .markdown-output h3 {
    margin-top: 1rem;
    color: var(--navy);
}

.markdown-output p {
    line-height: 1.7;
}

.markdown-output ul, .markdown-output ol {
    padding-left: 1.5rem;
}

.markdown-output table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.markdown-output th {
    background-color: var(--navy);
    color: var(--white);
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    padding: 0.6rem 0.75rem;
    text-align: left;
}

.markdown-output td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.markdown-output tr:hover {
    background-color: rgba(177, 237, 232, 0.15);
}

/* Blazor error */
.blazor-error-boundary {
    background-color: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* Validation */
.validation.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid var(--coral);
}

.validation-message {
    color: var(--coral);
}

/* Thinking Indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(17, 45, 97, 0.08);
    animation: fadeIn 0.3s ease;
}

.thinking-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--coral);
    animation: bounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.thinking-text {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--navy);
    font-size: 0.95rem;
    animation: fadeSwap 5s ease-in-out infinite;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSwap {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Chat */
.chat-history {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chat-message {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.chat-user {
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
}

.chat-avatar-user {
    background-color: var(--coral);
    color: var(--white);
}

.chat-avatar-assistant img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-bubble {
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    line-height: 1.6;
}

.chat-bubble-user {
    background-color: var(--navy);
    color: var(--white);
    border-top-right-radius: 2px;
}

.chat-bubble-assistant {
    background-color: var(--white);
    color: var(--text-dark);
    box-shadow: 0 2px 4px rgba(17, 45, 97, 0.08);
    border-top-left-radius: 2px;
}

.response-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.response-tagline {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.tagline-blue {
    color: var(--tagline-blue);
}

.tagline-coral {
    color: var(--coral);
}

.response-disclaimer {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0;
    line-height: 1.4;
}

.chat-input-bar {
    background-color: var(--white);
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(17, 45, 97, 0.08);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.chat-input-bar textarea {
    border: 1px solid #e0e0e0;
    resize: none;
}

/* Auto-resize textarea */
.auto-resize {
    overflow: hidden;
    resize: none;
    min-height: 2.5rem;
}

/* Document search result rows */
.doc-search-result:hover {
    background-color: var(--light-bg);
}

.scroll-to-bottom-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 50;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 12px rgba(17, 45, 97, 0.2);
}

    /* Mobile */
    @media (max-width: 768px) {
        .sidebar {
            transform: translateX(-260px);
        }

            .sidebar.open {
                transform: translateX(0);
            }

        main {
            margin-left: 0 !important;
        }

        .sidebar-overlay.visible {
            display: block;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 99;
        }
    }
