/* ...existing CSS code from the <style> tag in the HTML file... */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: white;
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 60px);
    /* height is now handled by flex parent */
}

.sidebar {
    width: 280px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.sidebar-new-chat {
    padding: 16px;
}

.sidebar button {
    width: 100%;
    background: #42a5f5;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 5px 0;
    /* Updated padding */
    font-size: 14px;
    /* Adjusted font size */
    cursor: pointer;
    margin-bottom: 16px;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Orion Header Styles */
.orion-header {
    background: #000000;
    color: #ffffff;
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.hamburger-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
}

.orion-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-symbol {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -2px;
}

.logo-text {
    font-size: 14px;
    line-height: 1.1;
    font-weight: 500;
}

.header-divider {
    height: 32px;
    width: 1px;
    background: #333;
    margin: 0 20px;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}

/* Brand Section */
.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-info {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.1;
    color: #ffffff;
    /* Changed to white */
}

.brand-subtitle {
    font-size: 11px;
    color: #aaa;
    /* Changed to light gray */
    letter-spacing: 0.5px;
}

.badge-prod {
    background: #333;
    /* Darker bg */
    border: 1px solid #444;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    /* White text */
}

/* Mode Switch */
.mode-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-switch {
    display: flex;
    background: #222;
    /* Dark bg */
    border: 1px solid #333;
    border-radius: 6px;
    padding: 2px;
}

.mode-btn {
    background: none;
    border: none;
    padding: 4px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #aaa;
    /* Light gray */
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: #444;
    /* Active dark state */
    color: white;
}

/* ...existing mode-btn styles... */

.mode-btn:hover:not(.active) {
    background: #333;
}

/* Refresh Button Styles */
.refresh-btn {
    background: none;
    border: none;
    color: #aaa;
    /* Light gray */
    padding: 6px;
    /* Reduced horizontal padding */
    width: 32px;
    /* Fixed square size */
    height: 32px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 50%;
    /* Circular */
    margin-left: 0;
    /* Gap handles spacing */
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-btn:hover {
    background: #333;
    color: #fff;
}

.refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
    /* disable hover animation if any */
}

/* Animation for the icon inside */
.refresh-btn i {
    display: block;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}



/* Header Controls */
.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-items {
    display: flex;
    gap: 16px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #aaa;
    /* Light gray */
    font-weight: 500;
}

.status-item i {
    font-size: 14px;
    color: #888;
}

.acting-badge {
    background: #1a2733;
    /* Dark blueish bg */
    color: #4da6ff;
    /* Lighter blue */
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #2a4055;
}

.control-icons {
    display: flex;
    gap: 8px;
    border-left: 1px solid #333;
    /* Dark border */
    padding-left: 16px;
}

.icon-btn {
    background: none;
    border: none;
    color: #aaa;
    /* Light gray */
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.icon-btn:hover {
    background: #333;
    color: #fff;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 1px solid #333;
    /* Dark border */
    padding-left: 16px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: #333;
    /* Dark bg */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.user-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.1;
}

.user-role {
    font-size: 11px;
    color: #aaa;
}

.user-role:first-child {
    font-weight: 600;
    color: #fff;
}




#newThread:disabled {
    background: #f5f7fb;
    color: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    border-color: #000000;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 30px;
    background-color: white;
    font-size: 13px;
    scroll-behavior: smooth;
}

#messagesWrapper {
    /* width: 100%; */
    max-width: 1200px;
    margin: 0 auto;
}

.messages-wrapper {
    min-width: 500px;
    max-width: 1200px;
}

.message {
    display: flex;
    margin-bottom: 20px;
    align-items: flex-start;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0590d7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    margin-right: 12px;
    flex-shrink: 0;
    font-size: 14px;
}

.message.incoming .avatar {
    background: url('/asset/Cpu.svg') center center no-repeat;
    background-size: 24px 24px;
}

.message.outgoing {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.message.outgoing .avatar {
    margin-right: 0;
    margin-left: 12px;
    background: #fff;
    /* Set background to white */
    color: #0590d7;
    /* Set icon fill color */
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.message.outgoing .bubble {
    background: #f5f5f5;
    color: #000000;
}

.message-content {
    max-width: 70%;
}

.bubble {
    padding: 10px;
    border-radius: 8px;
    position: relative;
    word-break: break-word;
    font-size: 13px;
}

.message.outgoing .bubble {
    background: #f5f5f5;
    color: #000000;
}

.bubble p {
    margin: 0 0 10px 0;
}

.bubble p:last-child {
    margin-bottom: 0;
}

.bubble pre {
    background: #f0f0f0;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
}

.bubble code {
    background: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.bubble pre code {
    padding: 0;
    background: transparent;
}

.bubble ul,
.bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.bubble blockquote {
    border-left: 4px solid #ccc;
    padding-left: 8px;
    margin-left: 0;
    color: #666;
}

.bubble table {
    border-collapse: collapse;
    margin: 8px 0;
}

.bubble th,
.bubble td {
    border: 1px solid #ddd;
    padding: 6px 10px;
}

.bubble th {
    background: #f0f0f0;
}

/* Modern Input Area Styling */
.chat-input {
    padding: 20px 30px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.input-wrapper {
    width: 100%;
    min-width: unset;
    max-width: 1200px;
    display: flex;
    background: #f5f7fb;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    padding: 8px 16px;
    transition: all 0.3s ease;
    flex-direction: column;
}

.input-wrapper:focus-within {
    border-color: #0590d7;
    background: white;
    box-shadow: 0 0 0 3px rgba(5, 144, 215, 0.1);
}

#input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 15px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    resize: none;
    min-height: 24px;
    max-height: 120px;
    line-height: 1.5;
}

#input::placeholder {
    color: #9ca3af;
}

.input-icon-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.input-icon-btn:hover {
    color: #0590d7;
    background: rgba(5, 144, 215, 0.1);
}

.input-icon-btn.recording {
    color: #ef4444;
    animation: pulse 1.5s infinite;
}

#send {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: #0590d7;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(5, 144, 215, 0.3);
    flex-shrink: 0;
}

#send:hover {
    background: #047ab8;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(5, 144, 215, 0.4);
}

#send:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

#loading {
    display: none;
    text-align: center;
    padding: 10px;
}

.loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-radius: 50%;
    border-top: 3px solid #667eea;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}


#threadLoadBlock {
    padding: 10px 30px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: none;
    align-items: center;
    gap: 12px;
}

#threadIdInput {
    flex: 1;
    padding: 5px 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    font-size: 12px;
}

#loadThreadBtn {
    background: #0590d7;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 5px 24px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

#loadThreadBtn:hover {
    background: #047ab8;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(5, 144, 215, 0.3);
}

.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.form-check-input {
    width: 35px;
    height: 20px;
    cursor: pointer;
    border: 1px solid #dee2e6;
}

.form-check-input:checked {
    background-color: #0590d7;
    border-color: #0590d7;
}

.form-check-input:focus {
    border-color: #0590d7;
    box-shadow: 0 0 0 0.2rem rgba(5, 144, 215, 0.25);
}

.toggle-label {
    font-size: 12px;
    color: #000000;
    font-weight: 500;
    user-select: none;
}

#manualRefresh {
    background: #f7f9fb;
    border: none;
    color: #000000;
    padding: 5px 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: none;
    width: 35px;
    height: 35px;
    line-height: 1;
    border-radius: 50%;
}

#manualRefresh:hover {
    background-color: #c6c7c8 !important;
}

.dropdown-toggle {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    padding: 0;
}

#manualRefresh:hover {
    background: #f5f7fb;
}

#manualRefresh:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-blk {
    display: flex;
    justify-content: space-between;
}

.dropdown-menu-end li {
    font-size: 12px;
}

.thread-list-item {
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    /* Stack title and timestamp vertically */
    align-items: flex-start;
    /* Align content to the left */
}

.thread-list-item:hover {
    background: #f5f7fb;
    border-color: #0590d7;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(5, 144, 215, 0.2);
}

.thread-list-item .thread-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    /* Ensure the title stays on one line */
    overflow: hidden;
    /* Hide overflowing text */
    text-overflow: ellipsis;
    /* Add ellipsis for overflowing text */
    width: 100%;
    /* Ensure ellipsis works within the container */
}

.thread-list-item .thread-meta {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    /* Add spacing between title and timestamp */
}

.thread-list-item.active {
    background: #e0f7fa;
    border-left: 3px solid #0078d4;
}

.step-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(5, 144, 215, 0.07);
    transition: box-shadow 0.2s;
    overflow: hidden;
}

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 12px;
    background: #f5f7fb;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #e5e7eb;
}

.step-header .collapse-icon {
    font-size: 18px;
    color: #0590d7;
    margin-left: 8px;
    transition: transform 0.2s;
}

/* Add these after .step-header */
.step-header.status-in-progress {
    background: #fffbe6;
    /* Light yellow */
}

.step-header.status-completed {
    background: #e6ffed;
    /* Light green */
}

.step-header.status-failed {
    background: #ffeaea;
    /* Light red */
}

.step-card.collapsed .step-details {
    display: none;
}

.step-details {
    padding: 12px 16px;
    font-size: 12px;
    color: #333;
}

.step-row {
    margin-bottom: 8px;
    white-space: normal;
}

.step-label {
    font-weight: 500;
    color: #0590d7;
    white-space: nowrap;
    margin-right: 0;
    /* Remove extra margin to keep label and value close */
}

.step-value {
    color: #222;
    word-break: break-word;
    flex: 1 1 auto;
}

@media (max-width: 768px) {
    .chat-container {
        margin: 0;
        height: 100vh;
        border-radius: 0;
    }

    .message-content {
        max-width: 80%;
    }

    .logo-section h1 {
        font-size: 24px;
    }

    .chat-input {
        padding: 15px 20px;
    }

    .input-wrapper {
        width: 90%;
        min-width: unset;
    }

    .messages-wrapper {
        width: 100%;
        min-width: unset;
    }

    #send {
        width: 30px;
        height: 30px;
    }
}

@media (min-width: 1366px) {

    .input-wrapper,
    .messages-wrapper {
        width: 80%;
    }
}

/* Remove down arrow from dropdown-toggle */
.dropdown-toggle::after {
    display: none;
}

.message.outgoing .message-time {
    text-align: right;
    display: block;
    /* Ensure it takes up its own line */
    margin-top: 4px;
    /* Optional: Add spacing above the time */
}

.agent-steps {
    width: 400px;
    background: #f9f9f9;
    border-left: 1px solid #ddd;
    padding: 16px;
    overflow-y: auto;
}

.agent-steps h5 {
    font-size: 16px;
    margin-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 15px;
}

.agent-steps ul {
    list-style: none;
    padding: 0;
}

.agent-steps ul li {
    margin-bottom: 8px;
    font-size: 14px;
    color: #333;
}

.chat-welcome-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 50vh;
    text-align: left;
    opacity: 0.9;
}

.welcome-row {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 12px;
}

.welcome-logo img {
    display: block;
}

.welcome-title h2 {
    margin: 0;
    font-size: 2rem;
    font-weight: 600;
}

.welcome-desc {
    margin-top: 8px;
    text-align: left;
}

.chat-history-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 50vh;
    gap: 8px;
}

#chatHistory {
    height: 90vh;
    padding: 0 10px;
    overflow-y: auto;
}

.chat-history-loader .dot,
.bouncing-dots .dot {
    width: 12px;
    height: 12px;
    background: #0590d7;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1s infinite alternate;
}

.chat-history-loader .dot:nth-child(2),
.bouncing-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-history-loader .dot:nth-child(3),
.bouncing-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

.bouncing-dots .dot {
    width: 8px;
    height: 8px;
}

.bouncing-dots {
    margin-left: 10px;
    position: relative;
    top: 5px;
    display: none;
}

@keyframes bounce {
    to {
        transform: translateY(-16px);
        opacity: 0.6;
    }
}


/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0;
    padding: 12px 16px;
    gap: 0;
    background: #fff;
}

.sidebar-tab {
    background: none;
    border: none;
    color: #555;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 4px;
    cursor: pointer;
    transition: color 0.2s, border-bottom 0.2s;
    outline: none;
    position: relative;
    white-space: nowrap;
}

.sidebar-tab:hover {
    color: #222;
}

.sidebar-tab.active {
    color: #1a1a1a;
    font-weight: 600;
    border-bottom: 2px solid #333;
    margin-bottom: -1px;
    padding-bottom: 10px;
}

.sidebar-tab-divider {
    color: #ccc;
    font-size: 13px;
    font-weight: 300;
    padding: 0 2px;
    user-select: none;
}

.sidebar-tab-content {
    display: none;
}

.sidebar-tab-content.active {
    display: block;
}

.sidebar-placeholder-list {
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.sidebar-placeholder-card {
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 24px 16px;
    margin-bottom: 10px;
    text-align: center;
    width: 100%;
}

.placeholder-title {
    font-size: 15px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.placeholder-desc {
    font-size: 13px;
    color: #888;
    line-height: 1.5;
}


/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0;
    padding: 12px 16px;
    gap: 0;
    background: #fff;
}

.sidebar-tab {
    background: none;
    border: none;
    color: #555;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 4px;
    cursor: pointer;
    transition: color 0.2s, border-bottom 0.2s;
    outline: none;
    position: relative;
    white-space: nowrap;
}

.sidebar-tab:hover {
    color: #222;
}

.sidebar-tab.active {
    color: #1a1a1a;
    font-weight: 600;
    border-bottom: 2px solid #333;
    margin-bottom: -1px;
    padding-bottom: 10px;
}

.sidebar-tab-divider {
    color: #ccc;
    font-size: 13px;
    font-weight: 300;
    padding: 0 2px;
    user-select: none;
}

.sidebar-tab-content {
    display: none;
}

.sidebar-tab-content.active {
    display: block;
}

.sidebar-placeholder-list {
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.sidebar-placeholder-card {
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 24px 16px;
    margin-bottom: 10px;
    text-align: center;
    width: 100%;
}

.placeholder-title {
    font-size: 15px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.placeholder-desc {
    font-size: 13px;
    color: #888;
    line-height: 1.5;
}