@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* Reset lề body & màu nền */
*,
*::before,
*::after {
  transition: none !important;
  animation: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: #fafafa;
  color: #1b2533;
  font-family: 'Plus Jakarta Sans', 'Nunito', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

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

/* Thanh header sticky */
.top-bar {
  flex-shrink: 0;
  width: 100%;
  background-color: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  z-index: 1000;
}

/* Ép các thành phần nằm ngang */
.top-bar-content {
  width: 100%;
  padding: 10px 24px;
  box-sizing: border-box;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 24px;
}

/* Tiêu đề */
.brand-title {
  font-weight: 600;
  font-size: 18px;
  line-height: 1;
  color: #1b2533;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
  margin: 0;
  padding: 0;
}

.brand-title::before {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  background-image: url("assets/icons/favicon.ico");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}

/* Navigation Menu */
.nav-menu {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 4px;
  margin: 0;
  padding: 0;
}

.dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.dropdown::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 8px;
}

.dropbtn {
  background-color: transparent;
  color: #1b2533;
  padding: 6px 12px;
  font-size: 15px;
  line-height: 1;
  font-weight: 500;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.dropdown:hover .dropbtn {
  background-color: #f3f4f6;
  color: #1b2533;
}

/* Khung Dropdown - Co giãn tự động theo nội dung */
.dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background-color: #ffffff;
  width: max-content;
  min-width: 140px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 6px;
  z-index: 1001;
  border: 1px solid #e5e7eb;
}

.dropdown-content::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 24px;
  width: 10px;
  height: 10px;
  background-color: #ffffff;
  transform: rotate(45deg);
  border-top: 1px solid #e5e7eb;
  border-left: 1px solid #e5e7eb;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-content a {
  color: #1b2533;
  padding: 8px 12px;
  text-decoration: none !important;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 400;
  border-radius: 4px;
  white-space: nowrap;
}


.dropdown-content a:hover {
  background-color: #f3f4f6;
}

.dropdown-content a img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Vùng Main trên PC */
main.markdown-body {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  flex: 1;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Notepad trên PC */
.notepad-container {
  width: 100%;
  flex: 1;
  min-height: calc(100vh - 49px);
  display: flex;
  flex-direction: column;
  background-color: #fafafa;
}

/* Nhóm điều khiển bên phải Topbar (Nút Note, Nút Sửa/Xem, Thanh Tìm kiếm) */
.topbar-right-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.notes-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.notes-dropbtn {
  height: 32px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #1e293b;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  max-width: 200px;
}

.notes-dropbtn:hover {
  background-color: #f3f4f6;
  border-color: #d1d5db;
  color: #111827;
}

.notes-icon {
  color: #6b7280;
  flex-shrink: 0;
}

.current-tab-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.dropdown-arrow-icon {
  color: #9ca3af;
  flex-shrink: 0;
}

/* Khung Dropdown danh sách Notes */
.notes-dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  background-color: #ffffff;
  min-width: 240px;
  max-width: 320px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 8px;
  z-index: 1001;
  border: 1px solid #e5e7eb;
  box-sizing: border-box;
}

.notes-dropdown-content::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 20px;
  left: auto;
  width: 10px;
  height: 10px;
  background-color: #ffffff;
  transform: rotate(45deg);
  border-top: 1px solid #e5e7eb;
  border-left: 1px solid #e5e7eb;
}

.notes-dropdown:hover .notes-dropdown-content,
.notes-dropdown.active .notes-dropdown-content {
  display: block;
}

.notes-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 8px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 11.5px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.notes-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background-color: transparent;
  border: none;
  border-radius: 50%;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  box-sizing: border-box;
}

.notes-add-btn:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.notes-dropdown-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 260px;
  overflow-y: auto;
  padding-top: 6px;
}

.notes-tab-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: #374151;
  background-color: transparent;
  cursor: pointer;
  user-select: none;
}

.notes-tab-item.active {
  background-color: transparent;
  color: #111827;
  font-weight: 600;
}

.notes-tab-item:hover,
.notes-tab-item.active:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.notes-tab-icon {
  width: 14px;
  height: 14px;
  color: #9ca3af;
  flex-shrink: 0;
}

.notes-tab-item.active .notes-tab-icon {
  color: #111827;
}

.notes-tab-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
}

.notes-tab-title[contenteditable="true"] {
  background: #ffffff;
  padding: 0 4px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px #3b82f6;
  cursor: text;
}

.notes-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #9ca3af;
  flex-shrink: 0;
  cursor: pointer;
}

.notes-tab-close:hover {
  background-color: #d1d5db;
  color: #111827;
}

/* Nút Preview / Edit trên Topbar */
.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  color: #6b7280;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-sizing: border-box;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}

.topbar-icon-btn:hover {
  background-color: #f3f4f6;
  color: #111827;
  border-color: #d1d5db;
}

.topbar-icon-btn.active {
  background-color: #e5e7eb;
  color: #111827;
  border-color: #d1d5db;
}

.notepad-body {
  position: relative;
  flex: 1;
  min-height: calc(100vh - 89px);
  width: 65%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background-color: #fafafa;
}

#notepad {
  width: 100%;
  flex: 1;
  min-height: calc(100vh - 89px);
  padding: 20px 0;
  box-sizing: border-box;
  border: none;
  border-radius: 0;
  background-color: #fafafa;
  color: #1b2533;
  font-family: 'Plus Jakarta Sans', 'Nunito', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  outline: none;
}

.notepad-preview-content {
  width: 100%;
  flex: 1;
  min-height: calc(100vh - 89px);
  padding: 20px 0;
  box-sizing: border-box;
  background-color: #fafafa;
  color: #1b2533;
  font-family: 'Plus Jakarta Sans', 'Nunito', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

/* Format HTML Markdown preview */
.notepad-preview-content>*:first-child {
  margin-top: 0 !important;
}

.notepad-preview-content h1,
.notepad-preview-content h2,
.notepad-preview-content h3,
.notepad-preview-content h4 {
  color: #0f172a;
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-weight: 600;
  line-height: 1.3;
}

.notepad-preview-content h1 {
  font-size: 1.8em;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.3em;
}

.notepad-preview-content h2 {
  font-size: 1.4em;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.2em;
}

.notepad-preview-content h3 {
  font-size: 1.2em;
}

.notepad-preview-content p {
  margin-top: 0;
  margin-bottom: 1em;
}

.notepad-preview-content ul,
.notepad-preview-content ol {
  padding-left: 24px;
  margin-bottom: 1em;
}

.notepad-preview-content li {
  margin-bottom: 0.3em;
}

.notepad-preview-content blockquote {
  border-left: 3px solid #3b82f6;
  margin: 0.6em 0;
  padding: 8px 12px;
  color: #334155;
  background-color: #f8fafc;
  border-radius: 0 6px 6px 0;
}

.notepad-preview-content blockquote p {
  margin: 0;
}

.notepad-preview-content blockquote p+p {
  margin-top: 0.5em;
}

.notepad-preview-content code {
  background-color: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13.5px;
  font-family: SFMono-Regular, Consolas, monospace;
}

.notepad-preview-content pre {
  position: relative;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1em;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: #64748b;
  border-radius: 6px;
  box-shadow: none;
  cursor: pointer;
  transition: none;
  user-select: none;
  z-index: 5;
}

.code-copy-btn:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.code-copy-btn.copied {
  background-color: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.notepad-preview-content pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
}

.notepad-preview-content a {
  color: #2563eb;
  text-decoration: underline;
}

.notepad-preview-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1em;
}

.notepad-preview-content th,
.notepad-preview-content td {
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  text-align: left;
}

.notepad-preview-content th {
  background-color: #f8fafc;
  font-weight: 600;
}

.notepad-empty-hint {
  color: #94a3b8;
  font-style: italic;
  cursor: pointer;
}

#mobile-content {
  display: none;
}

@media (max-width: 1024px) {
  .notepad-body {
    width: 85%;
  }
}

/* Giao diện Mobile (Giữ nguyên như cũ, ẩn hoàn toàn Notepad) */
@media (max-width: 768px) {

  html,
  body {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  main.markdown-body {
    height: auto;
    overflow: visible;
    padding: 16px 20px 40px 20px;
    max-width: 800px;
    margin: 0 auto;
  }

  .notepad-container {
    display: none !important;
    /* Ẩn ghi chú trên điện thoại */
  }

  .topbar-right-controls {
    display: none !important;
  }

  .top-bar-content {
    padding: 12px 16px;
  }

  .nav-menu {
    display: none !important;
  }

  .search-box {
    display: none !important;
  }

  #mobile-content {
    display: block;
    margin-top: 0;
  }

  #mobile-content h2 {
    font-size: 16px;
    font-weight: 600;
    color: #1b2533;
    margin: 20px 0 10px 0;
  }

  #mobile-content h2:first-child {
    margin-top: 0;
  }

  .link-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .link-grid a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    width: auto;
    max-width: 100%;
    background-color: #ffffff;
    border: 1px solid #eef2f6;
    border-radius: 6px;
    color: #1b2533;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none !important;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  }

  .link-grid a img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
  }
}

/* Styling riêng cho trang 404 */
body.markdown-body main {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
}

body.markdown-body h1 {
  font-size: 32px;
  margin-bottom: 12px;
  color: #1b2533;
}

body.markdown-body p {
  font-size: 16px;
  color: #57606a;
  margin: 6px 0;
}

body.markdown-body a {
  color: #0969da;
  text-decoration: none;
  font-weight: 500;
}

body.markdown-body a:hover {
  text-decoration: underline;
}

/* Search Box ở góc phải Header */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 200px;
  flex-shrink: 0;
  margin: 0;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0 10px;
  width: 100%;
  height: 32px;
  box-sizing: border-box;
}

.search-input-wrapper:focus-within {
  width: 100%;
  border: 2px solid #2563eb;
  padding: 0 9px;
  box-shadow: none;
}

.search-icon {
  color: #64748b;
  flex-shrink: 0;
  margin-right: 6px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

#header-search {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: #1e293b;
  padding: 0;
  margin: 0;
  display: block;
}

#header-search::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.search-clear-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  margin-left: 4px;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear-btn:hover {
  color: #111827;
  background-color: #e5e7eb;
}

/* Dropdown kết quả tìm kiếm - dài bằng thanh tìm kiếm */
.search-results-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  box-sizing: border-box;
  max-height: 320px;
  overflow-y: auto;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 4px;
  z-index: 1100;
}

.search-results-dropdown.active {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  text-decoration: none;
  color: #1e293b;
  font-size: 13px;
  cursor: pointer;
}

.search-result-item:hover,
.search-result-item.selected {
  background-color: #f3f4f6;
}

.search-result-item img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.search-result-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-result-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-category {
  font-size: 10.5px;
  color: #6b7280;
  font-weight: 400;
}

.search-result-google {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid #f3f4f6;
  margin-top: 2px;
  color: #2563eb;
  font-weight: 500;
  font-size: 12.5px;
  text-decoration: none;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-google:hover,
.search-result-google.selected {
  background-color: #f3f4f6;
}

.search-no-results {
  padding: 10px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}

/* ===== GitHub Flavored Alerts (rendered in Notepad preview) ===== */
.gh-alert {
  border-left: 4px solid;
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.gh-alert-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.gh-alert-title svg {
  flex-shrink: 0;
}

/* NOTE — xanh dương */
.gh-alert-note {
  border-color: #3b82f6;
  background-color: #eff6ff;
  color: #1e3a5f;
}

.gh-alert-note .gh-alert-title {
  color: #2563eb;
}

/* TIP — xanh lá */
.gh-alert-tip {
  border-color: #22c55e;
  background-color: #f0fdf4;
  color: #14532d;
}

.gh-alert-tip .gh-alert-title {
  color: #16a34a;
}

/* IMPORTANT — tím */
.gh-alert-important {
  border-color: #a855f7;
  background-color: #faf5ff;
  color: #3b0764;
}

.gh-alert-important .gh-alert-title {
  color: #9333ea;
}

/* WARNING — vàng cam */
.gh-alert-warning {
  border-color: #f59e0b;
  background-color: #fffbeb;
  color: #78350f;
}

.gh-alert-warning .gh-alert-title {
  color: #d97706;
}

/* CAUTION — đỏ */
.gh-alert-caution {
  border-color: #ef4444;
  background-color: #fef2f2;
  color: #7f1d1d;
}

.gh-alert-caution .gh-alert-title {
  color: #dc2626;
}