/* ============================================================
   Omnoi Group — Internal Communication Portal
   Brand colors (from Brand Guide 2026):
   Navy #003149 | Blue #6a9dbd | Maroon #7a1315 | Red #ed1c24 | Cream #fff0d8
   Font: Prompt (Google Fonts)
   ============================================================ */

:root {
  --navy: #003149;
  --blue: #6a9dbd;
  --maroon: #7a1315;
  --red: #ed1c24;
  --cream: #fff0d8;
  --ink: #14232c;
  --border: #e3d9c6;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Prompt", "Segoe UI", system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Top nav ---------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: #fff;
  padding: 14px 24px;
}
.topnav-left { display: flex; align-items: center; gap: 10px; }
.topnav-home-link { display: flex; align-items: center; gap: 10px; }
.topnav-home-link:hover .topnav-title { text-decoration: underline; }
.topnav-mark { height: 32px; width: auto; }
.topnav-title { font-weight: 700; letter-spacing: 0.3px; }
.topnav-sep { opacity: 0.5; }
.topnav-active { color: var(--blue); font-weight: 500; }
.topnav-right { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  transition: background 0.15s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); }

/* ---------- Page shell ---------- */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}
.page h1 { margin: 0 0 6px; color: var(--navy); font-size: 28px; }
.page-subtitle { color: #55636b; margin: 0 0 28px; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--maroon) 55%, var(--red) 85%, var(--blue) 100%);
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  text-align: center;
}
.login-logo { height: 64px; width: auto; margin-bottom: 16px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; color: var(--navy); }
.login-card .subtitle { font-size: 13px; color: #6b7a82; margin: 0 0 24px; }
.login-form { display: flex; flex-direction: column; text-align: left; gap: 6px; }
.login-form label { font-size: 12px; font-weight: 600; color: var(--navy); margin-top: 8px; }
.login-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.login-form input:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.login-form button {
  margin-top: 18px;
  background: var(--red);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s;
}
.login-form button:hover { background: var(--maroon); }
.error { color: var(--red); font-size: 13px; margin-top: 10px; }
.demo-hint {
  margin-top: 22px;
  text-align: left;
  font-size: 12px;
  color: #6b7a82;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.demo-hint summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.demo-hint code { background: var(--cream); padding: 1px 5px; border-radius: 4px; }
.demo-hint .warn { color: var(--maroon); font-style: italic; margin-top: 10px; }
.demo-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 11px; }
.demo-table th, .demo-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.demo-table th { color: var(--navy); }

/* ---------- Dashboard ---------- */
.dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}
.dept-card {
  background: #fff;
  border: 1px solid var(--border);
  border-top: 4px solid var(--dept-color, var(--navy));
  border-radius: var(--radius);
  padding: 20px;
  display: block;
  transition: transform 0.15s, box-shadow 0.15s;
}
.dept-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,0.08); }
.dept-card-icon { font-size: 26px; margin-bottom: 8px; }
.dept-card h3 { margin: 0 0 4px; color: var(--navy); font-size: 17px; }
.dept-card-count { margin: 0 0 8px; font-size: 12px; color: #7a8990; }
.dept-card-latest { margin: 0; font-size: 13px; color: #33454e; }
.empty-state { color: #7a8990; font-style: italic; }
.section-heading { margin: 40px 0 4px; color: var(--navy); font-size: 20px; }

/* ---------- กล่องค้นหา + แท็ก ---------- */
.search-bar { margin: 14px 0 24px; }
.search-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.search-input:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag-chip {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--navy);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s;
}
.tag-chip:hover { border-color: var(--blue); }
.tag-chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.search-result-count { font-size: 12px; color: #7a8990; margin: 0 0 4px; }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.post-tag { font-size: 11px; color: var(--blue); font-weight: 600; }
.dept-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--dept-color, var(--navy));
  padding: 2px 9px;
  border-radius: 999px;
}
.post-view-dept-link { display: inline-block; font-size: 12px; font-weight: 600; color: var(--navy); }
.tag-checkbox-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.tag-checkbox {
  display: flex !important;
  align-items: center;
  gap: 6px;
  font-weight: 500 !important;
  font-size: 13px;
  background: var(--cream);
  padding: 6px 12px;
  border-radius: 999px;
  margin-top: 0 !important;
}
.tag-checkbox input { width: auto; }
.add-tag-row { display: flex; gap: 8px; margin-top: 10px; }
.add-tag-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}
.btn-small { padding: 8px 14px; font-size: 12px; }

.existing-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.existing-files:empty { display: none; }
.existing-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cream);
  border: 1px solid var(--border);
  padding: 4px 8px 4px 4px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--navy);
}
.existing-file-chip img { width: 22px; height: 22px; object-fit: cover; border-radius: 50%; }
.remove-file-btn {
  background: var(--maroon);
  color: #fff;
  border: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.custom-badge.edited-badge { background: var(--maroon); }
.post-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

/* ---------- ตารางจัดการผู้ใช้ ---------- */
.user-table { width: 100%; border-collapse: collapse; margin-top: 24px; background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.user-table th, .user-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.user-table th { background: var(--cream); color: var(--navy); font-weight: 700; }
.user-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-reset { display: flex; gap: 6px; align-items: center; }
.inline-reset input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  width: 120px;
}
.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-right: 4px;
}

/* ---------- Department feed ---------- */
.back-link { display: inline-block; margin-bottom: 14px; font-size: 13px; color: var(--navy); font-weight: 600; }
.dept-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.dept-header-row h1 { margin: 0; }
.post-list { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.post-card {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--dept-color, var(--navy));
  border-radius: var(--radius);
  padding: 20px 22px;
  position: relative;
}
.badges { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.pin-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--maroon);
}
.custom-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--blue);
  padding: 2px 9px;
  border-radius: 999px;
}
.post-card h3 { margin: 0 0 4px; color: var(--navy); }
.post-meta { margin: 0 0 10px; font-size: 12px; color: #7a8990; }
.post-body { margin: 0; font-size: 14px; line-height: 1.6; color: #33454e; white-space: pre-wrap; }

.post-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.post-photo-link { display: block; position: relative; }
.post-photo-link:hover .post-photo { opacity: 0.85; }
.post-photo {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}
.post-pdfs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pdf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cream);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--navy);
  font-weight: 600;
}
.pdf-chip:hover { background: #ffe6b8; }

/* ---------- ฟอร์มเพิ่มข่าว ---------- */
.add-news-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-top: 18px;
}
.add-news-card h3 { margin: 0 0 12px; color: var(--navy); font-size: 16px; }
.add-news-form { display: flex; flex-direction: column; }
.add-news-form label { font-size: 13px; font-weight: 600; color: var(--navy); margin-top: 14px; margin-bottom: 4px; }
.add-news-form input[type="text"],
.add-news-form input[type="password"],
.add-news-form textarea,
.add-news-form select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: #fff;
}
.add-news-form input[type="file"] { font-size: 13px; font-family: inherit; }
.file-hint { font-size: 12px; color: #7a8990; margin-top: 4px; }
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 500 !important;
}
.checkbox-label input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.form-actions .btn-primary { margin-top: 0; }
button.btn-primary { border: none; }
.btn-ghost-dark {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--navy);
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}

/* ---------- Access denied ---------- */
.access-denied {
  text-align: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
}
.access-denied h1 { color: var(--maroon); }
.btn-primary {
  display: inline-block;
  margin-top: 18px;
  background: var(--navy);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}

@media (max-width: 520px) {
  .topnav-title { display: none; }
  .topnav-user { display: none; }
  .page { padding: 24px 16px 48px; }
}
