/* ============================================================
   ENCRYPTED_NOTEPAD — 赛博朋克终端风格
   移动优先 + PC 居中窗口
   ============================================================ */

/* ----- CSS 变量 ----- */
:root {
  --bg:        #0a0a0f;
  --bg-light:  #0f0f18;
  --bg-panel:  #0c0c16;
  --primary:   #00d4ff;
  --primary-dim: #007a99;
  --primary-bright: #33e0ff;
  --error:     #ff3366;
  --success:   #00ff88;
  --warn:      #ffb000;
  --text:      #b0d4e0;
  --text-dim:  #4a6a7a;
  --border:    rgba(0, 212, 255, 0.15);
  --border-focus: rgba(0, 212, 255, 0.4);
  --glow:      0 0 8px rgba(0, 212, 255, 0.12);
  --glow-strong: 0 0 16px rgba(0, 212, 255, 0.25);

  --font:      'Courier New', 'Consolas', 'Liberation Mono', monospace;
  --font-size: 14px;
  --line-height: 1.65;
  --radius:    4px;

  /* PC 终端窗口 */
  --term-width:  960px;
  --term-height: 640px;
}

/* ----- 基础重置 ----- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050508;
  font-family: var(--font);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ----- 扫描线 ----- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 212, 255, 0.015) 2px,
    rgba(0, 212, 255, 0.015) 4px
  );
}

/* ----- 选中颜色 ----- */
::selection {
  background: var(--primary);
  color: var(--bg);
}

/* ----- 滚动条 ----- */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--primary-dim);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ============================================================
   终端窗口
   ============================================================ */
#terminal {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--glow);
  border-radius: var(--radius);
  overflow: hidden;
}

.screen {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}
.screen.active {
  display: flex;
}

/* ============================================================
   标题栏
   ============================================================ */
#title-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #08080f;
  border-bottom: 1px solid var(--border);
  user-select: none;
  flex-shrink: 0;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-red    { background: #ff5f57; }
.dot-yellow { background: #ffb000; }
.dot-green  { background: #28c840; }

#title-text {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ============================================================
   解锁屏幕
   ============================================================ */
#lock-screen {
  align-items: center;
  justify-content: center;
}

.lock-container {
  text-align: center;
  padding: 24px;
  max-width: 440px;
  width: 100%;
}

.lock-ascii pre {
  font-size: 7px;
  line-height: 1.2;
  color: var(--primary);
  text-shadow: var(--glow-strong);
  white-space: pre;
  overflow: hidden;
  margin-bottom: 24px;
}

.prompt {
  color: var(--primary);
  font-size: 14px;
  margin-bottom: 8px;
  text-align: left;
}

.input-line {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.input-line input,
input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--primary);
  font-family: var(--font);
  font-size: var(--font-size);
  line-height: var(--line-height);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-line input:focus,
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--glow);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

.cursor {
  position: absolute;
  right: 14px;
  color: var(--primary-bright);
  font-size: 18px;
  animation: blink 1s step-end infinite;
  pointer-events: none;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 按钮 */
.btn {
  width: 100%;
  padding: 12px 20px;
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  color: var(--primary);
  font-family: var(--font);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}
.btn:hover {
  background: rgba(0, 212, 255, 0.08);
  box-shadow: var(--glow-strong);
  color: var(--primary-bright);
}
.btn:active {
  background: rgba(0, 212, 255, 0.15);
  transform: translateY(1px);
}
.btn:disabled {
  border-color: var(--text-dim);
  color: var(--text-dim);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-sm {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--primary);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-sm:hover {
  border-color: var(--primary);
  box-shadow: var(--glow);
  background: rgba(0, 212, 255, 0.05);
}
.btn-sm:active {
  background: rgba(0, 212, 255, 0.1);
}

/* 消息 */
.error-msg {
  color: var(--error);
  font-size: 13px;
  min-height: 20px;
  margin-top: 8px;
}
.status-msg {
  color: var(--warn);
  font-size: 13px;
  min-height: 20px;
  margin-top: 4px;
}

/* ============================================================
   主界面 (PC 分栏)
   ============================================================ */
#main-screen {
  flex-direction: column;
}

/* ----- 侧栏 ----- */
#sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-header .prompt {
  margin: 0;
  font-size: 12px;
  flex: 1;
}

.search-box {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-box input {
  padding: 6px 10px;
  font-size: 12px;
}

#note-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.note-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  gap: 8px;
}
.note-item:hover {
  background: rgba(0, 212, 255, 0.04);
  border-left-color: var(--primary-dim);
}
.note-item.active {
  background: rgba(0, 212, 255, 0.08);
  border-left-color: var(--primary);
  color: var(--primary-bright);
}

.note-item .note-icon {
  color: var(--primary-dim);
  font-size: 13px;
  flex-shrink: 0;
}
.note-item .note-info {
  flex: 1;
  min-width: 0;
}
.note-item .note-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-item .note-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}

/* ----- 编辑区 ----- */
#editor-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

#editor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#editor-header input {
  flex: 1;
  padding: 6px 10px;
  font-size: 15px;
  font-weight: bold;
}
#new-note-btn {
  font-size: 12px;
  font-weight: bold;
}
#delete-note-btn {
  color: var(--error);
  border-color: rgba(255, 51, 102, 0.25);
  flex-shrink: 0;
}
#delete-note-btn:hover {
  border-color: var(--error);
  box-shadow: 0 0 6px rgba(255, 51, 102, 0.2);
  background: rgba(255, 51, 102, 0.06);
}

#editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 编辑器 */
#editor {
  width: 100%;
  height: 100%;
  resize: none;
  border: none;
  border-radius: 0;
  padding: 16px 20px;
  font-size: 16px;
  line-height: var(--line-height);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  outline: none;
  tab-size: 4;
}
#editor:focus {
  box-shadow: none;
}

/* ----- 状态栏 ----- */
#status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  border-top: 1px solid var(--border);
  background: #08080f;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

#save-status.success { color: var(--success); }
#save-status.error   { color: var(--error); }
#save-status.saving  { color: var(--warn); }

/* ============================================================
   PC 端布局 (≥ 768px)
   ============================================================ */
@media (min-width: 768px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
  }

  #terminal {
    width: var(--term-width);
    max-width: 100%;
    height: var(--term-height);
    max-height: calc(100vh - 48px);
  }

  .lock-ascii pre {
    font-size: 8px;
  }

  #main-screen {
    flex-direction: row;
  }

  #sidebar {
    width: 260px;
    min-width: 200px;
    flex-shrink: 0;
  }

  #editor-body {
    flex: 1;
    overflow: hidden;
  }

  .mobile-only {
    display: none !important;
  }
}

/* ============================================================
   手机端 (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  html, body {
    background: var(--bg);
  }

  body::after {
    /* 手机端保留扫描线但更淡 */
    opacity: 0.5;
  }

  #terminal {
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    margin: 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--glow);
  }

  #title-bar {
    padding: 6px 10px;
  }
  .dot {
    width: 10px;
    height: 10px;
  }
  #title-text {
    font-size: 11px;
  }

  .lock-ascii pre {
    font-size: 5.5px;
  }

  .lock-container {
    padding: 20px 16px;
  }

  #main-screen {
    flex-direction: column;
  }

  /* 手机: 列表 / 编辑区 切换 */
  #sidebar, #editor-area {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
  }
  #sidebar.active, #editor-area.active {
    display: flex;
  }
  #editor-area.active {
    animation: fadeIn 1s ease-out;
  }
  #note-list {
    flex: 1;
  }

  /* 编辑区顶部与侧栏对齐 */
  #editor-header input {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.2;
    border: 1px solid var(--border);
    background: var(--bg);
  }
  #editor-area {
    background: var(--bg-panel);
  }

  .btn {
    font-size: 16px;
    padding: 14px 20px;
  }

  input[type="text"],
  input[type="password"],
  textarea {
    font-size: 16px; /* 防 iOS 缩放 */
  }
}

/* ============================================================
   终端弹窗
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 8, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--glow-strong);
  border-radius: var(--radius);
  width: 400px;
  max-width: 92vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: translateY(8px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.modal-overlay.active .modal {
  transform: translateY(0);
  opacity: 1;
}

#modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#modal-title {
  color: var(--primary);
  font-size: 13px;
  letter-spacing: 1px;
}
#modal-close {
  padding: 3px 10px;
  font-size: 13px;
}

#modal-body {
  padding: 16px 18px;
  flex: 1;
  overflow-y: auto;
}
#modal-body .modal-input {
  width: 100%;
  margin-bottom: 12px;
}
#modal-body .modal-msg {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
#modal-body .modal-menu-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}
#modal-body .modal-menu-item:hover {
  border-color: var(--primary);
  color: var(--primary-bright);
  box-shadow: var(--glow);
  background: rgba(0, 212, 255, 0.05);
}
#modal-body .modal-menu-item.danger {
  color: var(--error);
  border-color: rgba(255, 51, 102, 0.2);
}
#modal-body .modal-menu-item.danger:hover {
  border-color: var(--error);
  box-shadow: 0 0 8px rgba(255, 51, 102, 0.2);
  background: rgba(255, 51, 102, 0.05);
}

#modal-footer {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  justify-content: flex-end;
}
#modal-footer .btn {
  width: auto;
  min-width: 80px;
  font-size: 13px;
  padding: 8px 16px;
}

/* ============================================================
   工具类
   ============================================================ */
.hidden { display: none !important; }
