body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #1e1e1e;
    color: #d4d4d4;
}

header {
    background-color: #252526;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #3e3e42;
    z-index: 10;
}

header h1 {
    margin: 0;
    font-size: 1.2rem;
    color: #00979d;
    margin-right: 20px;
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

button.t-btn {
    background-color: #00979d;
    border: none;
    color: white;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 4px;
    font-weight: bold;
}

button.t-btn:hover {
    background-color: #007f85;
}

button.t-btn:disabled {
    background-color: #444;
    cursor: not-allowed;
}

/* Container for Sidebar + Activity Bar + Editor */
.workbench-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* --- SIDEBAR STYLES --- */
#left-sidebar {
    width: 250px;
    background-color: #252526;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #3e3e42;
    transition: margin-left 0.1s ease-in-out;
}

#left-sidebar.collapsed {
    margin-left: -250px;
    /* Hide sidebar */
    display: none;
    /* simple hide for now */
}

.sidebar-header {
    padding: 10px 20px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #bbbbbb;
}

#file-list {
    flex: 1;
    overflow-y: auto;
}

.file-item {
    padding: 5px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #cccccc;
}

.file-item:hover {
    background-color: #2a2d2e;
}

.file-item.active {
    background-color: #37373d;
    color: #ffffff;
}

.file-icon {
    margin-right: 8px;
    width: 16px;
    text-align: center;
}

/* --- EDITOR AREA STYLES --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-split-view {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#editor-container {
    flex: 2;
    position: relative;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #3e3e42;
}

#editor {
    flex: 1;
    position: relative;
}

/* OVERRIDE ACE POSITIONING */
#editor>.ace_editor {
    position: absolute !important;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

#sidebar-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #1e1e1e;
    min-width: 200px;
}

.panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    border-bottom: 1px solid #3e3e42;
}

.panel-header {
    background-color: #252526;
    padding: 5px 10px;
    font-weight: bold;
    font-size: 0.9rem;
    border-bottom: 1px solid #3e3e42;
    border-top: 1px solid #3e3e42;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#output {
    flex: 1;
    background-color: #1e1e1e;
    color: #cccccc;
    padding: 10px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    border-bottom: 1px solid #3e3e42;
}

#serial-monitor {
    flex: 1;
    background-color: #000;
    color: #00ff00;
    padding: 10px;
    overflow-y: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.status-ok {
    color: #4caf50;
}

.status-err {
    color: #f44336;
}

.input-row {
    display: flex;
    padding: 5px;
    background: #333;
}

.input-row input {
    flex: 1;
    padding: 5px;
}

.input-row button {
    padding: 5px;
    font-size: 0.8rem;
}

select {
    background: #3c3c3c;
    color: white;
    border: 1px solid #3e3e42;
    padding: 5px;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* TAB BAR STYLES */
.tab-bar {
    height: 35px;
    background-color: #252526;
    display: flex;
    align-items: center;
    overflow-x: auto;
    border-bottom: 1px solid #1e1e1e;
}

.tab {
    padding: 0 15px;
    height: 35px;
    display: flex;
    align-items: center;
    background-color: #2d2d2d;
    color: #969696;
    cursor: pointer;
    border-right: 1px solid #1e1e1e;
    font-size: 13px;
    white-space: nowrap;
}

.tab.active {
    background-color: #1e1e1e;
    color: #fff;
    border-top: 2px solid #00979d;
}

.tab:hover {
    color: #fff;
}

.tab-close {
    margin-left: 8px;
    font-size: 14px;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-close:hover {
    background-color: #4e4e4e;
}

/* Utilities */
.icon-btn {
    background: none;
    border: none;
    color: #cccccc;
    cursor: pointer;
    font-size: 14px;
}

.icon-btn:hover {
    color: white;
}

#floating-format-btn {
    position: absolute;
    top: 40px;
    /* Below tab bar (35px) */
    right: 20px;
    z-index: 20;
    /* Above editor */
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    padding: 0;
}

#floating-format-btn:hover {
    opacity: 1.0;
}

/* --- STATUS BAR --- */
#status-bar {
    height: 22px;
    background-color: #007acc;
    /* VS Code blue-ish */
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    font-size: 12px;
    user-select: none;
}

#status-left {
    display: flex;
    align-items: center;
}

#status-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- MODAL --- */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #252526;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #3e3e42;
    width: 60%;
    min-width: 500px;
    height: 80%;
    color: #cccccc;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}

.modal-header {
    padding: 15px;
    border-bottom: 1px solid #3e3e42;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1e1e1e;
}

.lib-tabs {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.lib-tab {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 14px;
    padding-bottom: 5px;
    border-bottom: 2px solid transparent;
}

.lib-tab:hover {
    color: white;
}

.lib-tab.active {
    color: white;
    border-bottom: 2px solid #9c27b0;
    font-weight: bold;
}

.lib-view {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: white;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.modal-body {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.search-bar input {
    flex: 1;
    padding: 8px;
    background-color: #3c3c3c;
    border: 1px solid #3e3e42;
    color: white;
    border-radius: 4px;
}

#lib-results {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #3e3e42;
    background-color: #1e1e1e;
    padding: 10px;
}

.lib-item {
    background-color: #2d2d2d;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    border: 1px solid #3e3e42;
}

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

.lib-name {
    font-weight: bold;
    color: #4caf50;
    font-size: 1.1em;
}

.lib-version {
    color: #888;
    font-size: 0.9em;
}

.lib-desc {
    font-size: 0.95em;
    color: #ccc;
    margin-bottom: 5px;
}

.lib-author {
    font-size: 0.85em;
    color: #888;
    font-style: italic;
}