/* ============================================================
   h5note.css - Notepad++ 风格编辑器样式
   ============================================================ */

/* ---------- Menu Bar ---------- */
.hn-menubar {
  display: flex;
  background: #fafbfd;
  border: 1px solid #e0e4ea;
  border-bottom: 1px solid #d4d9e0;
  border-radius: 8px 8px 0 0;
  overflow: visible;
  margin-top: 12px;
  position: relative;
  z-index: 500;
}
.hn-menu { position: relative; }
.hn-menu-label {
  display: block;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #3a4450;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 5px;
  margin: 2px 1px;
  transition: background 0.12s, color 0.12s;
}
.hn-menu-label:hover,
.hn-menu.open .hn-menu-label { background: #e8ecf2; color: #1e293b; }
.hn-menu-drop {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  background: #fff;
  border: 1px solid #d4d9e0;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
  padding: 4px 0;
  z-index: 510;
}
.hn-menu.open .hn-menu-drop { display: block; }
.hn-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  font-size: 0.78rem;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.hn-menu-item:hover { background: #f1f5f9; color: #7c3aed; }
.hn-menu-item kbd {
  margin-left: 24px;
  font-size: 0.68rem;
  color: #94a3b8;
  font-family: inherit;
  font-weight: 400;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}
.hn-menu-item .hn-check {
  margin-left: 10px;
  color: #27ae60;
  font-size: 0.7rem;
  font-weight: 700;
}
.hn-menu-sep {
  height: 1px;
  margin: 4px 10px;
  background: #e8ecf0;
}

/* ---------- Tab Bar ---------- */
.hn-tabbar {
  display: flex;
  align-items: center;
  background: #eef1f5;
  border: 1px solid #e0e4ea;
  border-top: none;
  padding: 0 8px;
  gap: 2px;
  overflow: hidden;
}
.hn-tab {
  padding: 5px 16px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #7a8490;
  cursor: pointer;
  background: #e0e3ea;
  border-radius: 6px 6px 0 0;
  margin-top: 2px;
  transition: all 0.15s;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}
.hn-tab:hover { color: #4a5568; background: #d2d6df; }
.hn-tab.active {
  color: #1e293b;
  background: #fff;
  border: 1px solid #d4d9e0;
  border-bottom: 1px solid #fff;
  margin-bottom: -1px;
}
.hn-filename {
  margin-left: 12px;
  font-size: 0.72rem;
  color: #7c3aed;
  font-weight: 600;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hn-status {
  margin-left: auto;
  font-size: 0.66rem;
  color: #8a9baa;
  white-space: nowrap;
  padding-right: 8px;
}

/* ---------- Panels ---------- */
.hn-panels { position: relative; }
.hn-panel { display: none; }
.hn-panel.active { display: block; }

/* ---------- Editor ---------- */
.hn-editor-wrap {
  display: flex;
  background: #fff;
  border: 1px solid #d4d9e0;
  border-top: none;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  min-height: 340px;
  max-height: 52vh;
}
.hn-line-numbers {
  width: 46px;
  flex-shrink: 0;
  background: #f2f3f6;
  border-right: 1px solid #e4e7ed;
  text-align: right;
  padding: 8px 8px 8px 6px;
  font-family: "SF Mono","Consolas","Monaco",monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  color: #b4bac6;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.hn-line-numbers div { line-height: 1.7; }

.hn-editor-container {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.hn-editor-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 8px 14px;
  margin: 0;
  border: none;
  outline: none;
  font-family: "SF Mono","Consolas","Monaco","Courier New",monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  color: #2c3e50;
  background: transparent;
  white-space: pre;
  overflow-wrap: normal;
  overflow: auto;
  pointer-events: none;
  z-index: 0;
  tab-size: 2;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.hn-editor-layer::-webkit-scrollbar { display: none; }
.hn-editor-layer.wrap {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.hn-editor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  resize: none;
  padding: 8px 14px;
  font-family: "SF Mono","Consolas","Monaco","Courier New",monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  color: transparent;
  caret-color: #2c3e50;
  background: transparent;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow: auto;
}
.hn-editor::placeholder { color: #b0bec5; }
.hn-editor:focus { outline: none; box-shadow: none; }
.hn-editor.wrap { white-space: pre-wrap; overflow-wrap: break-word; }
.hn-editor::selection { background: rgba(124, 58, 237, 0.25); }

/* Light theme tokens for editor layer */
.hn-editor-layer .hn-cmt  { color: #008000; font-style: italic; }
.hn-editor-layer .hn-str  { color: #a31515; }
.hn-editor-layer .hn-kw   { color: #0000ff; font-weight: 600; }
.hn-editor-layer .hn-num  { color: #098658; }
.hn-editor-layer .hn-br   { color: #0000ff; }
.hn-editor-layer .hn-tag  { color: #0000ff; }
.hn-editor-layer .hn-atr  { color: #ff0000; }
.hn-editor-layer .hn-prop { color: #0000ff; }
.hn-editor-layer .hn-val  { color: #098658; }

/* ---------- Highlight Panel ---------- */
.hn-highlight-wrap {
  background: #1e1e2e;
  border: 1px solid #2a2a3e;
  border-top: none;
  border-radius: 0 0 8px 8px;
  overflow: auto;
  min-height: 340px;
  max-height: 52vh;
}
.hn-highlight {
  margin: 0;
  padding: 14px;
  font-family: "SF Mono","Consolas","Monaco",monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  color: #cdd6f4;
  white-space: pre-wrap;
}

/* Tokens */
.hn-cmt { color: #6c7086; font-style: italic; }
.hn-str { color: #a6e3a1; }
.hn-kw  { color: #cba6f7; font-weight: 600; }
.hn-num { color: #fab387; }
.hn-br  { color: #89b4fa; }
.hn-tag { color: #89b4fa; }
.hn-atr { color: #f9e2af; }
.hn-prop { color: #89b4fa; }
.hn-val  { color: #a6e3a1; }

/* ---------- JSON Tree Panel ---------- */
.hn-tree-wrap {
  background: #1e1e2e;
  border: 1px solid #2a2a3e;
  border-top: none;
  border-radius: 0 0 8px 8px;
  overflow: auto;
  min-height: 340px;
  max-height: 52vh;
}
.hn-tree {
  padding: 14px;
  font-family: "SF Mono","Consolas",monospace;
  font-size: 0.8rem;
  line-height: 1.75;
  color: #cdd6f4;
}
.hn-tree-children { margin-left: 20px; }
.hn-tree-toggle {
  display: inline-block; width: 16px; text-align: center;
  cursor: pointer; color: #6c7086; user-select: none;
  margin-right: 4px; font-size: 0.75rem;
}
.hn-tree-toggle:hover { color: #a78bfa; }
.hn-tree-bracket { color: #89b4fa; }
.hn-tree-key { color: #f9e2af; }
.hn-tree-str { color: #a6e3a1; }
.hn-tree-num { color: #fab387; }
.hn-tree-bool { color: #cba6f7; }
.hn-tree-null { color: #6c7086; }
.hn-tree-count { color: #585b70; font-size: 0.72rem; margin-left: 6px; }
.hn-tree-index { color: #585b70; font-size: 0.72rem; }
.hn-tree-item { padding: 1px 0; }
.hn-tree-error { color: #f38ba8; padding: 20px; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .h5-main { padding-top: 90px; display: flex; flex-direction: column; min-height: 100vh; }
  .hn-panels { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .hn-panel { display: none; flex: 1; min-height: 0; }
  .hn-panel.active { display: flex; flex-direction: column; }
  .hn-menubar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    margin-top: 4px;
    border-radius: 6px 6px 0 0;
    flex-shrink: 0;
  }
  .hn-tabbar { flex-shrink: 0; }
  .hn-menu-label { padding: 5px 10px; font-size: 0.72rem; }
  .hn-menu-drop { position: fixed; left: 8px; right: 8px; top: auto; min-width: 0; border-radius: 8px; }
  .hn-tab { padding: 4px 12px; font-size: 0.72rem; }
  .hn-editor-wrap { max-height: none; flex: 1; min-height: 260px; }
  .hn-editor { font-size: 0.78rem; }
  .hn-line-numbers { width: 34px; font-size: 0.7rem; }
  .hn-filename { display: none; }
  .hn-highlight-wrap,
  .hn-tree-wrap { max-height: none; flex: 1; min-height: 260px; }
}

/* ---------- Stats Modal ---------- */
.hn-modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.hn-modal-overlay.open { display: flex; }
.hn-modal {
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.hn-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e8ecf1;
  flex-shrink: 0;
}
.hn-modal-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  color: #2c3e50;
  margin: 0;
}
.hn-modal-close {
  width: 32px; height: 32px;
  border: none;
  background: #f0f2f5;
  border-radius: 8px;
  font-size: 1.2rem;
  color: #8a9baa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.hn-modal-close:hover { background: #e8ecf1; color: #2c3e50; }
.hn-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Stats sections */
.hn-stats-section {
  margin-bottom: 20px;
}
.hn-stats-section:last-child { margin-bottom: 0; }
.hn-stats-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #7c3aed;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(124,58,237,0.12);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.hn-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.hn-stats-item {
  background: #f8f9fb;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.hn-stats-item .hn-stats-val {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2c3e50;
}
.hn-stats-item .hn-stats-lbl {
  font-size: 0.65rem;
  color: #8a9baa;
  margin-top: 2px;
  text-transform: uppercase;
}

/* Language detection */
.hn-detect-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f8f9fb;
  border-radius: 8px;
  margin-bottom: 8px;
}
.hn-detect-lang {
  font-weight: 700;
  font-size: 0.9rem;
  color: #2c3e50;
}
.hn-detect-pct {
  font-size: 0.72rem;
  color: #8a9baa;
  margin-left: 4px;
}
.hn-detect-rank {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}
.hn-detect-rank-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: #5a6c7d;
}
.hn-detect-rank-item .rank-bar {
  width: 40px;
  height: 4px;
  background: #e8ecf1;
  border-radius: 2px;
  overflow: hidden;
}
.hn-detect-rank-item .rank-fill {
  height: 100%;
  background: #7c3aed;
  border-radius: 2px;
}

/* Frequency table */
.hn-freq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.hn-freq-table th {
  text-align: left;
  padding: 6px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #8a9baa;
  text-transform: uppercase;
  border-bottom: 1px solid #e8ecf1;
}
.hn-freq-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #f0f2f5;
}
.hn-freq-table .freq-num {
  width: 1%;
  white-space: nowrap;
  color: #7c3aed;
  font-weight: 600;
  font-size: 0.72rem;
}
.hn-freq-table .freq-bar-wrap {
  width: 30%;
}
.hn-freq-table .freq-bar {
  height: 6px;
  background: #e8ecf1;
  border-radius: 3px;
  overflow: hidden;
}
.hn-freq-table .freq-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  border-radius: 3px;
}
.hn-freq-table .freq-word {
  font-family: "SF Mono","Consolas",monospace;
  color: #2c3e50;
  font-size: 0.76rem;
}

@media (max-width: 480px) {
  .h5-main { padding-top: 84px; display: flex; flex-direction: column; min-height: 100vh; }
  .hn-panels { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .hn-panel { display: none; flex: 1; min-height: 0; }
  .hn-panel.active { display: flex; flex-direction: column; }
  .hn-menubar { border-radius: 4px 4px 0 0; flex-shrink: 0; }
  .hn-tabbar { flex-shrink: 0; }
  .hn-menu-label { padding: 4px 8px; font-size: 0.68rem; }
  .hn-tab { padding: 3px 10px; font-size: 0.68rem; }
  .hn-status { font-size: 0.6rem; padding-right: 4px; }
  .hn-editor-wrap,
  .hn-highlight-wrap,
  .hn-tree-wrap { max-height: none; min-height: 200px; border-radius: 0 0 4px 4px; flex: 1; }
  .hn-modal { max-width: 100%; border-radius: 8px; }
  .hn-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
