/* ===== FONT: Anakotmai (อนาคตใหม่) ===== */
@font-face {
  font-family: "Anakotmai";
  src: url("webfont/anakotmai-light.eot");
  src:
    url("webfont/anakotmai-light.eot?#iefix") format("embedded-opentype"),
    url("webfont/anakotmai-light.woff2") format("woff2"),
    url("webfont/anakotmai-light.woff") format("woff");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Anakotmai";
  src: url("webfont/anakotmai-medium.eot");
  src:
    url("webfont/anakotmai-medium.eot?#iefix") format("embedded-opentype"),
    url("webfont/anakotmai-medium.woff2") format("woff2"),
    url("webfont/anakotmai-medium.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Anakotmai";
  src: url("webfont/anakotmai-bold.eot");
  src:
    url("webfont/anakotmai-bold.eot?#iefix") format("embedded-opentype"),
    url("webfont/anakotmai-bold.woff2") format("woff2"),
    url("webfont/anakotmai-bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ===== RESET & TOKENS ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --font:
    "Anakotmai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Fira Code", "JetBrains Mono", "SF Mono", "Consolas", monospace;

  --bg: #fafafa;
  --surface: #ffffff;
  --surface-hover: #f5f5f5;
  --surface-active: #f0f4ff;
  --border: #e8e8e8;
  --border-light: #f0f0f0;

  --text: #1a1a1a;
  --text-secondary: #666666;
  --text-muted: #999999;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-subtle: rgba(37, 99, 235, 0.08);

  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;

  --header-h: 52px;
  --sidebar-w: 280px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --ease: 0.15s ease;
}

html {
  font-size: 19px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
  font-weight: 300;
}

/* ===== HEADER ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  letter-spacing: -0.01em;
}

.header__logo-icon {
  color: var(--accent);
}

.header__nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 32px;
}

.header__nav-link {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--ease);
}

.header__nav-link:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.header__nav-link.active {
  color: var(--accent);
  background: var(--accent-subtle);
}

.header__mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
  border-radius: 6px;
  margin-left: auto;
}

/* ===== LAYOUT ===== */
.app {
  margin-top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.page {
  display: none;
  animation: fadeIn 0.2s ease;
}

.page.active {
  display: flex;
}

.page--notes {
  height: calc(100vh - var(--header-h));
}

.page--storage,
.page--about {
  justify-content: center;
  overflow-y: auto;
}

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
}

.sidebar__title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar__new-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--ease);
}

.sidebar__new-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
}

.sidebar__list::-webkit-scrollbar {
  width: 4px;
}
.sidebar__list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.sidebar__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  padding: 40px 20px;
  text-align: center;
}

.sidebar__empty p {
  font-weight: 500;
  font-size: 0.95rem;
}
.sidebar__empty span {
  font-size: 0.85rem;
}

/* Note Item */
.note-item {
  position: relative;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--ease);
  margin-bottom: 1px;
}

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

.note-item.active {
  background: var(--surface-active);
}

.note-item__title {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 24px;
}

.note-item__preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item__date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.note-item__delete {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0;
  transition: all var(--ease);
  display: flex;
  align-items: center;
}

.note-item:hover .note-item__delete {
  opacity: 1;
}

.note-item__delete:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

/* ===== EDITOR ===== */
.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  height: 100%;
  overflow: hidden;
}

.editor__placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.editor__placeholder h3 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.editor__placeholder p {
  font-size: 0.9rem;
}

.editor__active {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.editor__topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-light);
}

.editor__title {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  letter-spacing: -0.01em;
}

.editor__title::placeholder {
  color: var(--text-muted);
}

.editor__status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--success);
  background: var(--success-bg);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  transition: all var(--ease);
  flex-shrink: 0;
}

.editor__status--saving {
  color: var(--text-muted);
  background: var(--border-light);
}

.editor__status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
}

.editor__status--saving .editor__status-dot {
  background: var(--text-muted);
  animation: pulse 1s infinite;
}

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

/* ===== QUILL EDITOR OVERRIDES ===== */
#quill-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ql-toolbar.ql-snow {
  border: none !important;
  border-bottom: 1px solid var(--border-light) !important;
  padding: 6px 16px !important;
  font-family: var(--font) !important;
  background: var(--bg);
}

.ql-container.ql-snow {
  border: none !important;
  font-family: var(--font) !important;
  font-size: 1rem;
  flex: 1;
  overflow-y: auto;
}

.ql-editor {
  padding: 24px 32px 60px !important;
  line-height: 1.8;
  font-weight: 300;
  font-size: 1rem;
  color: var(--text);
}

.ql-editor.ql-blank::before {
  color: var(--text-muted) !important;
  font-style: normal !important;
  font-weight: 300;
}

.ql-snow .ql-stroke {
  stroke: var(--text-secondary);
}
.ql-snow .ql-fill {
  fill: var(--text-secondary);
}
.ql-snow .ql-picker {
  color: var(--text-secondary);
}

.ql-snow .ql-toolbar button:hover,
.ql-snow .ql-toolbar button.ql-active {
  color: var(--accent) !important;
}

.ql-snow .ql-toolbar button:hover .ql-stroke,
.ql-snow .ql-toolbar button.ql-active .ql-stroke {
  stroke: var(--accent) !important;
}

.ql-snow .ql-toolbar button:hover .ql-fill,
.ql-snow .ql-toolbar button.ql-active .ql-fill {
  fill: var(--accent) !important;
}

/* ===== CODE BLOCKS — VS Code Dark+ Style ===== */
.ql-editor pre.ql-syntax,
.ql-editor code {
  font-family: var(--font-mono) !important;
  font-size: 0.88rem;
  line-height: 1.65;
  tab-size: 4;
}

.ql-editor pre.ql-syntax {
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
  border-radius: var(--radius) !important;
  padding: 16px 20px !important;
  margin: 12px 0 !important;
  overflow-x: auto;
  border: 1px solid #333 !important;
}

.ql-editor code {
  background: #f1f5f9;
  color: #e11d48;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88rem;
}

/* Highlight.js VS Code theme token overrides inside Quill */
.ql-editor pre.ql-syntax .hljs-keyword {
  color: #569cd6;
}
.ql-editor pre.ql-syntax .hljs-built_in {
  color: #4ec9b0;
}
.ql-editor pre.ql-syntax .hljs-type {
  color: #4ec9b0;
}
.ql-editor pre.ql-syntax .hljs-literal {
  color: #569cd6;
}
.ql-editor pre.ql-syntax .hljs-number {
  color: #b5cea8;
}
.ql-editor pre.ql-syntax .hljs-string {
  color: #ce9178;
}
.ql-editor pre.ql-syntax .hljs-regexp {
  color: #d16969;
}
.ql-editor pre.ql-syntax .hljs-symbol {
  color: #569cd6;
}
.ql-editor pre.ql-syntax .hljs-variable {
  color: #9cdcfe;
}
.ql-editor pre.ql-syntax .hljs-template-variable {
  color: #9cdcfe;
}
.ql-editor pre.ql-syntax .hljs-link {
  color: #ce9178;
}
.ql-editor pre.ql-syntax .hljs-selector-attr,
.ql-editor pre.ql-syntax .hljs-selector-pseudo,
.ql-editor pre.ql-syntax .hljs-selector-id,
.ql-editor pre.ql-syntax .hljs-selector-class,
.ql-editor pre.ql-syntax .hljs-selector-tag {
  color: #d7ba7d;
}
.ql-editor pre.ql-syntax .hljs-title {
  color: #dcdcaa;
}
.ql-editor pre.ql-syntax .hljs-params {
  color: #9cdcfe;
}
.ql-editor pre.ql-syntax .hljs-comment {
  color: #6a9955;
  font-style: italic;
}
.ql-editor pre.ql-syntax .hljs-doctag {
  color: #608b4e;
}
.ql-editor pre.ql-syntax .hljs-meta,
.ql-editor pre.ql-syntax .hljs-meta .hljs-keyword,
.ql-editor pre.ql-syntax .hljs-tag {
  color: #569cd6;
}
.ql-editor pre.ql-syntax .hljs-attr {
  color: #9cdcfe;
}
.ql-editor pre.ql-syntax .hljs-attribute {
  color: #9cdcfe;
}
.ql-editor pre.ql-syntax .hljs-section {
  color: #dcdcaa;
}
.ql-editor pre.ql-syntax .hljs-emphasis {
  font-style: italic;
}
.ql-editor pre.ql-syntax .hljs-strong {
  font-weight: bold;
}
.ql-editor pre.ql-syntax .hljs-addition {
  color: #b5cea8;
  background: rgba(181, 206, 168, 0.1);
}
.ql-editor pre.ql-syntax .hljs-deletion {
  color: #ce9178;
  background: rgba(206, 145, 120, 0.1);
}

/* ===== SETTINGS PAGE ===== */
.settings {
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings__card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.settings__heading {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.settings__desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.settings__options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings__option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--ease);
}

.settings__option:hover,
.settings__option.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.settings__option input[type="radio"] {
  margin-top: 2px;
  accent-color: var(--accent);
}

.settings__option-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.settings__option-name {
  font-size: 0.95rem;
  font-weight: 500;
}

.settings__badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--success-bg);
  color: var(--success);
}

.settings__option-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.settings__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--ease);
  border: 1.5px solid transparent;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

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

.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== ABOUT PAGE ===== */
.about {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 20px;
}

.about__hero {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #3b82f6 100%);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  text-align: center;
  color: #fff;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.about__hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 20%,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 50%
  );
}

.about__hero-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  position: relative;
}

.about__hero-subtitle {
  font-size: 1rem;
  opacity: 0.9;
  line-height: 1.7;
  position: relative;
  font-weight: 300;
}

.about__features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.about__feature-card {
  background: var(--surface);
  padding: 24px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.about__feature-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.about__feature-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.about__feature-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.about__feature-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  font-weight: 300;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  background: var(--text);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  animation:
    toastIn 0.2s ease,
    toastOut 0.2s ease 2.7s forwards;
  font-family: var(--font);
}

.toast--success {
  background: var(--success);
}
.toast--error {
  background: var(--danger);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header__nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px;
    margin-left: 0;
    box-shadow: var(--shadow-md);
  }

  .header__nav.open {
    display: flex;
  }
  .header__mobile-toggle {
    display: flex;
  }

  .page--notes {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - var(--header-h));
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
  }

  .editor {
    min-height: 60vh;
  }

  .editor__title {
    font-size: 1rem;
  }

  .ql-editor {
    padding: 16px 18px 40px !important;
  }

  .about__features {
    grid-template-columns: 1fr;
  }

  .about__hero {
    padding: 36px 24px;
  }
  .about__hero-title {
    font-size: 1.5rem;
  }
}
