:root {
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --border: rgba(0, 0, 0, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);
    
    --agent-plant: #10b981;
    --agent-me: #f59e0b;
    --agent-facilitator: #8b5cf6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.top-headbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    z-index: 10;
    flex-shrink: 0;
}

.top-headbar .logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-headbar h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.app-container {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    grid-template-rows: minmax(0, 1fr);
    flex: 1;
    overflow: hidden;
    min-height: 0;
    min-width: 0;
}

/* Glassmorphism Utilities */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 0;
    min-width: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}



.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: 'Inter', sans-serif;
    flex-shrink: 0; /* Prevent button from shrinking */
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.w-full { width: 100%; }

.history-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.history-list h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

#problem-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
    padding-right: 8px; /* For scrollbar */
}

#problem-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: background 0.2s, color 0.2s;
    gap: 10px;
}

#problem-list li .problem-title-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#problem-list li .btn-delete-problem {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
}

#problem-list li:hover .btn-delete-problem {
    display: flex;
}

#problem-list li .btn-delete-problem:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

#problem-list li:hover, #problem-list li.active {
    background: rgba(0, 0, 0, 0.05);
    color: var(--accent);
}

/* Main Content */
.main-content {
    padding: 32px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

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

.view-header {
    margin-bottom: 24px;
}

.view-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.view-header p {
    color: var(--text-secondary);
}

.header-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}

#current-problem-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.step-badge {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

#view-init.active {
    display: block;
    overflow-y: auto;
    height: 100%;
    padding-bottom: 32px; /* Extra padding at bottom for better scrolling */
}

/* Form Container */
.form-container {
    padding: 32px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input[type="text"], .form-group textarea {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input[type="text"]:focus, .form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.checkbox-group label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    color: var(--text-primary) !important;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 40px 24px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 80%;
    padding: 16px;
    border-radius: 12px;
    line-height: 1.5;
    animation: slideIn 0.3s ease-out;
}

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

.message.user {
    align-self: flex-end;
    background: rgba(79, 70, 229, 0.1);
    border: 1px solid rgba(79, 70, 229, 0.2);
}

.message.assistant {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.msg-agent-name {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--agent-facilitator);
}

.message.assistant.peer .msg-agent-name {
    color: var(--agent-plant);
}

.chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

#chat-form {
    display: flex;
    gap: 12px;
    position: relative;
}

#chat-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    padding: 14px 20px;
    border-radius: 24px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: var(--accent);
}

.btn-icon {
    background: var(--accent);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-icon:hover {
    transform: scale(1.05);
}

/* Right Panel */
.right-panel {
    border-left: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background: var(--bg-secondary);
}

.panel-section {
    padding: 20px;
}

.panel-section h3 {
    font-size: 0.9rem;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.stepper {
    list-style: none;
    position: relative;
}

.stepper::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: var(--border);
}

.step {
    position: relative;
    padding-left: 32px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.step::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    z-index: 1;
    transition: all 0.3s;
}

.step.active {
    color: var(--text-primary);
    font-weight: 600;
}

.step.active::before {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.agent-matrix {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.agent-card {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.agent-card:hover {
    border-color: var(--border);
}

.agent-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.agent-avatar.plant {
    background: linear-gradient(135deg, #10b981, #059669);
}

.agent-avatar.me {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.agent-info h4 {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.agent-info p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Tooltip Styles */
.tooltip-container {
    position: relative;
    display: inline-block;
}

.tooltip-container .tooltip-text {
    visibility: hidden;
    width: max-content;
    max-width: 280px;
    min-width: 180px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    font-size: 0.8rem;
    line-height: 1.4;
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
    pointer-events: none;
    white-space: normal;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Modal Glassmorphism Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    width: 520px;
    max-width: 90%;
    box-shadow: 0 20px 40px 0 rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalFadeIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}
.close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.close-btn:hover {
    color: var(--text-primary);
}
.modal-body {
    padding: 24px;
    max-height: 65vh;
    overflow-y: auto;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}
.btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}
.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Role Selector & Dropdown styling */
#btn-add-role:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.role-dropdown-group-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 8px 16px 4px 16px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-top: 1px solid var(--border);
    opacity: 0.8;
}

.role-dropdown-group-title:first-child {
    border-top: none;
    padding-top: 4px;
}

.role-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.role-dropdown-item:hover {
    background-color: rgba(99, 102, 241, 0.08);
}

.role-dropdown-item.active {
    background-color: rgba(99, 102, 241, 0.12);
    font-weight: 600;
}

.role-dropdown-item .role-avatar {
    font-size: 1.2rem;
    width: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.role-dropdown-item .role-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-dropdown-item .role-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-left: auto;
}

/* Human group member custom style */
.message.assistant.peer.member .msg-agent-name {
    color: var(--accent) !important;
}

.message.assistant.peer.member {
    border-left: 4px solid var(--accent) !important;
}


