/*
 * สไตล์ระบบหลังบ้าน (ใช้ร่วมกับ vendor/bootstrap/bootstrap.min.css)
 */
:root {
  --brand: #f2b705;
  --brand-ink: #1d2a33;
  --ink: #1d2a33;
  --mist: #f3f5f2;
  --line: #dce1dc;
  --teal: #0b6e6c;
  --sidebar-w: 264px;
}

body.admin {
  background: var(--mist);
  min-height: 100vh;
}

:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

/* ---------- เมนูด้านข้าง ---------- */
.admin-sidebar {
  --bs-offcanvas-width: var(--sidebar-w);
  --bs-offcanvas-bg: var(--ink);
  --bs-offcanvas-color: #fff;
  background: var(--ink);
  color: #fff;
}
@media (min-width: 992px) {
  .admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    visibility: visible !important;
    transform: none !important;
    background-color: var(--ink) !important;
    z-index: 1020;
    display: flex;
    flex-direction: column;
  }
}
.admin-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 6px solid var(--brand);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  line-height: 1.35;
}
.admin-sidebar__brand:hover {
  color: #fff;
  text-decoration: none;
}
.admin-sidebar__brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: #fff;
  border-radius: 0.375rem;
  padding: 3px;
}
.admin-sidebar__brand small {
  display: block;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.78rem;
}
.admin-sidebar__body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem 1.5rem;
}
.admin-sidebar__group {
  margin: 1.25rem 0.75rem 0.4rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 500;
}
.admin-sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.375rem;
  color: rgba(255, 255, 255, 0.78);
  position: relative;
}
.admin-sidebar .nav-link i {
  width: 1.25rem;
  text-align: center;
  opacity: 0.8;
}
.admin-sidebar .nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}
.admin-sidebar .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
.admin-sidebar .nav-link.active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--brand);
}
.admin-sidebar .nav-link.active i {
  color: var(--brand);
  opacity: 1;
}
.admin-sidebar .nav-sub {
  padding-left: 2rem;
}
.admin-sidebar .nav-sub .nav-link {
  padding-block: 0.4rem;
  font-size: 0.95rem;
}
.admin-sidebar__user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.admin-sidebar__user img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.admin-sidebar__user small {
  display: block;
  color: rgba(255, 255, 255, 0.6);
}

/* ---------- ส่วนเนื้อหา ---------- */
@media (min-width: 992px) {
  .admin-main {
    margin-left: var(--sidebar-w);
  }
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 1010;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.admin-topbar .breadcrumb {
  margin: 0;
  font-size: 0.9rem;
}

.admin-content {
  padding: 1.5rem 1.25rem 3rem;
}
@media (min-width: 1200px) {
  .admin-content {
    padding-inline: 2rem;
  }
}

.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-title h1 {
  font-size: 1.6rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.page-title h1 i {
  color: #5b6870;
  font-size: 1.25rem;
}
.page-title p {
  margin: 0.15rem 0 0;
  color: #5b6870;
}
.page-title__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
}
.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.panel__head h2 {
  font-size: 1.1rem;
  margin: 0;
}
.panel__body {
  padding: 1.25rem;
}
.panel__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
  border-radius: 0 0 0.75rem 0.75rem;
}
.panel__foot .pagination {
  margin: 0;
}
.panel > .table-responsive > .table {
  margin: 0;
}

.table-admin {
  --bs-table-hover-bg: #f7f9f7;
  vertical-align: middle;
}
.table-admin thead th {
  font-weight: 500;
  color: #5b6870;
  font-size: 0.875rem;
  background: #fbfcfb;
  white-space: nowrap;
  border-bottom-width: 1px;
}
.table-admin td,
.table-admin th {
  padding: 0.75rem 1rem;
}
.table-admin .item-title {
  font-weight: 500;
}
.table-admin .item-link {
  display: block;
  max-width: 38rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  color: #5b6870;
}
.table-admin .thumb {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border-radius: 0.375rem;
  background: var(--mist);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
  white-space: nowrap;
}
.row-actions form {
  margin: 0;
}

.drag-handle {
  cursor: grab;
  color: #5b6870;
  padding: 0.25rem 0.4rem;
  border: 0;
  background: none;
}
.drag-handle:active {
  cursor: grabbing;
}

.sortable-ghost {
  opacity: 0.4;
  background: #fff7d6 !important;
}

.menu-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}
.menu-tree .menu-tree {
  margin-left: 2.25rem;
  border-left: 2px solid var(--line);
}
.menu-tree__item > .menu-tree__row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.menu-tree__name {
  flex: 1;
  min-width: 0;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.filter-chips .btn {
  border-radius: 999px;
  padding: 0.25rem 0.9rem;
  font-size: 0.9rem;
}

.form-label {
  font-weight: 500;
}

.form-hint {
  font-size: 0.85rem;
  color: #5b6870;
  margin-top: 0.3rem;
}

.cover-preview {
  display: block;
  max-width: 100%;
  max-height: 160px;
  margin-top: 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid var(--line);
}

.avatar-picker {
  text-align: center;
}
.avatar-picker img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  margin-bottom: 1rem;
}

.permission-group {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.permission-group__title {
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.image-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}
.image-board__item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
  background: #fff;
  cursor: grab;
}
.image-board__item img {
  width: 100%;
  aspect-ratio: 400/266;
  object-fit: cover;
  display: block;
}
.image-board__item .btn {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
}
.image-board__item figcaption {
  font-size: 0.78rem;
  padding: 0.35rem 0.5rem;
  color: #5b6870;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats > .col {
  border-bottom: 1px solid var(--line);
}
.stats > .col:nth-child(odd) {
  border-right: 1px solid var(--line);
}
@media (min-width: 992px) {
  .stats > .col {
    border-bottom: 0;
  }
  .stats > .col:not(:last-child) {
    border-right: 1px solid var(--line);
  }
}

.stat {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  color: var(--ink);
  text-decoration: none;
}
.stat:hover {
  text-decoration: none;
  color: var(--ink);
  background: #fbfcfb;
}
.stat__icon {
  width: 3rem;
  height: 3rem;
  border-radius: 0.5rem;
  display: grid;
  place-items: center;
  background: var(--mist);
  font-size: 1.2rem;
}
.stat__value {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
}
.stat__label {
  color: #5b6870;
  font-size: 0.9rem;
}

/* ---------- หน้าเข้าสู่ระบบ ---------- */
.login {
  min-height: 100vh;
  display: grid;
  background: #fff;
}
@media (min-width: 992px) {
  .login {
    grid-template-columns: minmax(0, 5fr) minmax(0, 4fr);
  }
}
.login__brand {
  background: var(--brand);
  color: var(--brand-ink);
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
}
.login__brand img {
  height: 84px;
  width: auto;
  align-self: flex-start;
  background: #fff;
  border-radius: 0.5rem;
  padding: 0.5rem;
}
.login__brand h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.6rem);
  font-weight: 600;
  max-width: 22ch;
  margin: 0;
}
.login__brand p {
  margin: 0.75rem 0 0;
  max-width: 40ch;
  opacity: 0.85;
}
.login__form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
}
.login__form form {
  width: 100%;
  max-width: 360px;
}

.note-editor.note-frame {
  border-color: var(--line);
  border-radius: 0.5rem;
}
.note-editor.note-frame .note-toolbar {
  background: #fbfcfb;
  border-bottom: 1px solid var(--line);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

/* ---------- เพิ่มในระบบใหม่ ---------- */
.admin-sidebar .badge-count {
  margin-left: auto;
  min-width: 1.4rem;
  padding: .1rem .4rem;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: .75rem;
  font-weight: 600;
  text-align: center;
}

.admin-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-grid;
  place-items: center;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
  flex-shrink: 0;
}

.admin-avatar--sm {
  width: 24px;
  height: 24px;
  font-size: .75rem;
}

.admin-avatar--lg {
  width: 140px;
  height: 140px;
  font-size: 3rem;
  border: 4px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  margin-bottom: 1rem;
}

.thumb-portrait {
  width: 48px;
  height: 60px;
  object-fit: cover;
  border-radius: .375rem;
  background: var(--mist);
  display: inline-grid;
  place-items: center;
  color: #5b6870;
  font-weight: 600;
}

.message-unread td {
  font-weight: 500;
}

.message-unread .item-title::before {
  content: "";
  display: inline-block;
  width: .5rem;
  height: .5rem;
  margin-right: .5rem;
  border-radius: 50%;
  background: var(--teal);
  vertical-align: middle;
}

.message-body {
  white-space: pre-wrap;
  font-size: 1.05rem;
  line-height: 1.8;
}

.dl-inline dt {
  font-weight: 500;
  color: #5b6870;
}

.upload-drop {
  border: 2px dashed var(--line);
  border-radius: .5rem;
  padding: 1.25rem;
  text-align: center;
  background: #fbfcfb;
}

.upload-drop.is-over {
  border-color: var(--teal);
  background: #eef6f5;
}

.setup-card {
  max-width: 520px;
  margin: 3rem auto;
}

.list-plain {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-plain li {
  padding: .6rem 0;
  border-bottom: 1px solid var(--line);
}

.list-plain li:last-child {
  border-bottom: 0;
}
