/* =====================================================================
   Giao diện trang quản lý (dùng chung): danh sách, form, tải tệp.
   Màu lấy từ bộ biến --app-* của layout nên đổi theme vẫn khớp.
   Mọi class có tiền tố adm- để không đụng trang bản đồ.
   ===================================================================== */

.adm-page { max-width: 1180px; margin: 0 auto; padding: 8px 4px 40px; color: var(--app-ink); }
.adm-page *, .adm-page *::before, .adm-page *::after { box-sizing: border-box; }
.adm-page a { text-decoration: none; }

/* ---------- Đầu trang ---------- */
.adm-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.adm-crumb { font-size: 13px; color: var(--app-muted); margin-bottom: 4px; }
.adm-crumb a { color: var(--app-muted); }
.adm-crumb a:hover { color: var(--app-primary); }
.adm-title { margin: 0; font-family: var(--app-heading-font, Georgia, serif); font-size: 26px; font-weight: 700; color: var(--app-ink); line-height: 1.2; }
.adm-sub { margin-top: 4px; font-size: 14px; color: var(--app-muted); }
.adm-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Nút ---------- */
.adm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s; white-space: nowrap; font-family: inherit; }
.adm-btn:focus-visible { outline: 3px solid rgba(139, 37, 0, 0.25); outline-offset: 2px; }
.adm-btn-primary { background: var(--app-primary); color: #fff; }
.adm-btn-primary:hover { color: #fff; filter: brightness(1.1); }
.adm-btn-ghost { background: #fff; color: var(--app-ink); border-color: var(--app-line); }
.adm-btn-ghost:hover { border-color: var(--app-primary); color: var(--app-primary); }
.adm-btn-danger { background: #fff; color: #b3261e; border-color: #f0c9c6; }
.adm-btn-danger:hover { background: #b3261e; color: #fff; border-color: #b3261e; }
.adm-btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.adm-btn-block { width: 100%; }

.adm-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--app-line); background: #fff; color: var(--app-muted); cursor: pointer; transition: 0.15s; font-size: 14px; padding: 0; }
.adm-icon-btn:hover { color: var(--app-primary); border-color: var(--app-primary); }
.adm-icon-btn.is-danger:hover { color: #fff; background: #b3261e; border-color: #b3261e; }

/* ---------- Ghi chú / thông báo ---------- */
.adm-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 10px; font-size: 13px; line-height: 1.5; margin-bottom: 16px; background: #fff8ec; border: 1px solid #f1d9ab; color: #6b4a00; }
.adm-note i { margin-top: 2px; }
.adm-note code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; color: inherit; }

/* ---------- Thanh lọc ---------- */
.adm-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.adm-search { position: relative; flex: 1 1 260px; max-width: 380px; }
.adm-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--app-muted); font-size: 13px; pointer-events: none; }
.adm-search input { width: 100%; height: 40px; padding: 0 12px 0 36px; border-radius: 10px; border: 1px solid var(--app-line); background: #fff; font-size: 14px; font-family: inherit; color: var(--app-ink); }
.adm-select { height: 40px; padding: 0 32px 0 12px; border-radius: 10px; border: 1px solid var(--app-line); background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a4636'/%3E%3C/svg%3E") no-repeat right 12px center; font-size: 14px; font-family: inherit; color: var(--app-ink); appearance: none; -webkit-appearance: none; cursor: pointer; }
.adm-search input:focus, .adm-select:focus { outline: none; border-color: var(--app-primary); box-shadow: 0 0 0 3px rgba(139, 37, 0, 0.12); }
.adm-count { margin-left: auto; font-size: 13px; color: var(--app-muted); }

/* ---------- Bảng danh sách ---------- */
.adm-card { background: #fff; border: 1px solid var(--app-line); border-radius: 14px; box-shadow: 0 1px 2px rgba(44, 30, 22, 0.04); }
.adm-table { width: 100%; border-collapse: collapse; }
.adm-table th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--app-muted); background: var(--app-paper); padding: 12px 16px; border-bottom: 1px solid var(--app-line); white-space: nowrap; }
.adm-table th:first-child { border-top-left-radius: 14px; }
.adm-table th:last-child { border-top-right-radius: 14px; }
.adm-table td { padding: 12px 16px; border-bottom: 1px solid #f1ebe1; font-size: 14px; vertical-align: middle; }
.adm-table tbody tr:last-child td { border-bottom: none; }
.adm-table tbody tr { transition: background 0.12s; }
.adm-table tbody tr:hover { background: #fcfaf6; }
.adm-table .adm-col-actions { width: 1%; white-space: nowrap; text-align: right; }
.adm-table td:first-child { min-width: 260px; }
.adm-actions { display: inline-flex; gap: 6px; align-items: center; }
.adm-actions form { display: inline; margin: 0; }

.adm-item { display: flex; align-items: center; gap: 12px; min-width: 0; }
.adm-thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--app-paper); border: 1px solid var(--app-line); display: flex; align-items: center; justify-content: center; color: var(--app-muted); font-size: 16px; }
.adm-item-name { font-weight: 700; color: var(--app-ink); line-height: 1.3; }
.adm-item-name:hover { color: var(--app-primary); }
.adm-item-meta { font-size: 12px; color: var(--app-muted); margin-top: 2px; }

.adm-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--app-paper); border: 1px solid var(--app-line); color: var(--app-ink); margin: 2px 4px 2px 0; white-space: nowrap; }
.adm-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.adm-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.adm-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.adm-badge-on { background: #e7f4ee; color: #1d7a4f; }
.adm-badge-off { background: #f3eeea; color: #7c6a5c; }
.adm-badge-info { background: #f6ecdf; color: #8a5a00; }
.adm-muted { color: var(--app-muted); }

.adm-empty { padding: 48px 16px; text-align: center; color: var(--app-muted); }
.adm-empty i { font-size: 28px; color: var(--app-line); display: block; margin-bottom: 10px; }
.adm-no-match { display: none; }

/* Mobile: mỗi dòng thành một thẻ */
@media (max-width: 760px) {
    .adm-title { font-size: 22px; }
    .adm-head-actions { width: 100%; }
    .adm-head-actions .adm-btn { flex: 1; }
    .adm-search { max-width: none; }
    .adm-count { width: 100%; margin-left: 0; }
    .adm-table thead { display: none; }
    .adm-table, .adm-table tbody, .adm-table tr, .adm-table td { display: block; width: 100%; }
    .adm-table tr { padding: 12px 14px; border-bottom: 1px solid #f1ebe1; }
    .adm-table tbody tr:last-child { border-bottom: none; }
    .adm-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
    .adm-table td { display: contents; padding: 0; border: none; }
    .adm-table td:first-child { display: block; width: 100%; min-width: 0; margin-bottom: 4px; }
    .adm-table td[data-label] > .adm-muted { display: none; }   /* ô trống "—" không cần hiện trên thẻ */
    .adm-table td.adm-hide-mobile { display: none; }
    .adm-table .adm-col-actions { display: block; width: auto; margin-left: auto; }
    .adm-table .adm-chip { margin: 0; }
    .adm-toolbar .adm-select { flex: 1; }
}

/* =====================================================================
   FORM
   ===================================================================== */
.adm-form-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.adm-toc { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 2px; }
.adm-toc a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--app-muted); }
.adm-toc a i { width: 16px; text-align: center; }
.adm-toc a:hover, .adm-toc a.is-current { background: #fff; color: var(--app-primary); }
.adm-form-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.adm-section { background: #fff; border: 1px solid var(--app-line); border-radius: 14px; padding: 22px 24px; scroll-margin-top: 80px; }
.adm-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.adm-section h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--app-ink); display: flex; align-items: center; gap: 10px; font-family: inherit; }
.adm-section h2 i { color: var(--app-primary); font-size: 15px; }
.adm-section-desc { margin: -8px 0 16px; font-size: 13px; color: var(--app-muted); }

.adm-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.adm-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; }
.adm-span-2 { grid-column: span 2; }

.adm-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin-bottom: 16px; }
.adm-grid-2 > .adm-field, .adm-grid-3 > .adm-field { margin-bottom: 0; }
.adm-grid-2 + .adm-field, .adm-grid-3 + .adm-field, .adm-grid-2 + .adm-grid-2 { margin-top: 16px; }
.adm-field:last-child { margin-bottom: 0; }
.adm-label { font-size: 13px; font-weight: 700; color: var(--app-ink); display: flex; align-items: center; gap: 6px; }
.adm-label .req { color: #b3261e; }
.adm-hint { font-size: 12px; color: var(--app-muted); line-height: 1.45; }

.adm-input, .adm-textarea, .adm-form select.adm-input { width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid #ddd2c2; border-radius: 10px; background: #fff; font-size: 14px; font-family: inherit; color: var(--app-ink); transition: border-color 0.15s, box-shadow 0.15s; }
.adm-textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.adm-input:focus, .adm-textarea:focus { outline: none; border-color: var(--app-primary); box-shadow: 0 0 0 3px rgba(139, 37, 0, 0.12); }
.adm-input[multiple] { padding: 6px; }
.adm-input-sm { min-height: 34px; padding: 6px 10px; font-size: 13px; border-radius: 8px; }

/* Thanh chọn ngôn ngữ nhập liệu: chỉ hiện ô của ngôn ngữ đang chọn */
.adm-langbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 18px; background: rgba(255, 252, 248, 0.92); backdrop-filter: blur(6px); border: 1px solid var(--app-line); border-radius: 12px; }
.adm-langbar-label { font-size: 13px; font-weight: 700; color: var(--app-muted); }
.adm-langtabs { display: inline-flex; background: var(--app-bg); border-radius: 10px; padding: 3px; gap: 2px; }
.adm-langtab { border: none; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--app-muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-family: inherit; }
.adm-langtab.is-active { background: #fff; color: var(--app-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.adm-langtab .need { width: 6px; height: 6px; border-radius: 50%; background: #d9a441; display: none; }
.adm-langtab.has-empty .need { display: inline-block; }
.adm-langbar-tip { font-size: 12px; color: var(--app-muted); margin-left: auto; }
.adm-form [data-lang] { display: none; }
.adm-form[data-active-lang="vi"] [data-lang="vi"],
.adm-form[data-active-lang="en"] [data-lang="en"],
.adm-form[data-active-lang="fr"] [data-lang="fr"],
.adm-form .tox-tinymce { border-radius: 10px !important; border-color: #ddd2c2 !important; }

/* Danh sách dòng lặp (link 360...) */
.adm-repeat-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; align-items: center; margin-bottom: 10px; }

/* Ngày lễ hội: tên | âm/dương | ngày/tháng | xoá */
.adm-repeat-row.adm-fest-row { grid-template-columns: minmax(0, 2fr) 130px 170px auto; }
.adm-repeat-row.adm-video-row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; }
.adm-video-row input[readonly] { background: #f6f1e8; color: var(--app-muted); }
.adm-cluster-note { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: #fff8ec; border: 1px solid #f1d9ab; font-size: 13px; color: #6b4a00; }
.adm-cluster-note a { color: var(--app-primary); font-weight: 700; }
.adm-fest-dm { display: flex; align-items: center; gap: 6px; }
.adm-fest-dm span { color: var(--app-muted); }
.adm-fest-dm .adm-input { text-align: center; padding-left: 6px; padding-right: 6px; }

/* Tải tệp */
.adm-upload { position: relative; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1.5px dashed #d8c9b2; border-radius: 12px; background: var(--app-paper); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.adm-upload:hover, .adm-upload.is-drag { border-color: var(--app-primary); background: #fff; }
.adm-upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.adm-upload-icon { width: 38px; height: 38px; border-radius: 10px; background: #fff; border: 1px solid var(--app-line); display: flex; align-items: center; justify-content: center; color: var(--app-primary); flex-shrink: 0; }
.adm-upload-text { font-size: 13px; line-height: 1.4; min-width: 0; }
.adm-upload-text b { color: var(--app-ink); display: block; }
.adm-upload-text span { color: var(--app-muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.adm-meta-list { display: none; flex-direction: column; gap: 10px; margin-top: 10px; }
.adm-meta-list.has-items { display: flex; }
.adm-meta-item { padding: 10px 12px; border: 1px solid var(--app-line); border-radius: 10px; background: #fff; }
.adm-meta-item-name { font-size: 12px; font-weight: 700; color: var(--app-primary); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ảnh / tệp đã có */
.adm-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.adm-media { border: 1px solid var(--app-line); border-radius: 12px; overflow: hidden; background: #fff; display: flex; flex-direction: column; transition: opacity 0.15s, border-color 0.15s; }
.adm-media-img { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; background: var(--app-paper); display: block; }
.adm-media-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.adm-media-doc { display: flex; align-items: center; gap: 10px; padding: 10px; border-bottom: 1px solid #f1ebe1; font-size: 13px; font-weight: 600; color: var(--app-ink); min-width: 0; }
.adm-media-doc i { color: var(--app-primary); font-size: 18px; flex-shrink: 0; }
.adm-media-doc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-media-doc:hover { color: var(--app-primary); }
.adm-del { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #b3261e; cursor: pointer; user-select: none; margin: 0; }
.adm-del input { accent-color: #b3261e; width: 15px; height: 15px; margin: 0; }
.adm-media:has(.adm-del input:checked) { opacity: 0.45; border-color: #e6a8a3; }
.adm-media:has(.adm-del input:checked) .adm-media-img { filter: grayscale(1); }
.adm-avatar-row { display: flex; gap: 16px; align-items: center; }
.adm-avatar-row .adm-media { width: 160px; flex-shrink: 0; }
.adm-empty-inline { font-size: 13px; color: var(--app-muted); font-style: italic; margin-bottom: 10px; }

.adm-audio-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.adm-audio { border: 1px solid var(--app-line); border-radius: 12px; padding: 12px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.adm-audio-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; }
.adm-audio audio { width: 100%; height: 34px; }
.adm-audio:has(.adm-del input:checked) audio { opacity: 0.4; }

/* Công tắc bật/tắt */
.adm-switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; margin: 0; }
.adm-switch input { position: absolute; opacity: 0; pointer-events: none; }
.adm-switch-track { position: relative; width: 42px; height: 24px; border-radius: 999px; background: #d6ccbd; flex-shrink: 0; transition: background 0.2s; margin-top: 1px; }
.adm-switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.2s; }
.adm-switch input:checked + .adm-switch-track { background: #1d7a4f; }
.adm-switch input:checked + .adm-switch-track::after { transform: translateX(18px); }
.adm-switch input:focus-visible + .adm-switch-track { outline: 3px solid rgba(139, 37, 0, 0.25); outline-offset: 2px; }
.adm-switch-text b { display: block; font-size: 14px; color: var(--app-ink); }
.adm-switch-text span { font-size: 12px; color: var(--app-muted); }

/* Lựa chọn dạng ô đánh dấu (phố, hành trình...) */
.adm-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.adm-check { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--app-line); border-radius: 999px; background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; user-select: none; margin: 0; transition: 0.15s; }
.adm-check input { accent-color: var(--app-primary); margin: 0; }
.adm-check:has(input:checked) { border-color: var(--app-primary); background: #fbf1ec; color: var(--app-primary); }

/* Bản đồ chọn vị trí */
.adm-map { height: 320px; width: 100%; border-radius: 12px; border: 1px solid var(--app-line); z-index: 1; margin-top: 4px; }

/* Thanh lưu dính dưới đáy */
.adm-savebar { position: sticky; bottom: 0; z-index: 30; display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 16px; margin-top: 4px; background: rgba(255, 252, 248, 0.95); backdrop-filter: blur(6px); border: 1px solid var(--app-line); border-radius: 14px; box-shadow: 0 -4px 16px rgba(44, 30, 22, 0.08); }
.adm-savebar-note { margin-right: auto; font-size: 12px; color: var(--app-muted); }

@media (max-width: 991px) {
    .adm-form-layout { grid-template-columns: minmax(0, 1fr); }
    .adm-toc { display: none; }
}
@media (max-width: 760px) {
    .adm-section { padding: 18px 16px; }
    .adm-grid-2, .adm-grid-3, .adm-audio-grid { grid-template-columns: minmax(0, 1fr); }
    .adm-span-2 { grid-column: auto; }
    .adm-repeat-row { grid-template-columns: minmax(0, 1fr); padding-bottom: 10px; border-bottom: 1px dashed var(--app-line); }
    .adm-langbar-tip { display: none; }
    .adm-savebar-note { display: none; }
    .adm-savebar .adm-btn { flex: 1; }
    .adm-avatar-row { flex-direction: column; align-items: stretch; }
    .adm-avatar-row .adm-media { width: 100%; }
}
@media (max-width: 760px) {
    .adm-repeat-row.adm-fest-row { grid-template-columns: minmax(0, 1fr) auto; }
    .adm-repeat-row.adm-fest-row > input[type="text"] { grid-column: 1 / -1; }
}
