/* =============================================================
   STWMS User Manual — Shared Stylesheet
   Font: Sarabun (Google Fonts) | Framework: Bootstrap 5 CDN
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --sidebar-width: 264px;
  --sidebar-bg: #1e2329;
  --sidebar-hover: #2d3340;
  --sidebar-active: #0d6efd;
  --sidebar-text: #c9d1d9;
  --sidebar-muted: #8b949e;
  --topbar-height: 56px;
  --content-max: 860px;
  --primary: #0d6efd;
  --success: #198754;
  --warning: #ffc107;
  --danger: #dc3545;
  --info: #0dcaf0;
  --step-size: 32px;
}

/* ─── Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Sarabun', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #212529;
  background: #f6f8fa;
  margin: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  line-height: 1.4;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-size: 0.875em;
  background: #f0f4f8;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  padding: 1px 6px;
  color: #d63384;
}

/* ─── Layout ────────────────────────────────────────────────── */
.docs-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.docs-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-track { background: transparent; }
.docs-sidebar::-webkit-scrollbar-thumb { background: #444c56; border-radius: 4px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid #30363d;
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 34px;
  height: 34px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  color: #fff;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-name {
  color: #e6edf3;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.sidebar-brand-sub {
  color: var(--sidebar-muted);
  font-size: 11px;
  line-height: 1;
}

.sidebar-nav {
  padding: 12px 0 24px;
  flex: 1;
}

.nav-section-label {
  padding: 10px 20px 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 20px;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border-radius: 0;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #e6edf3;
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(13, 110, 253, 0.15);
  color: #74a9ff;
  font-weight: 500;
  border-left: 3px solid var(--sidebar-active);
  padding-left: 17px;
}

.sidebar-link .nav-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
}
.sidebar-link:hover .nav-icon,
.sidebar-link.active .nav-icon { opacity: 1; }

.sidebar-link.sub-link {
  padding-left: 48px;
  font-size: 13.5px;
  color: var(--sidebar-muted);
}

.sidebar-link.sub-link:hover { color: var(--sidebar-text); }

.sidebar-link.sub-link.active {
  padding-left: 45px;
  color: #74a9ff;
}

.sidebar-back-app {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  color: var(--sidebar-muted);
  font-size: 13px;
  text-decoration: none;
  border-top: 1px solid #30363d;
  transition: color 0.15s, background 0.15s;
}
.sidebar-back-app:hover {
  color: #e6edf3;
  background: var(--sidebar-hover);
  text-decoration: none;
}

/* ─── Topbar ────────────────────────────────────────────────── */
.docs-topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e1e4e8;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 900;
  gap: 12px;
}

.topbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #586069;
  padding: 4px 8px;
}

.topbar-breadcrumb {
  font-size: 14px;
  color: #586069;
}

.topbar-breadcrumb .current {
  color: #212529;
  font-weight: 600;
}

.topbar-breadcrumb span { margin: 0 6px; color: #ccc; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-version {
  background: #f0f4ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid #c8d8ff;
}

/* ─── Main Content ──────────────────────────────────────────── */
.docs-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 36px 40px 80px;
  min-height: calc(100vh - var(--topbar-height));
}

.content-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ─── Page Header ───────────────────────────────────────────── */
.page-header {
  border-bottom: 1px solid #e8eaed;
  padding-bottom: 24px;
  margin-bottom: 36px;
}

.page-header .page-icon { display: none; }

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: #1a1d23;
  margin: 0 0 6px;
}

.page-header .page-desc {
  font-size: 16px;
  color: #586069;
  margin: 0;
}

/* Section headings */
.docs-content h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1a1d23;
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e1e4e8;
}

.docs-content h3 {
  font-size: 17px;
  font-weight: 600;
  color: #24292f;
  margin: 28px 0 12px;
}

.docs-content h4 {
  font-size: 15px;
  font-weight: 600;
  color: #24292f;
  margin: 20px 0 8px;
}

.docs-content p { margin-bottom: 14px; }

/* ─── Status Flow Diagram ───────────────────────────────────── */
.status-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  background: #f8fafc;
  border: 1px solid #e1e4e8;
  border-radius: 10px;
  padding: 20px 24px;
  margin: 20px 0 28px;
}

.status-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.status-badge {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge.draft    { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.status-badge.confirm  { background: #cfe2ff; color: #084298; border: 1px solid #9ec5fe; }
.status-badge.partial  { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.status-badge.done     { background: #d1e7dd; color: #0a3622; border: 1px solid #a3cfbb; }
.status-badge.cancel   { background: #f8d7da; color: #58151c; border: 1px solid #f1aeb5; }

.status-label {
  font-size: 11px;
  color: #6c757d;
  font-weight: 500;
}

.status-arrow {
  font-size: 20px;
  color: #adb5bd;
  margin: 0 6px;
  padding-bottom: 16px;
}

.status-branch {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

/* ─── Step Cards ────────────────────────────────────────────── */
.steps-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  counter-reset: step-counter;
}

.step-item {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.step-num {
  width: var(--step-size);
  height: var(--step-size);
  min-width: var(--step-size);
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-body { flex: 1; }

.step-body strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #1a1d23;
  margin-bottom: 3px;
}

.step-body p, .step-body ul {
  font-size: 14.5px;
  color: #444;
  margin: 0;
}

/* ─── Info / Warning / Tip Boxes ────────────────────────────── */
.doc-box {
  border-radius: 0 5px 5px 0;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 14.5px;
  border-left: 3px solid;
  line-height: 1.6;
}

.doc-box .box-icon { display: none; }
.doc-box .box-body strong { display: block; margin-bottom: 3px; font-size: 13.5px; }

.doc-box.tip {
  background: #e8f4fd;
  border-color: #0d6efd;
  color: #0a3055;
}

.doc-box.warning {
  background: #fff8e6;
  border-color: #ffc107;
  color: #5c4300;
}

.doc-box.danger {
  background: #fff0f0;
  border-color: #dc3545;
  color: #5c0011;
}

.doc-box.success {
  background: #e9f7ef;
  border-color: #198754;
  color: #0a3b22;
}

/* ─── Image Placeholder ─────────────────────────────────────── */
.img-placeholder {
  background: #f8f9fb;
  border: 1px dashed #d0d7de;
  border-radius: 8px;
  padding: 36px 24px;
  text-align: center;
  color: #8b949e;
  margin: 16px 0;
}

.img-placeholder .ph-icon { display: none; }
.img-placeholder .ph-caption { font-size: 13px; font-weight: 500; color: #586069; }
.img-placeholder .ph-hint { font-size: 12px; color: #adb5bd; margin-top: 4px; }

.img-doc {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #e1e4e8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin: 12px 0;
}

.img-caption {
  text-align: center;
  font-size: 12.5px;
  color: #6c757d;
  margin-top: -8px;
  margin-bottom: 16px;
  font-style: italic;
}

/* ─── Permission Badge ──────────────────────────────────────── */
.perm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0f4f8;
  border: 1px solid #d0d7de;
  color: #586069;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
}

.perm-required {
  font-size: 13px;
  color: #6c757d;
  margin-bottom: 16px;
}

.perm-required .perm-badge { margin-left: 4px; }

/* ─── Tables ────────────────────────────────────────────────── */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  margin: 16px 0 24px;
}

.doc-table th {
  background: #f6f8fa;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: #444;
  border: 1px solid #e1e4e8;
}

.doc-table td {
  padding: 9px 14px;
  border: 1px solid #e1e4e8;
  color: #333;
  vertical-align: top;
}

.doc-table tr:hover td { background: #f8f9fa; }

/* ─── Module Card (index.html) ──────────────────────────────── */
.module-card {
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 12px;
  padding: 24px;
  transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
}

.module-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.10);
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
}

.module-card .card-icon {
  width: 40px;
  height: 40px;
  background: #eef3ff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: var(--primary);
  margin-bottom: 14px;
}
.module-card .card-title { font-size: 17px; font-weight: 700; color: #1a1d23; margin: 0 0 6px; }
.module-card .card-desc { font-size: 13.5px; color: #586069; margin: 0 0 14px; line-height: 1.5; }

.card-links { display: flex; gap: 8px; flex-wrap: wrap; }

.card-tag {
  font-size: 12px;
  background: #f0f4ff;
  color: #2563eb;
  border: 1px solid #c8d8ff;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

/* ─── Workflow Quick-ref (index.html) ───────────────────────── */
.flow-ref {
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 10px;
  padding: 20px 24px;
}

.flow-ref-title {
  font-size: 15px;
  font-weight: 700;
  color: #1a1d23;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.flow-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 14px;
}

.flow-row .step-box {
  background: #f0f4ff;
  border: 1px solid #c8d8ff;
  color: #1a50c8;
  padding: 4px 14px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
}

.flow-row .arrow { color: #adb5bd; font-size: 16px; }

/* ─── Hero (index.html) ─────────────────────────────────────── */
.hero-section {
  background: linear-gradient(135deg, #1e2329 0%, #2d3340 100%);
  color: #e6edf3;
  padding: 48px 40px;
  border-radius: 16px;
  margin-bottom: 36px;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 220px;
  height: 220px;
  background: rgba(13, 110, 253, 0.1);
  border-radius: 50%;
}

.hero-section::after {
  content: '';
  position: absolute;
  bottom: -60px;
  right: 80px;
  width: 140px;
  height: 140px;
  background: rgba(13, 110, 253, 0.07);
  border-radius: 50%;
}

.hero-section h1 {
  font-size: 30px;
  font-weight: 700;
  color: #e6edf3;
  margin: 0 0 10px;
  position: relative;
  z-index: 1;
}

.hero-section p {
  font-size: 16px;
  color: #8b949e;
  margin: 0 0 20px;
  position: relative;
  z-index: 1;
  max-width: 600px;
}

.hero-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.hero-badge {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: #c9d1d9;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
}

/* ─── Sidebar Overlay (mobile) ──────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

/* ─── Anchor offset for fixed topbar ────────────────────────── */
[id] { scroll-margin-top: calc(var(--topbar-height) + 16px); }

/* ─── Divider ───────────────────────────────────────────────── */
.docs-divider {
  border: none;
  border-top: 1px solid #e1e4e8;
  margin: 36px 0;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 991px) {
  .docs-sidebar {
    transform: translateX(-100%);
  }

  .docs-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .docs-topbar {
    left: 0;
  }

  .topbar-toggle {
    display: flex;
    align-items: center;
  }

  .docs-content {
    margin-left: 0;
    padding: 24px 20px 60px;
  }
}

@media (max-width: 575px) {
  .status-flow { flex-direction: column; align-items: flex-start; }
  .status-arrow { transform: rotate(90deg); padding-bottom: 0; padding-right: 16px; }
  .hero-section { padding: 32px 24px; }
  .hero-section h1 { font-size: 22px; }
}

/* ─── Print ─────────────────────────────────────────────────── */
@media print {
  .docs-sidebar, .docs-topbar, .topbar-toggle, .sidebar-overlay { display: none !important; }
  .docs-content { margin: 0 !important; padding: 0 !important; }
  .content-inner { max-width: 100% !important; }
  .img-placeholder { border: 1px solid #ccc !important; }
  a[href]::after { content: none; }
  .module-card { break-inside: avoid; }
  body { font-size: 13px; }
}
