/* =========================================================
   NextSpellUI — Google-hosted only (no local(), no hard URLs)
   We rely on the <link> in HTML to load:
   - Be Vietnam Pro (300, 600)
   - Nokora (300, 600)
   - Noto Sans SC (300, 600)
   - Noto Sans TC (300, 600)
   We then use a font stack so the browser auto-picks by glyph coverage.
   ========================================================= */

:root { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  /* Order matters: Latin first, Khmer next, CJK after */
  font-family: "Be Vietnam Pro", "Nokora", "Noto Sans SC", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 300; /* Light */
  background: #0b0f14;
  color: #e6edf3;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prefer explicit Khmer where lang="km" (helps editable areas) */
:lang(km), [lang="km"] {
  font-family: "Nokora", "Be Vietnam Pro", "Noto Sans SC", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
}

/* Headings = SemiBold */
h1, h2, h3, h4, h5, h6,
.btn, .navbar, .nav-link {
  font-weight: 600;
}

/* Links */
a { color: #89b4ff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Container spacing (Bootstrap-friendly) */
.container { max-width: 1120px; }

/* ---------- Cards / Sections ---------- */
.card {
  background: #0f1620;
  border: 1px solid #1f2937;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}

/* ---------- Dropzone ---------- */
.dz {
  border: 2px dashed rgba(255, 255, 255, .14);
  border-radius: 14px;
  text-align: center;
  background: #0e1520;
  transition: background .15s ease, border-color .15s ease;
}
.dz.dragging {
  background: rgba(125, 146, 255, .10);
  border-color: rgba(122, 162, 247, .8);
}

/* ---------- Buttons ---------- */
.btn {
  border-radius: 10px;
  border: 1px solid #334155;
  transition: transform .15s ease, box-shadow .2s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-outline-primary {
  color: #cfe1ff;
  border-color: #264d9a;
}
.btn-outline-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

.btn-primary {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.btn-outline-info {
  border-color: #0ea5b7;
  color: #a7f3ff;
}
.btn-outline-info:hover { background: #0ea5b7; color: #06252b; }

.btn-outline-light {
  border-color: #3b4656;
  color: #e6edf3;
}
.btn-outline-light:hover { background: #3b4656; color: #fff; }

.btn-success {
  background: #16a34a;
  border-color: #16a34a;
}

.btn-outline-danger {
  border-color: #b91c1c;
  color: #ffb4b4;
}
.btn-outline-danger:hover { background: #b91c1c; color: #fff; }

/* ---------- Spinner / Status ---------- */
.spinner-border { color: #7aa2f7; }

/* Small muted helper text (readable on dark bg) */
.text-muted.small { color: #9fb3c8 !important; }

/* ---------- Preview images ---------- */
#preview img {
  max-height: 240px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid #1f2937;
}

.image-preview {
  border-radius: 10px;
  border: 1px solid #1f2937;
  background: #0b1220;
}

/* ---------- Editor ---------- */
.auto-resize-div {
  min-height: 0;
  max-height: none;
  overflow: visible;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0b1220;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 12px 14px;
  line-height: 1.6;
  color: #e6edf3;
  font-size: 1rem;
  font-family: "Be Vietnam Pro", "Nokora", "Noto Sans SC", "Noto Sans TC", sans-serif !important;
  font-weight: 300 !important;
}

/* Placeholder */
.auto-resize-div:empty:before {
  content: attr(placeholder);
  color: #6c757d;
}

.auto-resize-div .seg { display: inline; }
.auto-resize-div .nl  { display: block; height: 0; }

/* Keep size when rendering table in #textArea */
#textArea { 
  font-size: 1rem; 
  line-height: 1.6; 
}
#textArea pre {
  font-family: "Be Vietnam Pro", "Nokora", "Noto Sans SC", "Noto Sans TC", sans-serif !important;
  font-weight: 300 !important;
  font-size: inherit !important;
  line-height: inherit;
  background: transparent;
  color: inherit;
  border: 0;
  padding: 0;
  margin: 0 0 .75rem 0;
  white-space: pre-wrap;
}
#textArea .table {
  font-size: inherit !important;
  line-height: inherit;
}
#textArea table th {
  text-align: left !important;
  font-family: "Be Vietnam Pro", "Nokora", "Noto Sans SC", "Noto Sans TC", sans-serif !important;
  font-weight: 600 !important;
  color: #fff !important;
}
#textArea table td {
  font-family: "Be Vietnam Pro", "Nokora", "Noto Sans SC", "Noto Sans TC", sans-serif !important;
  font-weight: 300 !important;
  color: #fff !important;
}

/* ---------- Table base (theme) ---------- */
.table {
  --bs-table-bg: #0b1220;
  --bs-table-color: #e6edf3;
  --bs-table-border-color: #223046;
  background: var(--bs-table-bg) !important;
  color: var(--bs-table-color) !important;
  border-color: var(--bs-table-border-color) !important;
}
.table-striped > tbody > tr:nth-of-type(odd) > * {
  background: rgba(255, 255, 255, .03) !important;
}
.table > :not(caption) > * > * {
  border-bottom-color: #223046 !important;
}

/* ---------- Navbar ---------- */
.navbar {
  background: #0d1218 !important;
  border-bottom: 1px solid #1f2937;
}
.nav-link, .navbar-brand { color: #ccd6e5 !important; }
.nav-link:hover, .navbar-brand:hover { color: #ffffff !important; }

/* ---------- Utilities ---------- */
.d-none { display: none !important; }

/* Polished scrollbar (preview) */
#preview::-webkit-scrollbar { width: 10px; height: 10px; }
#preview::-webkit-scrollbar-track { background: #0b1220; border-radius: 8px; }
#preview::-webkit-scrollbar-thumb { background: #273246; border-radius: 8px; border: 2px solid #0b1220; }
#preview::-webkit-scrollbar-thumb:hover { background: #344660; }

/* ---------- Responsive tweaks ---------- */
@media (max-width: 992px) {
  .container { padding-left: 12px; padding-right: 12px; }
  #preview img { max-height: 200px; }
}
@media (max-width: 576px) {
  h1 { font-size: 1.5rem; }
  .btn { border-radius: 9px; }
  #preview img { max-height: 160px; }
}

/* ---------- DOCX list ---------- */
#doc-list { padding-left: 0; }
#doc-list .list-group-item {
  background: #0f1620;
  border: 1px solid #1f2937;
  color: #e6edf3;
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#doc-list .list-group-item:hover {
  background: #141e2e;
  color: #e6edf3;
}
.file-btn { position: relative; }
.file-btn input[type="file"] {
  position: absolute;
  inset: 0;            /* top:0; right:0; bottom:0; left:0 */
  opacity: 0;
  cursor: pointer;
}
