/* HX ADMIN V2 • layout.css — bố cục nút thống nhất cho toàn bộ web admin (đi kèm layout.js) */

/* ---------- Đầu trang: tiêu đề trái • nút phải, cùng hàng ---------- */
.page-head { flex-wrap: nowrap; align-items: flex-end; }
.page-head > div:first-child { flex: 1; min-width: 0; }
.page-head > .btns { flex-wrap: nowrap; flex-shrink: 0; justify-content: flex-end; }
.page-head > .btns .btn { white-space: nowrap; }
.page-head > .btns .btn.pri { order: 99; } /* nút chính luôn nằm ngoài cùng bên phải */
@media (max-width: 1100px) {
  .page-head { flex-wrap: wrap; }
  .page-head > .btns { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .page-head > .btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .page-head > .btns .btn { width: 100%; min-width: 0; padding: 0 10px; font-size: 12.5px; }
  .page-head > .btns .btn.pri { grid-column: 1 / -1; order: -1; } /* điện thoại: nút chính lên đầu, rộng hết hàng */
  .page-head > .btns > :only-child { grid-column: 1 / -1; }
}

/* ---------- Đầu thẻ: tiêu đề trái • ô tìm + nút chính phải, cùng hàng ---------- */
.card > .head { align-items: center; flex-wrap: wrap; row-gap: 10px; }
.card > .head > div:first-child { min-width: 0; flex: 1 1 220px; }
.card > .head > .btns { flex-wrap: nowrap; align-items: center; flex: 0 1 auto; }
.card > .head > .btns > .search { flex: 1 1 240px; min-width: 160px; max-width: 320px; }
.card > .head > .btns > .btn { flex-shrink: 0; white-space: nowrap; }
.card > .head > .search { flex: 0 1 300px; min-width: 180px; }
@media (max-width: 640px) {
  .card > .head > .btns { flex: 1 1 100%; flex-wrap: wrap; }
  .card > .head > .btns > .search { max-width: none; flex: 1 1 100%; order: 2; }
  .card > .head > .btns > .btn { flex: 1 1 auto; }
  .card > .head > .search { flex: 1 1 100%; }
}

/* ---------- Hàng thao tác trong danh sách: tối đa 2 nút + "⋯" ---------- */
.rm-row { flex-wrap: nowrap !important; justify-content: flex-end; align-items: center; gap: 6px !important; flex-shrink: 0; max-width: none !important; width: auto !important; }
.rm-row > .btn { white-space: nowrap; }
.rm { position: relative; display: inline-flex; }
.rm-btn { min-width: 34px; padding: 0 9px; gap: 6px; }
.rm-btn.txt { padding: 0 12px; }
.btn.lg + .rm .rm-btn, .rm-bar .rm-btn { height: 42px; border-radius: 12px; font-size: 13px; }
.rm-dots { display: inline-flex; gap: 3px; }
.rm-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.rm-chev { font-size: 10px; opacity: .7; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.rm.on .rm-btn { border-color: var(--blue); color: var(--text); }
.rm-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 45; min-width: 200px; max-width: 280px; padding: 6px; background: var(--card-solid); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 40px rgba(0, 0, 0, .28); flex-direction: column; gap: 2px; }
.rm.on .rm-menu { display: flex; animation: rmIn .14s ease-out; }
.rm.up .rm-menu { top: auto; bottom: calc(100% + 6px); }
@keyframes rmIn { from { opacity: 0; transform: translateY(-4px); } }
.rm-menu > .btn, .rm-menu > label.btn, .rm-menu > a.btn {
  all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 10px;
  font: 600 13px "Be Vietnam Pro", sans-serif; color: var(--text); cursor: pointer; white-space: nowrap;
}
.rm-menu > .btn:hover, .rm-menu > .btn:focus-visible, .rm-menu > label.btn:hover, .rm-menu > a.btn:hover { background: var(--soft); }
.rm-menu > .btn[disabled] { opacity: .45; cursor: not-allowed; }
.rm-menu > .btn.danger, .rm-menu > .btn.no { color: var(--redt); background: none; }
.rm-menu > .btn.danger:hover, .rm-menu > .btn.no:hover { background: rgba(255, 90, 90, .1); }
.rm-menu svg { width: 16px; height: 16px; flex-shrink: 0; }
.rm-menu .rm-ar { width: 16px; text-align: center; font-weight: 700; color: var(--muted); }
.rm-sep { border: 0; border-top: 1px solid var(--soft); margin: 4px 6px; }
.li .rm-row, .li .nw-tb.rm-row { margin-left: auto; }
@media (max-width: 640px) {
  .li:has(> .rm-row) { flex-wrap: wrap; }
  .li:has(> .rm-row) > .grow { flex: 1 1 calc(100% - 80px); }
  .li > .rm-row { width: 100% !important; justify-content: flex-end; }
  .rm-menu { min-width: 210px; }
}

/* ---------- Thanh nút lớn (thẻ ao làng…) ---------- */
.rm-bar { gap: 8px; align-items: center; }
@media (max-width: 640px) {
  .rm-bar { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rm-bar > .btn, .rm-bar > .rm, .rm-bar > .rm .rm-btn { width: 100%; }
  .rm-bar > .btn.pri { grid-column: 1 / -1; }
}

/* ---------- Bảng nổi: chân cố định ---------- */
.sheet-foot { position: sticky; bottom: -24px; margin: 4px -24px -24px; padding: 14px 24px 20px; background: var(--card-solid); border-top: 1px solid var(--soft); display: flex; align-items: center; gap: 10px; z-index: 3; border-radius: 0 0 24px 24px; }
.sheet-foot .sf-left, .sheet-foot .sf-right { display: flex; gap: 10px; align-items: center; }
.sheet-foot .sf-right { margin-left: auto; }
.sheet-foot .btn.lg { width: auto; min-width: 120px; height: 46px; padding: 0 20px; border-radius: 13px; }
.sheet-foot .sf-left .btn.lg { background: transparent; border-color: transparent; color: var(--redt); min-width: 0; padding: 0 10px; box-shadow: none; }
.sheet-foot .sf-left .btn.lg:hover { background: rgba(255, 90, 90, .1); }
.sheet-foot.many .sf-right { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 1024px) {
  .sheet-foot { bottom: calc(-28px - env(safe-area-inset-bottom)); margin: 4px -22px calc(-28px - env(safe-area-inset-bottom)); padding: 12px 22px calc(16px + env(safe-area-inset-bottom)); border-radius: 0; flex-direction: column-reverse; align-items: stretch; }
  .sheet-foot .sf-right { margin-left: 0; flex-direction: column-reverse; align-items: stretch; }
  .sheet-foot .btn.lg { width: 100%; }
  .sheet-foot .sf-left { justify-content: center; }
}
