:root {
    --font-family: 'Poppins', sans-serif;
    --success-color: #28a745;
    --danger-color: #dc3545;

    /* Default Theme (Original Dark) */
    --primary-color: #8a2be2; /* BlueViolet */
    --secondary-color: #4169e1; /* RoyalBlue */
    --background-start: #0f0c29;
    --background-mid: #302b63;
    --background-end: #24243e;
    --surface-color: rgba(255, 255, 255, 0.07);
    --text-color: #e8e6e3;
    --text-secondary-color: #a9a9a9;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --user-message-bg: linear-gradient(90deg, #6a5acd, #5a4acb);
    --agent-message-bg: linear-gradient(90deg, #7a4a9e, #8a5a9e);
    --overlay-bg-light: rgba(255, 255, 255, 0.1);
    --overlay-bg-dark: rgba(0, 0, 0, 0.2);
    --modal-bg: rgba(36, 36, 62, 0.6);
    --modal-border: rgba(255, 255, 255, 0.2);
    --modal-input-bg: rgba(0, 0, 0, 0.2);
    --modal-input-border: rgba(255, 255, 255, 0.2);
    --node-text-color: #FFFFFF;
    --header-bg: rgba(15, 12, 41, 0.8);
    --toast-bg: rgba(255, 255, 255, 0.1);
    --shortcut-item-bg: rgba(255, 255, 255, 0.08);
}

[data-theme="true-dark"] {
    --primary-color: #74c69d;
    --secondary-color: #40916c;
    --background-start: #121212;
    --background-mid: #121212;
    --background-end: #121212;
    --surface-color: #232323;
    --text-color: #f8f9fa;
    --text-secondary-color: #adb5bd;
    --border-color: rgba(248, 249, 250, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.9);
    --user-message-bg: linear-gradient(90deg, #2d6a4f, #1b4332);
    --agent-message-bg: linear-gradient(90deg, #495057, #343a40);
    --overlay-bg-light: rgba(255, 255, 255, 0.08);
    --overlay-bg-dark: rgba(0, 0, 0, 0.15);
    --modal-bg: rgba(35, 35, 35, 0.6);
    --modal-border: rgba(255, 255, 255, 0.15);
    --modal-input-bg: rgba(0, 0, 0, 0.2);
    --modal-input-border: rgba(255, 255, 255, 0.15);
    --node-text-color: #f8f9fa;
    --header-bg: rgba(18, 18, 18, 0.8);
    --toast-bg: rgba(255, 255, 255, 0.1);
    --shortcut-item-bg: #2a2a2a;
}

[data-theme="light"] {
    --primary-color: #6a1b9a;
    --secondary-color: #303f9f;
    --background-start: #f5f5f5;
    --background-mid: #e8eaf6;
    --background-end: #e0e0e0;
    --surface-color: #ffffff;
    --text-color: #212121;
    --text-secondary-color: #757575;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --user-message-bg: linear-gradient(90deg, #d6e2e9, #bcd4e6);
    --agent-message-bg: linear-gradient(90deg, #e9ecef, #dee2e6);
    --overlay-bg-light: rgba(0, 0, 0, 0.05);
    --overlay-bg-dark: rgba(255, 255, 255, 0.8);
    --modal-bg: rgba(255, 255, 255, 0.75);
    --modal-border: rgba(0, 0, 0, 0.1);
    --modal-input-bg: rgba(0, 0, 0, 0.05);
    --modal-input-border: rgba(0, 0, 0, 0.1);
    --node-text-color: #212121;
    --header-bg: rgba(232, 234, 246, 0.8);
    --toast-bg: rgba(255, 255, 255, 0.5);
    --shortcut-item-bg: #f1f1f1;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(45deg, var(--background-start), var(--background-mid), var(--background-end));
    color: var(--text-color);
    margin: 0;
    line-height: 1.6;
    height: 100vh;
    display: flex;
}

.sidebar {
    width: 80px; /* Default collapsed width */
    background: var(--background-start);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: width 0.2s ease; /* Faster transition */
    overflow-x: hidden; /* Hide overflowing text */
    flex-shrink: 0; /* Prevent sidebar from shrinking */
    flex-grow: 0; /* Prevent sidebar from growing */
    will-change: width;
}

.sidebar:hover {
    width: 250px; /* Expanded width on hover */
}



body.sidebar-expanded .sidebar {
    width: 250px; /* Expanded width when toggled by hamburger */
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .logo-text {
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.2; /* Explicit line-height to stabilize text */
    white-space: nowrap; /* Prevent text wrapping */
    display: none; /* Hidden by default */
}

/* Typing animation for logo text */
@keyframes typing {
    from { width: 0 }
    to { width: 100% }
}

.sidebar:hover .sidebar-header .logo-text,
body.sidebar-expanded .sidebar-header .logo-text {
    display: block; /* Ensure it's block for width animation */
    overflow: hidden; /* Ensures the text is cut off as width increases */
    white-space: nowrap; /* Keeps text on a single line */
    animation: typing 1s steps(10, end) forwards; /* Adjust steps based on text length, increased duration to 1s */
    width: 0; /* Start with 0 width for animation */
}

.sidebar-header .logo-icon {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    display: block; /* Visible by default */
}

.sidebar:hover .sidebar-header .logo-icon,
body.sidebar-expanded .sidebar-header .logo-icon {
    display: none; /* Hide on hover or when expanded */
}

.logo-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.sidebar-nav {
    flex-grow: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 1.1rem;
    transition: background 0.3s ease;
}

.nav-item:hover {
    background: var(--surface-color);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-icon {
    margin-right: 15px;
}

.nav-text {
    display: none; /* Hidden by default */
}

.sidebar:hover .nav-text,
body.sidebar-expanded .nav-text {
    display: inline; /* Show on hover or when expanded */
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: width 0.2s ease; /* Faster transition */
    will-change: width;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 20px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-header h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 600;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.digital-clock {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    background: var(--surface-color);
    padding: 8px 15px;
    border-radius: 20px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-color);
    padding: 8px 15px;
    border-radius: 20px;
    transition: background-color 0.3s;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.15);
}

.user-profile-icon {
    font-size: 1.2rem;
}

.user-profile span {
    font-size: 0.9rem;
    font-weight: 500;
}

.content-area {
    padding: 30px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    transition: opacity 0.2s ease-in-out;
}

.content-area.fade-out {
    opacity: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.card {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* Softer shadow */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px); /* Lift effect */
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7); /* Enhanced shadow */
}

.card h3 {
    margin-top: 0;
    font-size: 1.5rem;
}

.button {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-color);
}

#terminal-container {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--surface-color);
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px var(--shadow-color);
}

.login-card h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.login-card p {
    color: var(--text-color);
    margin-bottom: 30px;
}

.login-card a {
    color: white;
    font-weight: bold;
    text-decoration: none;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-color);
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    background-color: rgba(0,0,0,0.2);
    color: var(--text-color);
    border-radius: 8px;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
}

.login-card button {
    width: 100%;
    padding: 12px;
    border: none;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.login-card button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.modal-content {
    background: var(--modal-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--modal-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    padding: 30px;
    width: 80%;
    max-width: 500px;
    min-width: 300px; 
    position: relative;
}

.modal-content .input-group {
    margin-bottom: 15px;
}

.modal-content .input-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--modal-input-bg);
    border: 1px solid var(--modal-input-border);
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 1rem;
    color: var(--text-color);
    width: 100%;
    cursor: pointer;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23A9A9A9%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: .65em auto;
}

.modal-content .input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.5);
}

    .modal-actions .button {
        width: 100%;
    }
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

/* Modal Close Button */
.modal .close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary-color);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.modal .close-button:hover {
    color: var(--text-color);
    transform: rotate(90deg);
}

/* Modal Header */
.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

/* Button Loading State */
.button.loading {
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.hamburger-btn {
    display: block;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}

.main-layout-agenthub {
    display: flex;
    gap: 20px;
    flex-grow: 1;
    min-height: 0;
}

#left-column-agenthub {
    width: 250px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#right-column-agenthub {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-frame-agenthub {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Remove redundant styling from chat-section-agenthub */
#chat-section-agenthub {
    background: none;
    padding: 0;
    border: none;
    box-shadow: none;
}

/* Adjust chat window padding and margin */
#chat-window-agenthub {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    margin-bottom: 15px;
    height: 450px; /* Adjusted fixed height for the chat window */
    padding: 10px; /* Adjusted padding */
    border-radius: 8px; /* Match input/button rounding */
    background-color: rgba(0,0,0,0.1); /* Slightly darker background for chat history */
}

/* Adjust chat form margin */
#chat-form-agenthub {
    margin-top: 0; /* Remove top margin, as it's now part of the frame */
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    align-items: center; /* Align items vertically */
}

#chat-form-agenthub #upload-btn-agenthub {
    background: none;
    border: none;
    color: var(--text-secondary-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 5px;
    transition: color 0.3s ease;
}

#chat-form-agenthub #upload-btn-agenthub:hover {
    color: var(--primary-color);
}

#chat-form-agenthub input {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: rgba(0,0,0,0.2);
    color: var(--text-color);
}

#chat-form-agenthub button {
    padding: 12px 25px;
    border: none;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#chat-form-agenthub button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.agent-grid-agenthub {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    overflow-y: auto; /* Allow agent list to scroll if needed */
}

.agent-card {
    background: var(--surface-color);
    padding: 5px 15px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px var(--shadow-color);
    margin-bottom: 10px;
    transition: all 0.3s ease;
    overflow: hidden;
    max-height: 25px;
    cursor: pointer;
}

.agent-card:hover, .agent-card.agent-card-hover-expanded {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    border-color: var(--primary-color);
    max-height: 500px;
    padding: 20px;
}

.agent-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Base Agent Card Styles (for Settings page) */
.agent-card h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
}

.agent-card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    margin-top: 10px;
}

.agent-card-details p {
    margin: 8px 0;
    color: var(--text-color);
}

.agent-card-details .url {
    font-style: italic;
    color: var(--text-secondary-color);
    word-break: break-all;
}

/* Agent Hub Page Specific Overrides */
#agent-list-agenthub .agent-card h3 {
    font-size: 0.85rem;
}

#agent-list-agenthub .agent-card-details p {
    font-size: 0.7rem;
}

.agent-card:hover .agent-card-details,
.agent-card.agent-card-hover-expanded .agent-card-details {
    max-height: 500px;
}

.agents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px; /* Adjust as needed */
}

.agents-header h2 {
    margin: 0;
}

.button-small {
    display: inline-block;
    padding: 5px 10px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.8rem; /* Smaller font size */
    transition: all 0.3s ease;
}

.button-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.btn-remove {
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem; /* Make the icon larger */
    padding: 5px;
    border-radius: 50%; /* Make it a circle */
    line-height: 1; /* Ensure proper vertical alignment */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover {
    background: rgba(220, 53, 69, 0.2); /* A light red background on hover */
    color: var(--danger-color); /* Make the icon red on hover */
}

/* Tab styles */
.tabs-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.add-agent-card {
    background: #1a1a2e; /* Match agent card background */
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color); /* Match agent card border */
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 150px; /* Ensure it has some height */
}

.add-agent-card h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.add-agent-card form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.add-agent-card input[type="url"] {
    width: calc(100% - 20px);
    padding: 10px;
    border: 1px solid var(--border-color);
    background-color: rgba(0,0,0,0.2);
    color: var(--text-color);
    border-radius: 8px;
    box-sizing: border-box;
}

.add-agent-card button {
    width: 100%;
    padding: 10px;
    border: none;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-agent-card button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.settings-agent-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* Settings Page: Non-foldable, fixed-size agent cards */
.page-settings .agent-card {
    height: 220px;
    padding: 20px;
    cursor: default;
    max-height: 220px; /* Override hover-to-expand behavior */
    overflow-y: auto; /* Add scroll if content overflows */
}

.page-settings .agent-card:hover {
    transform: none; /* Disable hover lift effect */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* Keep base shadow */
}

.page-settings .agent-card .agent-card-details {
    max-height: none; /* Allow details to be fully visible */
}

/* Settings Page: Specific font sizes */
.page-settings .agent-card .description {
    font-size: 0.8rem;
}

.page-settings .agent-card .url {
    font-size: 0.75rem;
    word-break: break-all;
}

/* --- Styles for Default Agents Manager --- */
.side-by-side-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.agent-list-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    min-height: 200px;
    background-color: rgba(0,0,0,0.1);
    height: 300px; /* Fixed height */
    overflow-y: auto; /* Allow scrolling */
}

.custom-agent-form {
    margin-bottom: 20px;
    max-width: 50%;
}

.custom-agent-form form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.custom-agent-form input[type="url"] {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    background-color: rgba(0,0,0,0.2);
    color: var(--text-color);
    border-radius: 8px;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.custom-agent-form input[type="url"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
}

/* --- Compact UI for Fixed Agent Cards on Settings Page --- */
.settings-agent-grid .agent-card h3 {
    font-size: 0.85rem; /* Slightly smaller title */
    margin-bottom: 5px;
}

.settings-agent-grid .agent-card .description {
    font-size: 0.75rem; /* Smaller description font */
    line-height: 1.4; /* Tighter line spacing */
    margin-bottom: 5px;
}

.settings-agent-grid .agent-card .url,
.settings-agent-grid .agent-card .last-seen {
    font-size: 0.7rem; /* Even smaller meta font */
}

/* --- Compact UI Adjustments for Agent Manager --- */
#my-default-agents-tab-content .card {
    padding: 15px; /* Reduce card padding */
}

#my-default-agents-tab-content h3 {
    margin-bottom: 5px; /* Reduce space below main title */
}

#my-default-agents-tab-content > .card > p {
    margin-bottom: 15px; /* Reduce space below description p */
}

#my-default-agents-tab-content .custom-agent-form {
    margin-bottom: 15px; /* Reduce space below the form */
}

#my-default-agents-tab-content h4 {
    margin-top: 0;
    margin-bottom: 10px; /* Reduce space below list titles */
}

#my-default-agents-tab-content .side-by-side-layout {
    gap: 15px; /* Reduce gap between lists */
}

#my-default-agents-tab-content .agent-list-container {
    padding: 10px; /* Reduce padding inside lists */
}

#my-default-agents-tab-content .default-agent-item,
#my-default-agents-tab-content .available-agent-item {
    padding: 8px; /* Reduce padding in items */
    margin-bottom: 5px; /* Reduce space between items */
    font-size: 0.85rem; /* Slightly smaller font */
}

/* Simple card for agents in the new lists */
.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--shortcut-item-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.shortcut-item:hover {
    background: var(--overlay-bg-light);
    transform: translateY(-2px);
}

#shortcuts-list .shortcut-item .shortcut-link,
#shortcuts-list .shortcut-item .shortcut-link:visited {
    color: var(--text-color) !important;
    text-decoration: none;
    flex-grow: 1;
    font-weight: 600;
    transition: color 0.2s ease;
}

#shortcuts-list .shortcut-item .shortcut-link:hover {
    color: var(--primary-color) !important;
}

.default-agent-item button, .available-agent-item button {
    padding: 3px 8px;
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 10px;
}

.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-button {
    background: none;
    border: none;
    padding: 10px 20px;
    color: var(--text-secondary-color);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.3s ease, border-bottom 0.3s ease, font-size 0.3s ease;
}

.tab-button:hover {
    color: var(--text-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    font-size: 1.5rem;
    font-weight: 600;
}

.tab-content {
    display: none;
    flex-grow: 1;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
}

#terminal-container {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
}

/* Login Page */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.message {
    margin-bottom: 8px;  /* Slightly less vertical spacing */
    padding: 6px 12px;   /* Further reduced internal padding */
    border-radius: 12px; /* Consistent with larger containers */
    max-width: 70%;      /* Keep max-width as is */
    line-height: 1.3;    /* Tighter line spacing */
    font-size: 0.85rem;  /* Slightly smaller font size */
}

.message.user {
    background: var(--user-message-bg);
    color: var(--text-color);
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.message.agent {
    background: var(--agent-message-bg);
    color: var(--text-color);
    margin-right: auto;
    border-bottom-left-radius: 5px;
}

.message.thinking-bubble .typing-indicator {
    display: inline-flex;
    align-items: center;
    margin-left: 5px;
}

.message.thinking-bubble .typing-indicator span {
    height: 8px;
    width: 8px;
    margin: 0 2px;
    background-color: var(--text-secondary-color);
    border-radius: 50%;
    display: inline-block;
    animation: pulse-dots 1.4s infinite ease-in-out both;
}

.message.thinking-bubble .typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.message.thinking-bubble .typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes pulse-dots {
  0%, 80%, 100% { transform: scale(0); } 
  40% { transform: scale(1.0); }
}

.message pre {
    background-color: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message code {
    font-family: 'Courier New', Courier, monospace;
    background-color: rgba(0,0,0,0.2);
    padding: 2px 4px;
    border-radius: 3px;
}

.message pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

#chat-form-agenthub button.busy {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
    overflow: hidden;
    background: var(--text-secondary-color);
    box-shadow: none;
    transform: none;
}

#chat-form-agenthub button.busy:hover {
    transform: none;
    box-shadow: none;
    background: var(--text-secondary-color);
}

#chat-form-agenthub button.busy::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.agent-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
}

.status-dot-online {
    background-color: var(--success-color);
}

.status-dot-offline {
    background-color: var(--danger-color);
}

#chat-form-agenthub #upload-btn-agenthub:hover {
    color: var(--primary-color);
}

/* Settings Page Layout */
.settings-container {
    display: flex;
    gap: 30px;
    height: 100%;
}

.settings-menu {
    flex: 0 0 200px; /* Fixed width for the menu */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-menu-item {
    display: block;
    padding: 15px 20px;
    color: var(--text-secondary-color);
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.3s, color 0.3s;
    font-weight: 500;
}

.settings-menu-item:hover {
    background-color: var(--surface-color);
    color: var(--text-color);
}

.settings-menu-item.active {
    background-color: var(--surface-color);
    color: var(--primary-color);
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
}

.settings-content {
    flex-grow: 1;
}

.settings-section {
    display: none; /* Hidden by default */
    animation: fadeIn 0.5s ease-in-out;
}

.settings-section.active {
    display: block; /* Shown when active */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive for settings */
@media (max-width: 768px) {
    .settings-container {
        flex-direction: column;
    }
    .settings-menu {
        flex-direction: row;
        flex: 0 0 auto;
        overflow-x: auto;
    }

    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .side-by-side-layout {
        grid-template-columns: 1fr;
    }
}

/* --- Mission Control Dashboard --- */
.dashboard-grid-container {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: 1fr 1.5fr;
    gap: 20px;
    height: calc(100vh - 150px);
}

.widget-agents-status {}
.widget-recent-automations {}
.widget-log-feed { 
    display: flex;
    flex-direction: column;
}

.dashboard-widget {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-color) 0px 4px 12px;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.widget-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.widget-content {
    flex-grow: 1;
    overflow-y: auto;
    font-size: 0.9rem;
}

/* Specific Widget Styles */
#agent-status-list .agent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}
#agent-status-list .agent-item:last-child {
    border-bottom: none;
}

#recent-automations-list .automation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}
#recent-automations-list .automation-item:last-child {
    border-bottom: none;
}
.automation-status-success {
    color: var(--success-color);
    font-weight: 600;
}
.automation-status-failed {
    color: var(--danger-color);
    font-weight: 600;
}

#log-feed-display {
    flex-grow: 1; /* Make log display fill the widget */
    white-space: pre-wrap;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    line-height: 1.4;
    background-color: var(--overlay-bg-dark);
    border-radius: 6px;
    padding: 10px;
    min-height: 100px; /* Ensure it has some height */
}

.log-entry {
    padding: 5px 0;
    border-bottom: 1px solid var(--border-color);
}
.log-entry:last-child {
    border-bottom: none;
}
.log-timestamp {
    color: var(--text-secondary-color);
    margin-right: 10px;
}
.log-level {
    font-weight: 600;
    margin-right: 10px;
}
.log-level-info {
    color: var(--success-color);
}
.log-level-error {
    color: var(--danger-color);
}
.log-level-warning {
    color: #ffc107;
}


/* --- Artifacts Page Table --- */
.details-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.details-table th, .details-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.details-table th {
    background-color: rgba(0,0,0,0.2);
    font-weight: 600;
    color: var(--text-color);
}

.details-table tbody tr:hover {
    background-color: var(--surface-color);
}

.details-table .type-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: capitalize;
}

.details-table .type-badge.personal {
    background-color: var(--primary-color);
    color: white;
}

.details-table .type-badge.public {
    background-color: var(--secondary-color);
    color: white;
}

.artifacts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-container input {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: rgba(0,0,0,0.2);
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 0.9rem;
    min-width: 250px;
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(138, 43, 226, 0.5);
}


/* --- Toast Notifications --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2001; /* Increased z-index */
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-message {
    background: var(--toast-bg);
    backdrop-filter: blur(10px);
    color: var(--text-color);
    padding: 15px 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px var(--shadow-color);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto;
}

.toast-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary-color);
    font-size: 1.5rem;
    line-height: 1;
    padding: 0 0 0 15px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
}

.toast-close-btn:hover {
    opacity: 1;
    color: var(--text-color);
}

.toast-message.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-message.success {
    border-left: 4px solid var(--success-color);
}

.toast-message.error {
    border-left: 4px solid var(--danger-color);
}

.toast-title {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.toast-body {
    font-size: 0.9rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Specific override for the edit user modal to ensure it's a proper popup */
#edit-user-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
}

/* Specific override for the confirmation modal to ensure it's always on top of other modals */
#confirm-modal {
    z-index: 1003;
}


/* --- Loading Overlay --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.loading-overlay.show {
    opacity: 1;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid var(--primary-color);
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

/* Accessibility: Hide element visually but keep it accessible to screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Nested Tabs */
.nested-tabs-header {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.nested-tab-button {
    background: none;
    border: none;
    padding: 10px 20px;
    color: var(--text-secondary-color);
    font-size: 1rem;
    cursor: pointer;
    transition: color 0.3s ease, border-bottom 0.3s ease;
}

.nested-tab-button:hover {
    color: var(--text-color);
}

.nested-tab-button.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    font-weight: 600;
}

.nested-tab-content {
    display: none;
}

.nested-tab-content.active {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}
/* --- Settings Page Form Professional Refresh --- */

/* Use a more specific selector to avoid affecting other forms */
.settings-section .card form {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px; /* Increased gap for better spacing */
}

/* Grid layout for name fields */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.settings-section .card .input-group {
    margin-bottom: 0; /* Remove margin as we use gap now */
}

.settings-section .card .input-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary-color);
    margin-bottom: 8px;
}

.settings-section .card .input-group input {
    background-color: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 1rem;
    color: var(--text-color);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.settings-section .card .input-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.25); /* A glow effect */
}

.settings-section .card button[type="submit"] {
    align-self: flex-start; /* Align button to the left */
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    transition: all 0.3s ease;
}

.settings-section .card button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* Status message styling */
#update-status, #password-status {
    margin-top: 5px;
    font-weight: 500;
    font-size: 0.9rem;
    height: 20px; /* Reserve space to prevent layout shift */
    transition: color 0.3s;
}
/* --- Visual Theme Selector --- */
.theme-selector {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.theme-option {
    cursor: pointer;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    width: 120px;
}

.theme-option:hover {
    border-color: var(--secondary-color);
    transform: translateY(-3px);
}

.theme-option.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.4);
    background-color: var(--surface-color);
}

.theme-preview {
    height: 60px;
    border-radius: 6px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
}

.theme-dark {
    background: linear-gradient(45deg, #0f0c29, #302b63);
}

.theme-light {
    background: linear-gradient(45deg, #f5f5f5, #e8eaf6);
}

.theme-true-dark {
    background: linear-gradient(45deg, #212529, #343a40);
}

.theme-option span {
    font-weight: 600;
}

/* Style the select dropdown to match the text inputs */
.card .input-group select {
    appearance: none; /* Remove default arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 1rem;
    color: var(--text-color);
    transition: border-color 0.3s, box-shadow 0.3s;
    width: 100%;
    cursor: pointer;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23A9A9A9%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: .65em auto;
}

.card .input-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.25); /* A glow effect */
    outline: none;
}




.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.logs-header h3 {
    margin: 0;
}

.logs-header .input-group {
    margin-bottom: 0;
    min-width: 200px;
}