:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --border-color: #d1d5db;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --editor-bg: #ffffff;
    --line-num-bg: #f9fafb;
    --line-num-color: #9ca3af;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dark-mode {
    --bg-primary: #18181b;
    --bg-secondary: #27272a;
    --bg-tertiary: #3f3f46;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --border-color: #3f3f46;
    --accent-color: #3b82f6;
    --accent-hover: #60a5fa;
    --editor-bg: #18181b;
    --line-num-bg: #27272a;
    --line-num-color: #71717a;
}

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

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

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
    flex-wrap: wrap;
}

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

.toolbar-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 8px;
}

.spacer {
    flex-grow: 1;
}

.tool-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    transition: background-color 0.2s, transform 0.1s;
}

.tool-btn:hover {
    background-color: var(--bg-tertiary);
}

.tool-btn:active {
    transform: scale(0.95);
}

.tool-select {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.tool-select:focus {
    border-color: var(--accent-color);
}

/* Tabs */
.tabs-container {
    display: flex;
    align-items: center;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    padding: 0 12px;
}

.tabs-container::-webkit-scrollbar {
    height: 4px;
}
.tabs-container::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
}

.tabs-list {
    display: flex;
    align-items: flex-end;
}

.tab {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    margin-right: -1px;
    margin-top: 8px;
    cursor: pointer;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    user-select: none;
    min-width: 120px;
    max-width: 200px;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

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

.tab.active {
    background-color: var(--editor-bg);
    color: var(--text-primary);
    padding-bottom: 9px;
    margin-bottom: -1px;
    border-bottom: 1px solid var(--editor-bg);
    font-weight: 500;
    z-index: 2;
}

.tab-close {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.tab-close:hover {
    background-color: rgba(220, 38, 38, 0.1);
    color: #ef4444;
}

.add-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-left: 8px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-tab-btn:hover {
    background-color: var(--bg-tertiary);
}

/* Editor Area */
.editor-container {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    position: relative;
    background-color: var(--editor-bg);
}

.line-numbers {
    width: 50px;
    background-color: var(--line-num-bg);
    color: var(--line-num-color);
    text-align: right;
    padding: 16px 8px 16px 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    line-height: 1.5;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    user-select: none;
}

#main-editor {
    flex-grow: 1;
    background-color: transparent;
    color: var(--text-primary);
    border: none;
    outline: none;
    padding: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    white-space: pre;
    overflow: auto;
}

#main-editor.wrap-on {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Quick Notes Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar.hidden {
    display: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
}

.sidebar-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
}

.sidebar-header button {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.2rem;
}

.sidebar-content {
    padding: 0 12px 12px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#quick-notes-editor {
    flex-grow: 1;
    width: 100%;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 0.85rem;
}

.recent-files-list {
    list-style: none;
    padding: 0;
    overflow-y: auto;
    max-height: 150px;
}

.recent-files-list li {
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    border-top: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-files-list li:hover {
    background-color: var(--bg-tertiary);
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 16px;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: inherit;
}

.status-left, .status-right {
    display: flex;
    gap: 8px;
}

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 10;
        box-shadow: var(--shadow-md);
    }
}
