/* src/smolagentsUI/static/style.css */
:root {
    --bg-dark: #212121;
    --bg-sidebar: #171717;
    --bg-input: #2f2f2f;
    --text-primary: #ececec;
    --text-secondary: #b4b4b4;
    --accent: #10a37f;
    --danger: #ef4444; /* Red for Stop button */
    --danger-hover: #dc2626;
    --border: #444;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #333;
}

.sidebar-header { padding: 10px; }

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #333;
    background-color: rgba(0, 0, 0, 0.2);
    margin-top: auto; /* Ensures it sits at the bottom */
}

.ui-info {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    opacity: 0.6;
    transition: opacity 0.2s ease, color 0.2s ease;
    user-select: none;
    letter-spacing: 0.5px;
    
    /* Flexbox for Icon Alignment */
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none; /* Remove underline from link */
    gap: 8px; /* Space between icon and text */
}

.ui-info:hover {
    opacity: 1;
    color: var(--accent);
}

.ui-info svg {
    fill: currentColor; /* Icon takes text color */
}

.history-list { flex-grow: 1; overflow-y: auto; padding: 10px; }

/* --- HISTORY ITEM STYLES --- */

.history-item {
    position: relative;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.history-item-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.history-item:hover { background-color: #2a2b32; }
/* Visual indicator for the active session */
.history-item.active { background-color: #343541; color: white; border-left: 3px solid var(--accent); }

/* Menu Button (Three Dots) */
.menu-btn {
    opacity: 0;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    color: var(--text-primary);
    margin-left: 5px;
    transition: opacity 0.2s;
}

.history-item:hover .menu-btn { opacity: 1; background-color: #444; }
.menu-btn:hover { background-color: #666; }

/* Context Menu Dropdown */
.context-menu {
    position: absolute;
    top: 35px;
    right: 10px;
    background-color: #25262b;
    border: 1px solid #444;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    z-index: 1000;
    min-width: 120px;
    display: none;
}

.context-menu.visible { display: block; }

.context-menu-item {
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.9em;
    cursor: pointer;
    display: block;
}

.context-menu-item:hover { background-color: #343541; }

.context-menu-item.delete {
    color: #ff6b6b;
    border-top: 1px solid #333;
}

/* Main Chat */
.main-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: filter 0.2s ease, opacity 0.2s ease;
}

.chat-container.loading {
    filter: blur(4px);
    opacity: 0.6;
    pointer-events: none; 
    user-select: none;
}

/* Message Wrappers */
.message {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
    flex-shrink: 0
}

.message .content {
    line-height: 1.6;
    word-wrap: break-word;
}

.message.user { display: flex; justify-content: flex-end; }

.message.user .content {
    background-color: #343541;
    padding: 10px 15px;
    border-radius: 12px;
    border-bottom-right-radius: 2px;
    max-width: 80%;
}

.message.agent {
    border: 1px solid var(--border);
    background-color: rgba(255,255,255,0.02);
    border-radius: 8px;
    overflow: hidden;
    height: auto;
}

.message.agent .content { padding: 20px; height: auto; }
.message.system { text-align: center; color: var(--text-secondary); }

/* --- Developer View / Process Panel --- */

.agent-process-group {
    margin-bottom: 20px;
    border: 1px solid #333;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.process-status-panel {
    padding: 12px 15px;
    background-color: #25262b;
    cursor: pointer;
    display: flex;
    align-items: center;
    position: relative;
    user-select: none;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: background-color 0.2s;
}

.process-status-panel:hover {
    background-color: #2a2b32;
    color: var(--text-primary);
}

/* Loading Bar Animation */
.process-status-panel .loading-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--accent);
    opacity: 0;
    transition: opacity 0.3s;
}

.agent-process-group.running .loading-bar {
    opacity: 1;
    animation: pulse-bar 1.5s infinite ease-in-out;
}

@keyframes pulse-bar {
    0% { opacity: 0.5; box-shadow: 0 0 2px var(--accent); }
    50% { opacity: 1; box-shadow: 0 0 8px var(--accent); }
    100% { opacity: 0.5; box-shadow: 0 0 2px var(--accent); }
}

.status-text {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

.toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    opacity: 0.7;
}

.agent-process-group.expanded .toggle-icon {
    transform: rotate(180deg);
}

.process-steps-container {
    display: none;
    border-top: 1px solid var(--border);
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px;
}

.agent-process-group.expanded .process-steps-container {
    display: block;
}


/* Collapsible Steps (Modified to fit in container) */
details.step {
    background-color: #2a2b32;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    overflow: hidden;
}

details.step:last-child {
    margin-bottom: 0;
}

summary {
    padding: 8px 12px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    list-style: none;
    font-size: 0.9em;
}

summary::-webkit-details-marker { display: none; }
summary::after { content: '▼'; font-size: 0.8em; margin-left: auto; }
details[open] summary::after { content: '▲'; }

.step-content {
    padding: 12px;
    border-top: 1px solid var(--border);
    background-color: #00000020;
    font-family: monospace;
    font-size: 0.9em;
    white-space: pre-wrap;
}

/* Input Area */
.input-area { padding: 20px; background: var(--bg-dark); }

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    background: var(--bg-input);
    border-radius: 24px; /* More rounded container */
    border: 1px solid #555;
    display: flex;
    padding: 10px 15px;
    align-items: flex-end; /* Align bottom for multiline */
}

textarea {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: white;
    resize: none;
    outline: none;
    max-height: 200px;
    padding: 10px 0;
    font-size: 1rem;
}

#send-btn {
    background: var(--accent);
    border: none;
    border-radius: 50%; /* Perfect Circle */
    color: white;
    padding: 0;           
    width: 40px;          
    height: 40px;        
    display: flex;       
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#send-btn:hover { background-color: #0d8a6a; transform: scale(1.05); }

/* Stop Button State */
#send-btn.stop {
    background-color: var(--danger);
}

#send-btn.stop:hover {
    background-color: var(--danger-hover);
}

/* Final Answer & Misc */
.final-answer {
    background-color: #2a2b32;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--accent);
    overflow-x: auto;
    margin-top: 15px;
}

img.agent-image { max-width: 100%; border-radius: 8px; margin-top: 10px; }

.step-thinking {
    font-family: monospace;
    color: #a0a0a0;
    white-space: pre-wrap;
    padding: 10px;
    font-size: 0.9em;
    /* removed border/background since it's now inside the details view */
}

.code-block {
    background: #111;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto; 
    margin-bottom: 10px;
}

.code-block .hljs {
    background: transparent;
    padding: 0;
}

.error-msg { color: #ff6b6b; padding: 5px; background: #3d1a1a; border-radius: 4px; }
.logs { border-top: 1px dashed #444; padding-top: 10px; font-size: 0.85em; color: #888; }

/* Modal Styles (Unchanged mostly) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.modal-overlay.visible { display: flex; }
.modal-box {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    padding: 20px;
    display: flex; flex-direction: column; gap: 15px;
}
.modal-input {
    width: 100%; 
    padding: 10px; 
    border-radius: 5px;
    border: 1px solid var(--border); 
    background-color: #222; 
    color: white;
    box-sizing: border-box; 
}
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; }
.modal-btn { padding: 8px 16px; border-radius: 4px; border: none; cursor: pointer; color: white;}
.modal-btn.cancel { background: transparent; border: 1px solid #444; }
.modal-btn.confirm { background: var(--accent); }
.modal-btn.confirm.danger { background: var(--danger); }


* {
    scrollbar-width: thin; 
    scrollbar-color: #777777 #2c2c2c;
}

/* --- Webkit Method (Chrome, Edge, Safari, Opera) --- */
::-webkit-scrollbar {
    width: 14px;  /* Width for vertical scrollbars */
    height: 14px; /* Height for horizontal scrollbars */
}

::-webkit-scrollbar-track {
    background: #2c2c2c; /* Deep gray background to blend with dark themes */
    border-radius: 0px;
}

::-webkit-scrollbar-thumb {
    background-color: #666666; /* A medium matte gray */
    border-radius: 10px;       /* Makes the thumb rounded */
    
    /* This trick creates padding around the thumb so it doesn't fill the track width */
    border: 3px solid transparent; 
    background-clip: content-box; 
}

::-webkit-scrollbar-thumb:hover {
    background-color: #888888; /* A slightly lighter gray on hover */
}

::-webkit-scrollbar-thumb:active {
    background-color: #999999; 
    border: 2px solid transparent; /* Slightly larger on click for feedback */
}