:root {
    --left-width: 260px;
    --right-width: 360px;
    --gutter: 12px;
    --bg-color: #1a1d23;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;
    background-color: var(--bg-color);
}

/* === Layout Grid === */
.layout {
    display: grid;
    grid-template-columns: var(--left-width) 1fr var(--right-width);
    grid-template-rows: 100%;
    gap: var(--gutter);
    height: 100vh;
    padding: var(--gutter);
    box-sizing: border-box;
}

.left-nav {
    display: flex;
    flex-direction: column;
    background: #0b0f14;
    color: #e5e7eb;
    border: 1px solid #1f2937;
    border-radius: 12px;
}

.right-panel, .chat-area {
    background: #0b0f14;
    color: #e5e7eb;
    border: 1px solid #1f2937;
    border-radius: 12px;
}

/* === Navigation === */
.nav {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    padding: 12px;
    gap: 10px;
}
.company-logo {
    height: 50px; /* sets a consistent vertical size */
    width: auto; /* auto-adjust width to preserve aspect ratio */
    object-fit: contain; /* ensures no cropping or distortion */
    max-width: 200px; /* optional upper limit for very wide logos */
    display: block;
}

.logo {
    margin: 0 0 8px 0;
    font-size: 18px;
    letter-spacing: 2px;
    opacity: .9;
}

/* remove underline from all nav links */
.nav a,
.nav a:hover,
.nav-btn,
.nav-btn:hover {
    text-decoration: none !important;
}
/* unified nav button styling (left nav + toolbar buttons) */
.nav .nav-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: 10px;
    border: 1px solid #2d2f35;
    background: #15171c;
    color: #cbd5e1;
    cursor: pointer;
    text-align: left;
    gap: 8px;
    transition: background-color .2s ease, border-color .2s ease;
}

    .nav .nav-btn:last-child {
        margin-bottom: 8px;
    }

    .nav .nav-btn .oi {
        flex-shrink: 0;
    }

    .nav .nav-btn:hover {
        background: #1f2128;
        border-color: #383a40;
    }

    /* === Sign Out button variant (subtle red accent, white text) === */
    .nav .nav-btn.signout {
        color: #fff; /* same as other nav buttons */
        border: 1px solid rgba(239,68,68,0.35); /* soft red border */
        background: #15171c; /* same base background */
        margin-top: auto; /* stays at bottom */
    }

        .nav .nav-btn.signout:hover {
            border-color: rgba(239,68,68,0.55); /* slightly stronger on hover */
            background: #1f2128; /* same hover background */
            color: #fff; /* keep white text */
        }

    /* Active (selected) nav button */
    .nav .nav-btn.active {
        background: #2a2d35; /* slightly lighter gray than hover */
        border-color: #4b4d55; /* soft highlight border */
        color: #ffffff; /* brighter text for contrast */
        font-weight: 600; /* optional – subtle emphasis */
    }


/* === Right Panel === */
.right-panel {
    overflow: hidden;
    display: block;
    border: none;
    outline: none;
}

.right-grid {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    height: 100%;
    min-height: 0; /* allow children to size correctly */
    gap: 8px;
    border: none ;
    outline: none;
}

/* === Sources / Threads === */
.sources_threads {
    padding: 12px;
    overflow: hidden; /* Important: contain flex behavior */
    min-height: 0; /* Critical: allows flex item to shrink */
    /* Full visual separation + background */
    border: 1px solid #1f2937;
    border-radius: 10px;
    background: #0b0f14;
    /* Flex child: take available space equally */
    flex: 1;
    /* Enable internal scrolling */
    display: flex;
    flex-direction: column;
}

    /* Make the scrollable content fill the panel */
    .sources_threads > * {
        flex: 1;
        overflow: auto;
        min-height: 0;
    }

/* Optional: enhance list styling inside */
.sources_threads-panel ul {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto; /* Ensures list itself scrolls */
}

.sources_threads-panel li {
    padding: 8px;
    position: relative;
    margin-bottom: 8px;
    border-radius: 8px;
}

    .sources_threads-panel li:hover {
        background-color: #1f2128;
        cursor: pointer;
    }


/* === Global Buttons === */
.btn-primary {
    display: block;
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #2d2f35;
    background: #15171c;
    color: #cbd5e1;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
    margin-top: 1.5rem; /* keeps spacing consistent with forms */
    margin-bottom: 1.5rem;
}

    .btn-primary:hover {
        background: #1f2128;
        border-color: #2563eb;
        color: #fff;
    }

/* Optional — subtle secondary and ghost variations for future use */
.btn-secondary {
    display: block;
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #30333a;
    background: #0e1117;
    color: #cbd5e1;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease;
}

    .btn-secondary:hover {
        background: #1a1d24;
        border-color: #475569;
    }

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: #9aa4af;
    font-weight: 500;
    cursor: pointer;
    transition: color .2s ease;
}

    .btn-ghost:hover {
        color: #e5e7eb;
    }




/* === Buttons inside panels === */
.highlighted-btn {
    background-color: #1f2128;
    font-weight: 600;
    border-radius: 10px;
    color: #e5e7eb;
    padding: 8px;
    margin-bottom: 8px;
}

/* Delete / trash buttons */
.delete-btn {
    background: none;
    border: none;
    color: red;
    font-weight: bold;
    cursor: pointer;
    margin-left: 10px;
}

    .delete-btn:hover {
        color: darkred;
    }

/* === Chat Area === */
.chat-area,
.chat {
    display: grid;
    grid-template-rows: 1fr auto;
    height: 100%;
    min-height: 0;
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 12px;
    min-height: 0;
}

.msg-row {
    display: flex;
}

    .msg-row.mine {
        justify-content: flex-end;
        align-items: flex-start;
    }

    .msg-row.theirs {
        justify-content: flex-start;
        align-items: flex-start;
    }

/* USER bubble */
.message.user {
    display: inline-block;
    max-width: 80%;
    background: #1f2937;
    color: #e5e7eb;
    border-radius: 16px;
    padding: 10px 14px;
    line-height: 1.45;
    font-size: 0.95rem;
    border: 1px solid #374151;
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
    text-align: left;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ASSISTANT plain text */
.message-plain {
    max-width: 100%;
    font-size: 0.95rem;
    color: #d1d5db;
    line-height: 1.4;
    white-space: normal;
    word-wrap: break-word;
    padding: 2px 0;
    background: transparent;
    border: none;
    box-shadow: none;
    text-align: left;
}

/* === Chat input === */
.chat-input {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #1f2937;
    background: #0b0f14;
}

/* Textarea prompt */
.prompt {
    border-radius: 10px;
    border: 1px solid #374151;
    background: #0b0f14;
    color: #e5e7eb;
    padding: 10px;
    resize: none;
    overflow-y: auto;
    max-height: 200px;
}

/* Send button */
.send {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid #2563eb;
    background: #1d4ed8;
    color: #fff;
    cursor: pointer;
    transition: background-color .15s ease;
}

    .send:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* Action buttons */
.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 1rem;
    margin-bottom: 12px;
}

    .action-btn .oi-plus {
        font-size: 1em;
    }

    .action-btn:hover {
        background: #1d4ed8;
    }

/* === Table Overview === */
.table-bubble {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 6px 8px;
    margin: 6px 0;
    overflow-x: auto;
}

    .table-bubble table {
        width: 100%;
        border-collapse: collapse;
        font-size: 14px;
        color: #dcdcdc;
    }

    .table-bubble th,
    .table-bubble td {
        padding: 6px 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        text-align: left;
    }

    .table-bubble th {
        background-color: rgba(255, 255, 255, 0.04);
        font-weight: 600;
    }

/* Chart bubble */
.chart-bubble {
    width: 100%;
    max-width: 100%;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0;
}

/* Toolbar */
.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

    .page-toolbar .left,
    .page-toolbar .right {
        display: flex;
        align-items: center;
        gap: 12px;
    }

a {
    color: #e5e7eb;
    text-decoration: none;
}

    a:hover {
        color: #ffffff;
        text-decoration: underline;
    }
/* === Generic Nav Buttons (used outside left nav) === */
.nav-btn {
    display: inline-block;
    background-color: #2563eb;
    color: #fff;
    padding: 8px 14px;
    margin: 6px 4px 6px 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color .2s ease;
}

    .nav-btn:hover {
        background-color: #1d4ed8;
    }

/* === Responsive === */
@media (max-width:1280px) {
    :root {
        --right-width: 300px;
    }
}

@media (max-width:1000px) {
    .layout {
        grid-template-columns: var(--left-width) 1fr;
    }

    .right-panel {
        display: none;
    }
}
