html,
body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

body {
    transition: background-color 0.3s, color 0.3s;
}

.chat-layout {
    display: flex;
    height: 100%;
    height: 100dvh;
    width: 100vw;
}

.message-wrapper {
    min-width: 200px;
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.chat-bubble {
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}


[data-bs-theme="dark"] .chat-bubble-bot,
.theme-dark .chat-bubble-bot {
    border: var(--tblr-border-width) var(--tblr-border-style) var(--tblr-border-color-translucent) !important;
}

.chat-bubble-user {
    border-bottom-right-radius: 2px !important;
}

.chat-bubble-bot {
    border-bottom-left-radius: 2px !important;
}

.typing-dots {
    display: inline-block;
    width: 2ch;
    text-align: left;
}

.typing-dots::after {
    content: ' .';
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: ' .';
    }

    40% {
        content: ' . .';
    }

    60% {
        content: ' . . .';
    }

    80%,
    100% {
        content: ' ';
    }
}

.scrollable-content {
    overflow-y: auto;
    flex-grow: 1;
    scrollbar-width: thin;
}

.cursor-pointer {
    cursor: pointer;
}

.sidebar-left {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--tblr-border-color);
    background-color: var(--tblr-bg-surface-secondary);
}

.hover-effect:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.list-group-item-action:hover {
    color: var(--tblr-primary) !important;
}

.btn-new-chat {
    height: 48px;
    transition: all 0.3s ease;
}

.sidebar-left.collapsed {
    width: 76px;
}

.sidebar-left.collapsed .sidebar-text,
.sidebar-left.collapsed .chat-list-container,
.sidebar-left.collapsed .btn-new-chat span {
    display: none !important;
    opacity: 0;
}

.sidebar-left.collapsed .list-group-item,
.sidebar-left.collapsed .btn-new-chat,
.sidebar-left.collapsed .toggle-container,
.sidebar-left.collapsed .user-area {
    justify-content: center !important;
    padding-left: 0;
    padding-right: 0;
    text-align: center;
}

.sidebar-left.collapsed .btn-new-chat {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    margin: 0 auto;
}

.sidebar-left.collapsed .btn-new-chat i {
    margin: 0 !important;
}

.sidebar-left.collapsed .user-area .d-flex.align-items-center {
    margin: 0 auto;
}

.sidebar-left.collapsed .avatar {
    margin: 0 !important;
}

.dropdown-menu[style*="fixed"] {
    z-index: 10000 !important;
}

.list-group-item {
    position: relative;
}

.group-hover-visible-container:hover .opacity-0-hover {
    opacity: 1 !important;
}

.opacity-0-hover {
    opacity: 0;
    transition: opacity 0.2s;
}

.sidebar-left .list-group-item:has(.dropdown-menu.show) {
    z-index: 10000 !important;
}

#coachSidebar {
    width: 0px;
    min-width: 0px;
    max-width: 700px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    flex-shrink: 0;
    border-left: 1px solid var(--tblr-border-color);
    display: flex;
    flex-direction: column;
    background-color: var(--tblr-bg-surface);
}

#coachToggleBtn {
    transition: transform 0.2s;
}

#coachToggleBtn:hover {
    transform: scale(1.1);
}

.resizer-vertical {
    width: 5px;
    cursor: col-resize;
    background-color: transparent;
    transition: background-color 0.2s;
    z-index: 10;
    flex-shrink: 0;
}

.resizer-vertical:hover,
.resizer-vertical.active {
    background-color: var(--tblr-primary);
}


.message-actions {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    visibility: hidden;
}

.message-row:hover .message-actions {
    opacity: 1;
    visibility: visible;
}

.chat-input-autosize {
    max-height: 140px;
    overflow-y: auto !important;
}

.markdown-body p {
    margin-bottom: 0.75rem;
}

.markdown-body p:last-child {
    margin-bottom: 0;
}

.chat-bubble-bot .markdown-body a {
    color: var(--tblr-info);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.markdown-body pre {
    background: var(--tblr-bg-surface-secondary);
    color: var(--tblr-text-color);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-size: 0.85em;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.markdown-body table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
    font-size: 0.9em;
}

.markdown-body th,
.markdown-body td {
    padding: 0.5rem;
    border: 1px solid var(--tblr-border-color);
}

.markdown-body th {
    background-color: var(--tblr-bg-surface-secondary);
    font-weight: 600;
}

.markdown-body blockquote {
    border-left: 3px solid var(--tblr-primary);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--tblr-muted);
    font-style: italic;
}

.toggle-btn .logo-small-icon {
    display: none;
}

.toggle-btn .menu-icon {
    display: inline-block;
}

.main-logo {
    display: block;
}

.is-collapsed .main-logo {
    display: none;
}

.is-collapsed .toggle-btn .menu-icon {
    display: none;
}

.is-collapsed .toggle-btn .logo-small-icon {
    display: inline-block;
}

.is-collapsed .toggle-btn:hover .logo-small-icon {
    display: none;
}

.is-collapsed .toggle-btn:hover .menu-icon {
    display: inline-block;
}

#sidebar-header.is-collapsed {
    justify-content: center !important;
}

.chat-center-wrapper {
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 768px) {
    .sidebar-left {
        position: fixed;
        top: 0;
        left: 0;
        height: 100dvh;
        z-index: 1050;
        transform: translateX(-100%);
        width: 280px !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar-left.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    }

    #coachSidebar {
        position: fixed !important;
        top: 0;
        right: 0;
        height: 100dvh;
        z-index: 1050;
        box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    }

    .message-wrapper {
        max-width: 95%;
    }

    #coachResizer {
        display: none !important;
    }

    .scrollable-content.p-4 {
        padding: 1rem !important;
    }

    .sidebar-left.mobile-open .menu-icon {
        display: none !important;
    }

    .sidebar-left.mobile-open .close-icon {
        display: inline-block !important;
    }

    .chat-input-autosize {
        padding-top: 8px !important;
        padding-bottom: 8px !important;
        line-height: 1.5 !important;
        min-height: 44px !important;
    }

    .p-3.border-top.bg-body {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
    }

    .chat-hint-text {
        font-size: 9px !important;
        opacity: 0.8;
    }

    .chat-input-autosize {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

.mobile-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 1040;
    display: none;
}

.mobile-backdrop.show {
    display: block;
}

.form-check-input {
  background-color: var(--tblr-body-bg);
}

.sidebar-section a[data-bs-toggle="collapse"] .ti-chevron-down {
    transition: transform 0.3s ease;
}

.sidebar-section a[data-bs-toggle="collapse"][aria-expanded="false"] .ti-chevron-down {
    transform: rotate(-90deg);
}

.bg-coach-content {
    background-color: var(--tblr-light-bg-subtle) !important;
}

[data-bs-theme="dark"] .bg-coach-content,
.theme-dark .bg-coach-content {
    background-color: var(--tblr-dark-bg-subtle) !important;
}
/* Istemi: slate navigation, blue conversation/Admin coaching, teal ethical coaching. */
body {
    --istemi-page: #f4f6fa;
    --istemi-surface: #fff;
    --istemi-soft: #f8fafc;
    --istemi-border: #dce3ec;
    --istemi-text: #243247;
    --istemi-muted: #58687d;
    --istemi-blue: #315db5;
    --istemi-blue-soft: #eef3ff;
    --istemi-teal: #137b72;
    --istemi-teal-soft: #edf8f5;
    --tblr-primary: #315db5;
    --tblr-primary-rgb: 49, 93, 181;
    background: var(--istemi-page);
    color: var(--istemi-text);
}
body[data-bs-theme="dark"] {
    --istemi-page: #111a28;
    --istemi-surface: #182437;
    --istemi-soft: #1d2c40;
    --istemi-border: #34455d;
    --istemi-text: #e7eef8;
    --istemi-muted: #b0bfd3;
    --istemi-blue: #a6c1ff;
    --istemi-blue-soft: #223453;
    --istemi-teal: #8ad8c7;
    --istemi-teal-soft: #193c3b;
}
.chat-layout main { min-height: 0; background: var(--istemi-page); }
.chat-layout .text-muted { color: var(--istemi-muted) !important; }
.chat-layout main > .border-bottom { background: var(--istemi-surface); border-color: var(--istemi-border) !important; }
.chat-layout main > .bg-body { background: var(--istemi-surface) !important; }
.sidebar-left { background: #202e43 !important; border-right: 1px solid #34455d; }
.sidebar-left .text-muted { color: #b9c7da !important; }
.sidebar-left .list-group-item { color: #e7eef8; border-radius: 8px; }
.sidebar-left .list-group-item.active { background: #344b6c !important; color: #fff; }
.sidebar-left .btn-primary { background: #426bbe; border-color: #426bbe; }
#sidebarLeft .main-logo { max-width: 135px; }
.chat-bubble-user.bg-primary { background: #315db5 !important; }
.chat-bubble-bot { background: var(--istemi-surface) !important; color: var(--istemi-text); border: 1px solid var(--istemi-border); }
.chat-layout .form-control { background: var(--istemi-surface); color: var(--istemi-text); border-color: var(--istemi-border); }
.chat-layout .form-control:focus { border-color: #7b9bd6; box-shadow: 0 0 0 3px #315db51a; }
.ethics-column {
    width: 228px; flex: 0 0 228px; height: 100%; overflow-y: auto;
    padding: 24px 18px; background: var(--istemi-surface); border-right: 1px solid var(--istemi-border);
}
.section-eyebrow { display: block; color: var(--istemi-teal); font-size: 10px; font-weight: 700; letter-spacing: 1.4px; margin-bottom: 9px; }
.ethics-heading h2 { font-size: 18px; line-height: 1.35; margin: 0 0 10px; }
.ethics-heading p, .settings-hint { color: var(--istemi-muted); font-size: 12px; line-height: 1.55; }
.coach-switches { grid-column: 1 / -1; }
.coach-switch { display: flex; align-items: center; gap: 9px; border: 1px solid var(--istemi-border); border-left: 3px solid var(--istemi-blue); border-radius: 7px; padding: 10px 8px; margin: 9px 0; cursor: pointer; }
.coach-switch input { width: 17px; height: 17px; flex-shrink: 0; accent-color: #315db5; cursor: pointer; }
.coach-switch strong { display: block; color: var(--istemi-blue); font-size: 12px; }
.coach-switch small { display: block; color: var(--istemi-muted); font-size: 10px; margin-top: 3px; }
.coach-switch-admin:has(input:checked) { background: var(--istemi-blue-soft); }
.coach-switch-ethics { border-left-color: var(--istemi-teal); }
.coach-switch-ethics strong { color: var(--istemi-teal); }
.coach-switch-ethics input { accent-color: #137b72; }
.coach-switch-ethics:has(input:checked) { background: var(--istemi-teal-soft); }
.perspectives-title { font-size: 13px; margin: 22px 0 0; }
.ethics-group { border: 0; margin: 22px 0; padding: 0; min-width: 0; }
.ethics-group legend { float: none; width: auto; margin: 0 0 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--istemi-muted); }
.ethics-choice { display: flex; align-items: flex-start; gap: 10px; border-radius: 7px; padding: 8px; margin: 2px -8px; font-size: 13px; line-height: 1.4; cursor: pointer; }
.ethics-choice:hover, .ethics-choice:has(input:checked) { background: var(--istemi-teal-soft); }
.ethics-choice input { accent-color: #137b72; width: 16px; height: 16px; margin-top: 1px; flex-shrink: 0; cursor: pointer; }
.ethics-save { color: #fff; background: #137b72; border: 1px solid #137b72; border-radius: 7px; }
.ethics-save:hover { color: #fff; background: #0e625b; }
.settings-saved { color: var(--istemi-teal); margin-top: 10px; font-size: 12px; }
.settings-hint { margin: 14px 0 0; }
#coachSidebar { background: var(--istemi-soft); border-color: var(--istemi-border); }
.coaches-header { background: var(--istemi-surface); color: var(--istemi-text); border-color: var(--istemi-border) !important; }
.coaches-header h3 { font-size: 16px; }
.coaches-toolbar { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.coach-card { --coach-accent: var(--istemi-blue); --coach-tint: var(--istemi-blue-soft); background: var(--istemi-surface); border: 1px solid var(--istemi-border); border-top: 3px solid var(--coach-accent); border-radius: 10px; padding: 16px; margin-bottom: 18px; }
.coach-ethics { --coach-accent: var(--istemi-teal); --coach-tint: var(--istemi-teal-soft); }
.coach-card-heading { display: flex; align-items: flex-start; gap: 8px; justify-content: space-between; margin-bottom: 8px; }
.coach-card-heading h3 { font-size: 15px; color: var(--coach-accent); margin: 0; }
.coach-status { background: var(--coach-tint); color: var(--coach-accent); border-radius: 5px; padding: 3px 6px; font-size: 10px; line-height: 1.4; }
.coach-status.status-failed { background: #fce9e9; color: #9f2a32; }
.coach-source { font-size: 11px; color: var(--istemi-muted); margin: 0 0 12px; overflow-wrap: anywhere; }
.coach-source:empty { display: none; }
.coach-pending { display: flex; gap: 10px; align-items: center; padding: 18px 0; color: var(--istemi-muted); font-size: 12px; }
.feedback-item { border-top: 1px solid var(--istemi-border); padding-top: 14px; margin-top: 14px; }
.feedback-item-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.feedback-item h4 { font-size: 13px; font-weight: 700; margin: 0; }
.feedback-item p { font-size: 12px; line-height: 1.65; margin: 0; }
.feedback-suggestion { background: var(--coach-tint); border-radius: 6px; padding: 10px; margin-top: 10px; }
.feedback-suggestion strong { display: block; color: var(--coach-accent); font-size: 11px; margin-bottom: 4px; }
.evaluation-history { color: var(--istemi-muted); font-size: 12px; }
.evaluation-history summary { padding: 8px 0; cursor: pointer; }
.evaluation-history-item { display: block; width: 100%; text-align: left; color: var(--istemi-text); background: var(--istemi-surface); border: 1px solid var(--istemi-border); border-radius: 6px; padding: 8px; margin-top: 6px; font-size: 11px; }
@media (min-width: 769px) and (max-width: 1150px) { .ethics-column { width: 200px; flex-basis: 200px; padding: 20px 14px; } .message-wrapper { max-width: 95%; min-width: 0; } }
@media (max-width: 768px) {
    .chat-layout { flex-direction: column; }
    .ethics-column { width: 100%; height: auto; max-height: 36vh; flex: 0 0 auto; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--istemi-border); }
    .ethics-heading h2 { font-size: 16px; }
    .ethics-heading p { margin-bottom: 4px; }
    .ethics-column form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .ethics-group { margin: 8px 0; }
    .ethics-choice { font-size: 11px; padding: 5px 3px; margin: 2px 0; gap: 5px; }
    .ethics-save, .settings-hint, .settings-saved, .ethics-column .errorlist { grid-column: 1 / -1; }
    .settings-hint { margin: 0; font-size: 11px; }
    #messagesContainer { min-height: 0; }
    .message-actions { opacity: 1; visibility: visible; }
}

/* Keep message tools discoverable for keyboard and touch users. */
.message-actions { opacity: 1; visibility: visible; }
.sidebar-left .list-group-item.active, .sidebar-left .list-group-item.active a { color: #fff !important; }
.sidebar-left .list-group-item.active i { color: #d3e2ff !important; }
.sidebar-left .list-group-item:hover { background: #2b3d58; color: #fff; }

.message-wrapper { max-width: 94%; }
.coach-card .small { line-height: 1.6; }
.coach-controls { margin-top: 14px; }
.coach-controls .settings-hint { margin: 0 0 10px; }
.coach-run { border: 1px solid var(--coach-accent); background: var(--coach-tint); color: var(--coach-accent); }
.coach-run:hover:not(:disabled) { background: var(--coach-accent); color: var(--istemi-surface); }
.coach-run:disabled { opacity: .55; cursor: not-allowed; }
