/* Notepad++ Web - Main Stylesheet */

/* ==================== Design System & Variables ==================== */
:root {
  /* Common variables */
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-code: 'Fira Code', Consolas, Monaco, monospace;
  --transition-speed: 0.15s;
  
  /* Light Mode Theme (Default Notepad++ look modernized) */
  --bg-primary: #f0f4f9;        /* Windows-like clean background */
  --bg-secondary: #ffffff;      /* Editor & Main Canvas */
  --bg-active: #dce3eb;         /* Hover state */
  --bg-menu: #f8fafc;           /* Dropdown menus */
  --border-color: #cbd5e1;      /* Thin grey grid borders */
  --text-primary: #1e293b;      /* Main text */
  --text-secondary: #64748b;    /* Subtext / Shortcuts */
  --accent-color: #2563eb;      /* Active state highlight */
  --accent-hover: #1d4ed8;
  --tab-bg: #e2e8f0;            /* Inactive tab */
  --tab-active: #ffffff;        /* Active tab */
  --sidebar-bg: #f8fafc;
  --status-bg: #e2e8f0;
  --dialog-header-bg: linear-gradient(180deg, #f1f5f9 0%, #cbd5e1 100%);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.15);
  
  /* Unsaved/Dirty states */
  --color-dirty: #ef4444;       /* Red for modified file disk icon */
  --color-clean: #10b981;       /* Green/Blue for saved disk icon */
}

/* Dark Mode Theme Overlay */
body.dark-mode {
  --bg-primary: #1e1e24;        /* Dark slate background */
  --bg-secondary: #121214;      /* Deep dark editor canvas */
  --bg-active: #2a2a35;         /* Active/Hover states */
  --bg-menu: #18181c;           /* Dropdown menus dark */
  --border-color: #3f3f46;      /* Slate grey borders */
  --text-primary: #f4f4f5;      /* Crisp light text */
  --text-secondary: #a1a1aa;    /* Dimmed shortcuts */
  --accent-color: #3b82f6;      /* Cyber blue accent */
  --accent-hover: #60a5fa;
  --tab-bg: #18181c;            /* Dark inactive tab */
  --tab-active: #121214;        /* Active dark tab matches editor */
  --sidebar-bg: #151518;
  --status-bg: #18181c;
  --dialog-header-bg: linear-gradient(180deg, #27272a 0%, #18181b 100%);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
}

/* ==================== Reset & Global Styles ==================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

kbd {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font-ui);
  font-size: 11px;
}

/* ==================== Main Window Structure ==================== */
#app-window {
  display: flex;
  flex-direction: column;
  height: 100vh;
  border: 1px solid var(--border-color);
}

/* 1. Custom Title Bar */
#window-titlebar {
  height: 32px;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
}

.titlebar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.npp-logo {
  font-size: 16px;
}

.titlebar-right {
  display: flex;
  gap: 1px;
}

.window-control {
  border: none;
  background: transparent;
  width: 32px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  transition: background-color var(--transition-speed);
}

.window-control:hover {
  background-color: var(--bg-active);
}

.window-control.close:hover {
  background-color: #ef4444;
  color: white;
}

/* 2. Menu Bar */
#menu-bar {
  height: 28px;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 6px;
  z-index: 100;
}

.menu-item {
  position: relative;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color var(--transition-speed);
}

.menu-item:hover, .menu-item.active {
  background-color: var(--bg-active);
}

/* Dropdown Menus */
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--bg-menu);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  border-radius: 4px;
  min-width: 220px;
  padding: 4px 0;
  z-index: 200;
  margin-top: 1px;
}

.menu-item:hover .dropdown-menu {
  display: block;
}

.dropdown-item {
  padding: 6px 16px 6px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.dropdown-item:hover {
  background-color: var(--accent-color);
  color: white !important;
}

.dropdown-item .shortcut {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: 20px;
}

.dropdown-item:hover .shortcut {
  color: rgba(255, 255, 255, 0.8);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

/* Scrollable dropdown for language list */
.dropdown-menu.scrollable {
  max-height: 300px;
  overflow-y: auto;
}

/* Checkbox & Radio Indicators in Menus */
.dropdown-item.checkbox::before {
  content: "";
  position: absolute;
  left: 8px;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  border: 1px solid var(--text-primary);
}

.dropdown-item.checkbox.active::before {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

.dropdown-item.checkbox.active:hover::before {
  background-color: white;
  border-color: white;
}

.dropdown-item.radio::before {
  content: "";
  position: absolute;
  left: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid var(--text-primary);
}

.dropdown-item.radio.active::before {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

.dropdown-item.radio.active:hover::before {
  background-color: white;
  border-color: white;
}

/* Dropdown Submenus */
.dropdown-submenu-parent {
  position: relative;
  padding: 6px 16px 6px 24px;
  cursor: pointer;
}

.dropdown-submenu-parent::after {
  content: "▶";
  font-size: 8px;
  float: right;
  margin-top: 3px;
}

.dropdown-submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background-color: var(--bg-menu);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  border-radius: 4px;
  min-width: 200px;
  padding: 4px 0;
}

.dropdown-submenu-parent:hover {
  background-color: var(--accent-color);
  color: white;
}

.dropdown-submenu-parent:hover .dropdown-submenu {
  display: block;
}

/* 3. Toolbar Styles */
#toolbar {
  height: 36px;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 2px;
}

.toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.toolbar-btn:hover {
  background-color: var(--bg-active);
  border-color: var(--border-color);
}

.toolbar-btn:active {
  background-color: var(--border-color);
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background-color: var(--border-color);
  margin: 0 4px;
}

/* Toolbar icon colors based on theme */
body.dark-mode .toolbar-btn svg {
  stroke: var(--text-primary);
}

body.light-mode .toolbar-btn svg {
  stroke: var(--text-secondary);
}

.toolbar-btn:hover svg {
  stroke: var(--accent-color) !important;
}

/* ==================== 4. Main Workspace Layout ==================== */
#workspace {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* 4A. Left Sidebar */
#sidebar {
  width: 240px;
  min-width: 150px;
  max-width: 500px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width 0.05s linear;
}

#sidebar-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 50;
}

.sidebar-header {
  height: 32px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
}

.icon-btn:hover {
  background-color: var(--bg-active);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* Virtual Workspace Folder Tree */
.file-tree {
  font-family: var(--font-ui);
}

.tree-node {
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1px;
}

.tree-node:hover {
  background-color: var(--bg-active);
}

.tree-node.selected {
  background-color: var(--accent-color);
  color: white;
}

.tree-node.selected svg {
  stroke: white;
}

.tree-node-children {
  padding-left: 16px;
}

.tree-node .node-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 4B. Center Editor Area */
#editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
  overflow: hidden;
}

/* Tab Bar */
#tab-bar-container {
  height: 32px;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#tab-bar {
  display: flex;
  height: 100%;
  overflow-x: auto;
  align-items: flex-end;
  flex: 1;
}

/* Custom Scrollbar for tab bar */
#tab-bar::-webkit-scrollbar {
  height: 3px;
}

#tab-bar::-webkit-scrollbar-thumb {
  background: var(--border-color);
}

.npp-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  background-color: var(--tab-bg);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  padding: 0 10px;
  margin-left: 2px;
  cursor: pointer;
  max-width: 150px;
  position: relative;
  transition: background-color var(--transition-speed);
}

.npp-tab:hover {
  background-color: var(--bg-active);
}

.npp-tab.active {
  background-color: var(--tab-active);
  border-top: 2px solid var(--accent-color);
  height: 30px;
  font-weight: 500;
  z-index: 10;
}

.tab-icon-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--color-clean);
}

.npp-tab.dirty .tab-icon-status {
  background-color: var(--color-dirty);
}

.tab-title {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-close-btn {
  background: transparent;
  border: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  cursor: pointer;
}

.tab-close-btn:hover {
  background-color: #ef4444;
  color: white;
}

#btn-new-tab {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#btn-new-tab:hover {
  background-color: var(--bg-active);
}

/* Editor Wrapper & CodeMirror Customizations */
#editor-splitter-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

#editor-wrapper {
  flex: 1;
  position: relative;
  height: 100%;
}

.CodeMirror {
  height: 100% !important;
  font-family: var(--font-code) !important;
  font-size: 14px; /* Dynamically adjusted via Preferences */
}

/* Match Notepad++ default styles for line gutters */
.CodeMirror-gutters {
  background-color: var(--bg-primary) !important;
  border-right: 1px solid var(--border-color) !important;
}

.CodeMirror-linenumber {
  color: var(--text-secondary) !important;
}

/* 4C. Document Map / Minimap (Right Sidebar) */
#minimap-container {
  width: 120px;
  background-color: var(--sidebar-bg);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
}

.minimap-header {
  height: 32px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.minimap-viewport-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#minimap-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#minimap-slider {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background-color: rgba(37, 99, 235, 0.15);
  border: 1.5px solid var(--accent-color);
  cursor: grab;
  z-index: 20;
}

#minimap-slider:active {
  cursor: grabbing;
}

/* Code Runner Live Preview Pane */
#preview-pane {
  height: 250px;
  background-color: var(--bg-primary);
  border-top: 3px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
}

#preview-pane.collapsed {
  display: none;
}

#preview-resizer {
  position: absolute;
  top: -3px;
  left: 0;
  width: 100%;
  height: 6px;
  cursor: row-resize;
  z-index: 50;
}

.preview-header {
  height: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  font-weight: 500;
  background-color: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-color);
}

.preview-content {
  flex: 1;
  display: flex;
}

#preview-frame {
  flex: 1;
  border: none;
  background-color: white;
}

#console-output {
  flex: 1;
  background-color: #1e1e1e;
  color: #a8ff60;
  font-family: var(--font-code);
  font-size: 12px;
  padding: 10px;
  overflow-y: auto;
  border-left: 1px solid var(--border-color);
  white-space: pre-wrap;
}

/* ==================== 5. Status Bar ==================== */
#status-bar {
  height: 24px;
  background-color: var(--status-bg);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  font-size: 11px;
}

.status-panel {
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#status-lang { width: 180px; }
#status-stats { width: 220px; }
#status-pos { flex: 1; }
#status-eol { width: 140px; }
#status-encoding { width: 80px; }
#status-mode { width: 50px; border-right: none; }

/* ==================== Dialog Overlays ==================== */
.npp-dialog {
  position: absolute;
  background-color: var(--bg-menu);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  width: 420px;
  max-width: 90%;
  overflow: hidden;
}

.npp-dialog.mini-dialog {
  width: 320px;
}

.dialog-header {
  padding: 8px 12px;
  background: var(--dialog-header-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
}

.dialog-title {
  font-weight: 600;
  font-size: 12px;
}

.dialog-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
}

.dialog-body {
  padding: 14px;
}

.dialog-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.dialog-tab {
  padding: 6px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-size: 12px;
  border-bottom: 2px solid transparent;
}

.dialog-tab.active {
  border-bottom-color: var(--accent-color);
  color: var(--accent-color);
  font-weight: 600;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.form-row {
  margin-bottom: 10px;
}

.form-row.flex {
  display: flex;
  gap: 12px;
}

.form-group {
  flex: 1;
}

.form-row label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
}

.dialog-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  border-radius: 4px;
  outline: none;
}

.dialog-input:focus {
  border-color: var(--accent-color);
}

.dialog-grid {
  display: flex;
  gap: 16px;
  margin-top: 14px;
}

.dialog-options {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.dialog-buttons {
  width: 120px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dialog-btn {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-primary);
  cursor: pointer;
  transition: all var(--transition-speed);
}

.dialog-btn:hover {
  background-color: var(--bg-active);
}

.dialog-btn.primary {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.dialog-btn.primary:hover {
  background-color: var(--accent-hover);
}

.dialog-button-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.dialog-status {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
}

.pref-section {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.pref-section h3 {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.text-center {
  text-align: center;
}

.about-logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.copyright {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 16px;
}

/* Keyboard Shortcuts Table */
.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.shortcuts-table th, .shortcuts-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.shortcuts-table th {
  font-weight: 600;
  background-color: var(--bg-primary);
}

/* Context Menu */
.context-menu {
  position: absolute;
  background-color: var(--bg-menu);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 4px 0;
  min-width: 140px;
  z-index: 1000;
}

.context-item {
  padding: 6px 12px;
  cursor: pointer;
}

.context-item:hover {
  background-color: var(--accent-color);
  color: white;
}

.context-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

/* Utility Classes */
.scrollable-y {
  overflow-y: auto;
}
