/* Chatbot Sidebar Styling - VS Code Theme */
:root {
    --vscode-bg: #1e1e1e;
    --vscode-sidebar: #252526;
    --vscode-fg: #d4d4d4;
    --vscode-header: #3c3c3c;
    --vscode-blue: #007acc;
    --vscode-border: #454545;
    --vscode-input-bg: #3c3c3c;
    --vscode-input-fg: #cccccc;
    --sidebar-width: 400px;
}

/* DO NOT block scrolling globally */
body {
    margin: 0;
}

/* Training labs link */
.training-link {
    margin-bottom: 12px;
}
.training-link a {
    color: var(--vscode-blue);
    text-decoration: none;
    font-weight: 600;
}
.training-link a:hover {
    text-decoration: underline;
}

/* Full layout container */
#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Main Page Content */
#main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    transition: margin-right 0.3s ease;
}

/* --- SIDEBAR --- */
#chatbot-sidebar {
    width: var(--sidebar-width);
    background-color: var(--vscode-bg);
    color: var(--vscode-fg);
    border-left: 1px solid var(--vscode-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    flex-shrink: 0;
    transition: width 0.3s ease;
    z-index: 9999;
}

/* Collapsed Mode */
#chatbot-sidebar.collapsed {
    width: 40px;
}

#chatbot-sidebar.collapsed #chatbot-messages,
#chatbot-sidebar.collapsed #chatbot-input-area,
#chatbot-sidebar.collapsed h3 {
    display: none;
}
/* Resize Handle */
#chatbot-resize-handle {
    width: 8px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    position: absolute;
    left: -4px;
    top: 0;
    z-index: 10000;
    touch-action: none;
}

#chatbot-resize-handle:hover {
    background: rgba(255, 255, 255, 0.1);
}
/* Header Bar */
#chatbot-header {
    background-color: var(--vscode-header);
    color: var(--vscode-fg);
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--vscode-border);
    height: 40px;
    box-sizing: border-box;
}

#chatbot-header h3 {
    margin: 0;
    font-size: 13px;
    text-transform: uppercase;
    white-space: nowrap;
}

#chatbot-toggle-sidebar {
    background: none;
    border: none;
    color: var(--vscode-fg);
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
}

#chatbot-toggle-sidebar:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* --- CHAT MESSAGES --- */
#chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-size: 14px;
}

/* Scrollbar */
#chatbot-messages::-webkit-scrollbar {
    width: 10px;
}
#chatbot-messages::-webkit-scrollbar-track {
    background: var(--vscode-bg);
}
#chatbot-messages::-webkit-scrollbar-thumb {
    background: #424242;
}
#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #4f4f4f;
}

/* Message Bubbles */
.message {
    max-width: 95%;
    padding: 10px 12px;
    border-radius: 4px;
    line-height: 1.5;
    word-wrap: break-word;
}
.message.user {
    align-self: flex-end;
    background-color: #264f78;
    color: white;
}
.message.bot {
    align-self: flex-start;
    background-color: var(--vscode-sidebar);
    color: var(--vscode-fg);
    border: 1px solid var(--vscode-border);
}
.message.system {
    align-self: center;
    background-color: #333;
    color: #aaa;
    font-size: 12px;
    text-align: center;
    width: 100%;
    border: 1px dashed #555;
}

/* Markdown */
.message pre {
    background-color: #000;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid #444;
}
.message code {
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
}
.message :not(pre) > code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

/* --- INPUT AREA --- */
#chatbot-input-area {
    background-color: var(--vscode-bg);
    border-top: 1px solid var(--vscode-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    position: relative;
    box-sizing: border-box;
}
#chatbot-text-input {
    width: 100%;
    min-height: 60px;
    resize: vertical;
    background-color: var(--vscode-input-bg);
    color: var(--vscode-input-fg);
    border: 1px solid var(--vscode-border);
    border-radius: 3px;
    padding: 6px 8px;
    font-size: 13px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
#code-editor-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
#code-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--vscode-fg);
}
#code-language {
    background-color: var(--vscode-bg);
    color: var(--vscode-fg);
    border: 1px solid var(--vscode-border);
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 12px;
}
/* CodeMirror editor */
.CodeMirror {
    height: 150px !important;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    border-radius: 3px;
    border: 1px solid var(--vscode-border);
}

/* Send Button */
#chatbot-send {
    align-self: flex-end;
    margin-top: 4px;
    position: static; /* override absolute from earlier if needed */
}
#chatbot-send:hover {
    opacity: 1;
}
#chatbot-send:disabled {
    background-color: #555;
    color: #aaa;
    cursor: not-allowed;
}

/* --- API KEY MODAL --- */
#api-key-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.75);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 20000; /* above sidebar */
}

#api-key-modal .modal-box {
    background: #1e1e1e;
    padding: 25px 30px;
    border-radius: 6px;
    width: 320px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    color: white;
    text-align: center;
}

#api-key-input {
    width: 80%;
    padding: 10px;
    margin: 15px 0;
    background-color: var(--vscode-input-bg);
    color: var(--vscode-input-fg);
    border: 1px solid var(--vscode-border);
    border-radius: 3px;
}

#save-api-key {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 3px;
    cursor: pointer;
}
