/* 基础主题变量 */
:root {
  --bg-color: #f5f5f5;
  --bg-elevated: #ffffff;
  --text-color: #222222;
  --border-color: #dddddd;
  --accent-color: #3b82f6;
}

body.dark-theme {
  --bg-color: #111827;
  --bg-elevated: #1f2933;
  --text-color: #e5e7eb;
  --border-color: #374151;
  --accent-color: #60a5fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding-top: 3rem;
  /* 预留头部高度，大约 48px，多一点没关系 */
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
}


/* 总布局 */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background-color: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
  position: fixed;
  /* 固定在窗口顶部 */
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}


.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* 日期 + 时间的小胶囊 */
.header-datetime {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  background-color: rgba(148, 163, 184, 0.15);
  color: var(--text-color, #0f172a);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.header-date {
  opacity: 0.9;
}

.header-dot {
  font-size: 0.7rem;
  opacity: 0.6;
}

.header-time {
  font-variant-numeric: tabular-nums;
}

/* 深色模式适配（如果你有 data-theme 或类似开关） */
[data-theme="dark"] .header-datetime {
  background-color: rgba(148, 163, 184, 0.25);
  color: #e5e7eb;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.5);
}

/* 小屏幕适当缩小一点 */
@media (max-width: 600px) {
  .header-datetime {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
  }
}

/* 按钮 */

.icon-button,
.theme-toggle {
  border: none;
  background: none;
  color: var(--text-color);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover,
.theme-toggle:hover {
  background-color: rgba(148, 163, 184, 0.2);
}

/* 内容布局：侧栏 + 主区域 */

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar */

/* ===== Sidebar ===== */

.sidebar {
  min-width: 220px;
  max-width: 260px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-color);
  padding: 0.9rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: sticky;
  top: 56px;
  /* 如果你的 header 高度不是 56px，可以微调 */
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted, #94a3b8);
  padding: 0 0.4rem;
  margin-bottom: 0.15rem;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-item {
  margin: 0;
}

/* 侧边栏链接通用样式 */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.65rem;
  font-size: 0.9rem;
  line-height: 1.3;
  color: var(--text-color, #0f172a);
  text-decoration: none;
  position: relative;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    transform 0.08s ease,
    box-shadow 0.15s ease;
}

/* 左侧小色条，做一点视觉引导 */
.nav-link::before {
  content: "";
  width: 4px;
  height: 70%;
  border-radius: 999px;
  background-color: transparent;
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  transition: background-color 0.15s ease;
}

/* hover 效果 */
.nav-link:hover {
  background-color: rgba(148, 163, 184, 0.18);
  transform: translateX(1px);
}

/* 当前激活状态（根据你的 JS，可能是 active 或 is-active，都加上） */
.nav-link.active,
.nav-link.is-active {
  background: rgba(59, 130, 246, 0.12);
  /* 轻微蓝色高亮，可结合你自己的 accent 色 */
  color: var(--accent-color, #2563eb);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.nav-link.active::before,
.nav-link.is-active::before {
  background-color: var(--accent-color, #2563eb);
}

/* 深色模式下稍微调暗一点（如果你有 data-theme 或 .dark，可以适配） */
[data-theme="dark"] .sidebar {
  border-right-color: rgba(148, 163, 184, 0.25);
}

[data-theme="dark"] .nav-link:hover {
  background-color: rgba(148, 163, 184, 0.15);
}

/* 小屏幕时 sidebar 收窄一点 */
@media (max-width: 900px) {
  .sidebar {
    position: static;
    height: auto;
    min-width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
  }

  .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .nav-link {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
  }

  .nav-link::before {
    display: none;
  }
}


/* Main 内容 */

.main {
  flex: 1;
  padding: 1.25rem 1.5rem 2.5rem;
  /* max-width: 960px; */
}

.main h1 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.main p {
  line-height: 1.6;
}

/* Footer */

.app-footer {
  margin-top: auto;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  font-size: 0.85rem;
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-link {
  text-decoration: none;
  color: var(--text-color);
  opacity: 0.8;
}

.footer-link:hover {
  opacity: 1;
  text-decoration: underline;
}

/* 移动端 */

@media (max-width: 768px) {
  .app-body {
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 3rem;
    bottom: 2.5rem;
    left: 0;
    transform: translateX(-100%);
    max-width: 80%;
    z-index: 20;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .main {
    padding: 1rem 1rem 2.5rem;
  }
}

/* 菜单按钮只在移动端显示 */

.menu-button {
  display: none;
}

@media (max-width: 768px) {
  .menu-button {
    display: inline-flex;
  }
}


/* ===== JSON Formatter tool layout ===== */

.tool-layout {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  /* 关键：拉齐高度 */
  margin-bottom: 1.5rem;
  flex-wrap: nowrap;
}

.tool-column {
  flex: 1;
  display: flex;
  flex-direction: column;
}


.field-label {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-bottom: 0.25rem;
  display: block;
}

.code-area,
.code-output {
  width: 100%;
  min-height: 620px;
  /* 可以按自己屏幕高度调 */
  border-radius: 0.5rem;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  color: var(--text-color);
  resize: none;
  /* 不允许手动拉伸 */
  flex: 1;
  /* 在列中填满高度 */
  overflow: auto;
}


.code-output {
  white-space: pre-wrap;
  overflow: auto;
}

/* 错误状态 */
.code-output.error {
  color: #b91c1c;
  border-color: #f97373;
  background-color: rgba(248, 113, 113, 0.08);
}

/* 中间竖排按钮区 */

.tool-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  justify-content: flex-start;
  /* 从顶部开始排，不再居中 */
  align-items: stretch;
  margin-top: 1.5rem;
  /* 稍微往下挪一点，对齐上面的 label */
}


.primary-button,
.secondary-button {
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
}

.primary-button {
  background-color: var(--accent-color);
  color: #ffffff;
}

.primary-button:hover {
  filter: brightness(1.05);
}

.secondary-button {
  background-color: transparent;
  color: var(--text-color);
  border-color: var(--border-color);
}

.secondary-button:hover {
  background-color: rgba(148, 163, 184, 0.2);
}

/* 输出头部（label + copy 按钮） */

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.copy-button {
  font-size: 0.9rem;
}

/* 使用指南 */

.usage-section {
  margin-top: 2rem;
}

.usage-section h2 {
  margin-bottom: 0.5rem;
}

.usage-section ol {
  padding-left: 1.25rem;
}

.usage-section li {
  margin-bottom: 0.35rem;
  line-height: 1.6;
}

.usage-section p {
  margin-top: 0.75rem;
  line-height: 1.6;
}

/* 移动端：上下排列 */

@media (max-width: 900px) {
  .tool-layout {
    flex-direction: column;
  }

  .tool-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    justify-content: flex-start;
    /* 从顶部开始排，不再居中 */
    align-items: stretch;
    margin-top: 1.5rem;
    /* 稍微往下挪一点，对齐上面的 label */
  }


  .tool-buttons .primary-button,
  .tool-buttons .secondary-button {
    flex: 0 0 auto;
  }
}


/* ===== JSON viewer with colors & collapsible ===== */

.json-viewer {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.9rem;
  white-space: pre;
}

.json-item {
  display: block;
}

.json-children {
  /* 默认展开 */
}

.json-children.collapsed {
  display: none;
}

.json-toggle {
  display: inline-block;
  width: 1em;
  cursor: pointer;
  user-select: none;
  color: #9ca3af;
}

.json-toggle::before {
  content: "▼";
}

.json-toggle.collapsed::before {
  content: "▶";
}

.json-key {
  color: #2563eb;
  /* 蓝色 key */
}

.json-string {
  color: #16a34a;
  /* 绿色字符串 */
}

.json-number {
  color: #f59e0b;
  /* 橙色数字 */
}

.json-boolean {
  color: #ec4899;
  /* 粉色布尔 */
}

.json-null {
  color: #6b7280;
  /* 灰色 null */
}

.json-bracket {
  color: #9ca3af;
}

.json-comma {
  color: #9ca3af;
}


/* ===== Image to Base64 Tool Layout ===== */

.tool-img-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.tool-img-column {
  flex: 1;
  min-width: 320px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem 1.2rem;
}

.tool-title {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.file-input {
  margin-bottom: 0.75rem;
}

.preview-box {
  border: 1px dashed var(--border-color);
  border-radius: 0.5rem;
  background: var(--bg-color);
  min-height: 180px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
}

.preview-img {
  max-width: 100%;
  max-height: 300px;
  display: none;
}

.placeholder {
  opacity: 0.6;
  font-size: 0.9rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.small-copy {
  padding: 0.2rem 0.35rem;
  font-size: 0.85rem;
}

.small-height {
  min-height: 160px;
}

.mt-1 {
  margin-top: 0.75rem;
}

.mt-2 {
  margin-top: 1.5rem;
}

.size-info {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-bottom: 0.75rem;
}



/* ===== Text Notes Tool ===== */

.notes-layout {
  display: flex;
  gap: 1.25rem;
  align-items: stretch;
  margin-top: 0.75rem;
}

.notes-sidebar {
  width: 220px;
  min-width: 200px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 0.75rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.full-width {
  width: 100%;
}

.notes-list-header {
  font-size: 0.85rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.notes-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  max-height: 420px;
}

.notes-list-item,
.notes-list-empty {
  padding: 0.35rem 0.4rem;
  border-radius: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.notes-list-empty {
  opacity: 0.7;
  cursor: default;
}

.notes-list-item:hover {
  background-color: rgba(148, 163, 184, 0.15);
}

.notes-list-item.active {
  background-color: var(--accent-color);
  color: #ffffff;
}

/* 右侧编辑区域 */

.notes-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.notes-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.note-title-input {
  flex: 1;
  min-width: 180px;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  color: var(--text-color);
  font-size: 0.95rem;
}

.note-title-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.notes-toolbar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* 复用已有 file-input-label / file-input-hidden 样式 */

.small-button {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

.notes-textarea {
  min-height: 620px;
  flex: 1;
}

/* 响应式 */

@media (max-width: 900px) {
  .notes-layout {
    flex-direction: column;
  }

  .notes-sidebar {
    width: 100%;
    max-width: none;
  }
}


/* ===== JWT Decoder Tool ===== */

.jwt-layout {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.jwt-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.jwt-error {
  min-height: 1.2rem;
  font-size: 0.9rem;
  color: #b91c1c;
}

.jwt-panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.jwt-panel {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
}

.jwt-panel-title {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-bottom: 0.25rem;
}

/* 复用 code-output 的样式，如果没有可以用你现有的 .code-output */
.jwt-panel .code-output {
  flex: 1;
  margin: 0;
  white-space: pre-wrap;
}

/* 响应式：小屏幕改两列 / 一列 */

@media (max-width: 1100px) {
  .jwt-panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .jwt-panels {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* URL encoder specific tweaks */
.url-tool-layout .code-area {
  min-height: 240px;
}

.url-tool-buttons {
  margin-top: 1.5rem;
}

/* ===== UUID Generator ===== */

.uuid-layout {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.uuid-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
}

.uuid-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.uuid-count-input {
  width: 80px;
  padding: 0.3rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
  color: var(--text-color);
}

.uuid-checkboxes {
  flex-direction: row;
  align-items: center;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-right: 0.75rem;
  font-size: 0.9rem;
}

.uuid-buttons {
  display: flex;
  gap: 0.5rem;
}

.uuid-output {
  min-height: 220px;
}

/* ===== Base64 Text Tool ===== */

.base64-tool-layout .code-area {
  min-height: 240px;
}

.base64-tool-buttons {
  margin-top: 1.5rem;
}

/* ===== Text Counter Tool ===== */

.text-counter-layout {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 1.25rem;
  align-items: flex-start;
}

.text-counter-input-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.text-counter-actions {
  margin-top: 0.25rem;
  display: flex;
  gap: 0.5rem;
}

.text-counter-summary {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
}

.text-counter-summary-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.text-counter-stats {
  margin: 0;
  padding: 0;
}

.text-counter-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.25rem 0;
  font-size: 0.9rem;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.4);
}

.text-counter-stat-row:last-child {
  border-bottom: none;
}

.text-counter-stat-row dt {
  margin: 0;
  opacity: 0.9;
}

.text-counter-stat-row dd {
  margin: 0;
  font-weight: 600;
}

/* 小屏幕改为上下排布 */
@media (max-width: 900px) {
  .text-counter-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* ===== JSON ↔ CSV Tool ===== */

.json-csv-layout .code-area {
  min-height: 260px;
}

.json-csv-buttons {
  margin-top: 1.5rem;
}

.error-message {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: #b91c1c;
}