/* ============================================================
   SIDEBAR.CSS — Sidebar trái của cửa sổ Notes
   ============================================================ */

/* ── Sidebar Container ───────────────────────────────────── */
.sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Sidebar Top Bar ─────────────────────────────────────── */
.sidebar-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
  flex-shrink: 0;
}

.traffic-lights {
  display: flex;
  gap: 7px;
  align-items: center;
}

.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: filter 0.15s;
}

.traffic-light:hover { filter: brightness(0.85); }
.traffic-light.red    { background: #ff5f57; }
.traffic-light.yellow { background: #febc2e; }
.traffic-light.green  { background: #28c840; }

/* ── Sidebar Action Buttons (AA, new note) ───────────────── */
.sidebar-actions {
  display: flex;
  gap: 2px;
  align-items: center;
}

.sidebar-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 6px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}

.sidebar-action-btn:hover {
  background: var(--bg-sidebar-hover);
  color: var(--color-text);
}

/* ── Search Bar ──────────────────────────────────────────── */
.sidebar-search-wrap {
  padding: 4px 12px 10px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--bg-sidebar);
}

/* Box kiểu iPhone */
.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #e4e4e8;
  border-radius: 10px;
  padding: 6px 10px;
}

.search-icon {
  color: #8e8e93;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13.5px;
  color: var(--color-text);
  font-family: var(--font-main);
  caret-color: var(--color-active);
  min-width: 0;
}

.search-input::placeholder {
  color: #8e8e93;
  font-weight: 400;
}

.search-clear {
  border: none;
  background: #aeaeb2;
  cursor: pointer;
  color: #e4e4e8;
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
  padding: 0;
  line-height: 1;
}

.search-clear:hover {
  background: #8e8e93;
}

/* Highlight từ khóa tìm kiếm */
.note-item mark {
  background: #fff3b0;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* Trạng thái không có kết quả */
.search-empty {
  padding: 20px 16px;
  font-size: 13px;
  color: var(--color-muted);
  text-align: center;
}

/* ── Notes List ──────────────────────────────────────────── */
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Thanh cuộn sidebar cho đẹp */
.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* ── Section Label (Pinned / Notes) ──────────────────────── */
.sidebar-section-label {
  padding: 10px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Note Item (mỗi note trong sidebar) ─────────────────── */
.note-item {
  padding: 8px 14px;
  margin: 1px 6px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s;
  border: 1.5px solid transparent;
}

.note-item:hover {
  background: var(--bg-sidebar-hover);
}

.note-item.active {
  background: var(--bg-active);
  border-color: rgba(37, 99, 235, 0.2);
}

.note-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.note-item.active .note-item-title {
  color: var(--color-active);
}

.note-item-meta {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  overflow: hidden;
}

.note-item-date {
  font-size: 11px;
  color: var(--color-muted);
  flex-shrink: 0;
}

.note-item-date::after {
  content: "·";
  margin-left: 5px;
  opacity: 0.5;
}

.note-item-excerpt {
  font-size: 11.5px;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.8;
}

/* ── Content Area (phần phải) ────────────────────────────── */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  background: var(--bg-window);
}

/* Thanh cuộn content */
.content-area::-webkit-scrollbar { width: 5px; }
.content-area::-webkit-scrollbar-track { background: transparent; }
.content-area::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

.content-date {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 24px;
  font-style: italic;
}

/* ── Typography trong Content ────────────────────────────── */
.content-body h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--color-text);
  margin-bottom: 16px;
  line-height: 1.2;
}

.content-body h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-top: 28px;
  margin-bottom: 10px;
}

.content-body p {
  font-size: 14.5px;
  line-height: 1.75;
  color: #374151;
  margin-bottom: 14px;
}

.content-body ul {
  padding-left: 20px;
  margin-bottom: 14px;
}

.content-body ul li {
  font-size: 14.5px;
  line-height: 1.75;
  color: #374151;
  margin-bottom: 6px;
}

.content-body a {
  color: var(--color-link);
  text-decoration: none;
  border-bottom: 1px solid rgba(200, 146, 42, 0.35);
  transition: border-color 0.15s, color 0.15s;
}

.content-body a:hover {
  color: #a8761e;
  border-color: var(--color-link);
}

.content-body strong {
  font-weight: 600;
  color: var(--color-text);
}

.content-body em {
  font-style: italic;
  color: #6b7280;
}

/* ── Mobile Back Button ──────────────────────────────────── */
.mobile-back-btn {
  display: none;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 260px; min-width: 260px; }
}

@media (max-width: 540px) {
  /* Layout: stack sidebar và content theo chiều ngang,
     dùng JS để slide giữa 2 view */
  .window-body {
    position: relative;
    overflow: hidden;
  }

  .sidebar {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    min-width: 100%;
    height: 100%;
    z-index: 2;
    transform: translateX(0);
    transition: transform 0.3s ease;
  }

  .content-area {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    padding: 16px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  /* Khi đang xem note: ẩn sidebar, hiện content */
  .window-body.note-open .sidebar {
    transform: translateX(-100%);
  }

  .window-body.note-open .content-area {
    transform: translateX(0);
  }

  /* Nút Back chỉ hiện trên mobile */
  .mobile-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-link);
    font-size: 14px;
    font-family: var(--font-main);
    padding: 0 0 20px 0;
    font-weight: 500;
  }

  .mobile-back-btn:hover { opacity: 0.75; }
}
