/* ############################################################################
   © Cogora 2026 - Cogora AI Platform
   style/style.css — Custom styles (extends Bootstrap 5.3)
############################################################################ */

/* ── Base ────────────────────────────────────────────────────────────────── */
html, body {
    height: 100%;
    font-size: 0.9rem;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

/* Home page overrides: allow normal scrolling */
body.home-page,
body.home-page html {
    overflow: auto;
    height: auto;
}

html:has(body.home-page) {
    overflow: auto;
    height: auto;
}

/* ── App layout: full-height flex row below navbar ───────────────────────── */
#appWrapper {
    display: flex;
    height: calc(100vh - 50px); /* subtract navbar height */
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
    width: 270px;
    min-width: 270px;
    background: #1e2a3a;
    color: #cdd8e8;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s ease, min-width 0.25s ease;
}

#sidebar.collapsed {
    width: 0;
    min-width: 0;
}

#sidebarInner {
    width: 270px; /* fixed width so content doesn't reflow during transition */
    overflow-y: auto;
    padding: 16px 12px;
    flex: 1;
}

.sidebar-section {
    margin-bottom: 20px;
}

.sidebar-label {
    color: #7ea8d4;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1.2px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.sidebar-table-name {
    font-size: 11px;
    color: #5b9bd5;
    font-weight: 600;
    word-break: break-all;
}

.col-list {}

.col-item {
    font-size: 12px;
    padding: 4px 0;
    border-bottom: 1px solid #2d3f52;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
}

.col-name {
    color: #e0eaf6;
    word-break: break-all;
}

.col-type {
    color: #7ea8d4;
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.example-btn {
    background: none;
    border: 1px solid #2d3f52;
    color: #8eb8e0;
    font-size: 11px;
    border-radius: 5px;
    padding: 5px 8px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    margin-bottom: 5px;
    line-height: 1.4;
    transition: background 0.15s, color 0.15s;
}

.example-btn:hover {
    background: #2d3f52;
    color: #c9dff5;
    border-color: #3d5570;
}

.examples-heading {
    color: #7ea8d4;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1.2px;
    font-weight: 600;
    margin: 10px 0 5px;
}

/* ── Main area ───────────────────────────────────────────────────────────── */
#mainArea {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f4f6f9;
}

/* ── Chat area ───────────────────────────────────────────────────────────── */
#chatArea {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Prevent flex compression — messages must hold their natural height so the
   chat area scrolls rather than squashing existing bubbles */
.msg-welcome,
.msg-user,
.msg-thinking,
.msg-result {
    flex-shrink: 0;
}

/* Welcome message */
.msg-welcome {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 16px 20px;
    font-size: 13px;
    color: #495057;
    max-width: 620px;
    align-self: flex-start;
}

/* User bubble */
.msg-user {
    align-self: flex-end;
    background: #1a56db;
    color: #fff;
    padding: 10px 16px;
    border-radius: 18px 18px 4px 18px;
    max-width: 65%;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

/* Thinking indicator */
.msg-thinking {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px 18px 18px 18px;
    padding: 10px 16px;
    font-size: 13px;
    color: #6c757d;
    display: flex;
    align-items: center;
}

.dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 4px;
}

.dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6c757d;
    animation: dotBlink 1.2s infinite;
}

.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBlink {
    0%, 80%, 100% { opacity: 0.2; }
    40%           { opacity: 1; }
}

/* Result card */
.msg-result {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px 12px 12px 12px;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
}

.sql-toggle {
    background: #f8f9fa;
    border: none;
    border-bottom: 1px solid #e9ecef;
    color: #495057;
    font-size: 11px;
    padding: 7px 14px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
}

.sql-toggle:hover {
    background: #e9ecef;
}

.sql-block {
    background: #1e2a3a;
    color: #7dd3a8;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    padding: 12px 14px;
    white-space: pre-wrap;
    word-break: break-all;
    border-bottom: 1px solid #dee2e6;
}

.result-meta {
    padding: 7px 14px;
    font-size: 11px;
    color: #6c757d;
    border-bottom: 1px solid #f0f0f0;
}

.chart-wrap {
    padding: 16px 16px 8px;
    border-bottom: 1px solid #dee2e6;
}

.table-wrap {
    overflow-x: auto;
    max-height: 420px;
}

.msg-result table {
    font-size: 12px;
    margin: 0;
    width: 100%;
}

.msg-result thead th {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 1;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid #dee2e6;
    padding: 7px 10px;
}

.th-copy {
    width: 32px;
    text-align: center;
    padding: 4px 6px !important;
    border-bottom: 2px solid #dee2e6;
}

.btn-copy-table {
    background: none;
    border: none;
    color: #198754;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s;
}

.btn-copy-table:hover {
    background: rgba(25, 135, 84, 0.1);
}

.btn-copy-table.copied {
    color: #198754;
}

.msg-result tbody td {
    padding: 6px 10px;
    vertical-align: middle;
}

.error-box {
    padding: 12px 14px;
    color: #842029;
    background: #f8d7da;
    font-size: 12px;
    word-break: break-word;
}

/* ── Input bar ───────────────────────────────────────────────────────────── */
#inputBar {
    background: #fff;
    border-top: 1px solid #dee2e6;
    padding: 12px 24px 10px;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#questionInput {
    flex: 1;
    border: 1px solid #ced4da;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    resize: none;
    font-family: Arial, sans-serif;
    outline: none;
    transition: border-color 0.15s;
    line-height: 1.5;
}

#questionInput:focus {
    border-color: #1a56db;
}

#sendBtn {
    background: #1a56db;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 20px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    height: fit-content;
}

#sendBtn:hover {
    background: #1648c0;
}

#sendBtn:disabled {
    background: #93b4ef;
    cursor: not-allowed;
}

#clearBtn {
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    cursor: pointer;
    height: fit-content;
    transition: background 0.15s;
}

#clearBtn:hover {
    background: #bb2d3b;
}

.input-hint {
    font-size: 11px;
    color: #adb5bd;
    margin-top: 5px;
}

.input-hint kbd {
    font-size: 10px;
    background: #f1f3f5;
    border: 1px solid #ced4da;
    border-radius: 3px;
    padding: 1px 4px;
    color: #495057;
}

/* ── Footer (inside mainArea) ────────────────────────────────────────────── */
footer {
    font-size: 0.8rem;
    background: #fff;
    border-top: 1px solid #dee2e6;
    padding: 8px 24px;
    text-align: center;
    color: #adb5bd;
}

/* ── Scrollbar styling (webkit) ──────────────────────────────────────────── */
::-webkit-scrollbar        { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: #c8d0d8; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9aa5b0; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.card {
    border-radius: 0.5rem;
}

.card .card-body {
    border-radius: 0.5rem;
}

/* ── Home page — system cards ────────────────────────────────────────────── */
.system-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 28px 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
    position: relative;
}

.system-card.accessible:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.10);
    border-color: #1a56db;
    transform: translateY(-2px);
}

.system-card.locked {
    opacity: 0.55;
    cursor: not-allowed;
}

.system-card-icon {
    font-size: 2rem;
    color: #1a56db;
    line-height: 1;
}

.system-card.locked .system-card-icon {
    color: #adb5bd;
}

.system-card-body {
    flex: 1;
}

.system-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 6px;
}

.system-card-desc {
    font-size: 0.825rem;
    color: #6c757d;
    margin: 0;
    line-height: 1.5;
}

.system-card-footer {
    padding-top: 4px;
}

.system-card-lock {
    position: absolute;
    top: 14px;
    right: 16px;
    font-size: 0.9rem;
    color: #adb5bd;
}

/* ── Favourite star button ───────────────────────────────────────────────── */
.fav-btn {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #ced4da;
    cursor: pointer;
    z-index: 2;
    padding: 2px 4px;
    line-height: 1;
    transition: color 0.15s, transform 0.15s;
}

.fav-btn:hover {
    color: #f0ad4e;
    transform: scale(1.15);
}

.fav-btn.active {
    color: #f0ad4e;
}

.system-card.locked .fav-btn {
    color: #ced4da;
}

.system-card.locked .fav-btn.active {
    color: #f0ad4e;
}

.system-card.locked .fav-btn:hover {
    color: #f0ad4e;
}

/* Remove link underline/colour on accessible card links */
.system-card.accessible a {
    color: inherit;
}
