/* ============================================
   THANH LÝ BĐS - Trang quản trị
   ============================================ */

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

:root {
  --primary: #008C4F;
  --primary-dark: #006B3C;
  --primary-light: #e6f4ec;
  --accent-gold: #E49F15;
  --accent-red: #e74c3c;
  --accent-blue: #2f80ed;
  --navy: #1a2332;
  --navy-light: #243447;
  --white: #ffffff;
  --gray-50: #f8fafb;
  --gray-100: #f0f3f5;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e0;
  --gray-400: #a0aec0;
  --gray-500: #718096;
  --gray-600: #4a5568;
  --gray-700: #2d3748;
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 14px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: all .25s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Roboto', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--gray-50);
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, select, textarea { font-family: inherit; outline: none; }
h1, h2, h3, h4 { font-family: 'Inter', sans-serif; }

.adm-container { max-width: 1320px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }

/* ===== Màn hình đăng nhập ===== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, #0f1620 100%);
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-icon {
  width: 56px; height: 56px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: grid; place-items: center;
}
.login-icon svg { width: 26px; height: 26px; }
.login-box h1 { font-size: 20px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.login-box p { font-size: 14px; color: var(--text-secondary); margin-bottom: 22px; }
.login-box input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 15px;
  margin-bottom: 8px;
  text-align: center;
  letter-spacing: 1px;
}
.login-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,140,79,.12); }
.login-error { color: var(--accent-red); font-size: 13px; margin-bottom: 12px; text-align: left; }
.login-box .btn-block { margin-top: 8px; }
code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; font-size: .92em; }

/* ===== Header ===== */
.adm-header {
  background: var(--navy);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.adm-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
}
.adm-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 18px;
  white-space: nowrap;
}
.adm-logo-icon {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 9px;
  display: grid; place-items: center;
}
.adm-logo-icon svg { width: 20px; height: 20px; }
.adm-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  padding: 3px 8px;
  border-radius: 999px;
}
.adm-header-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  background: var(--gray-100);
  color: var(--text-primary);
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: rgba(255,255,255,.1); color: var(--white); border: 1px solid rgba(255,255,255,.22); }
.btn-ghost:hover { background: rgba(255,255,255,.2); }
.btn-outline { background: var(--white); border: 1px solid var(--gray-300); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fdecea; color: var(--accent-red); }
.btn-danger:hover { background: var(--accent-red); color: var(--white); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }

/* ===== Cảnh báo ===== */
.adm-alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 20px;
  border-left: 4px solid;
}
.adm-alert svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.adm-alert-warn { background: #fff8e6; border-color: var(--accent-gold); color: #7a5200; }
.adm-alert-info { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }
.adm-alert-error { background: #fdecea; border-color: var(--accent-red); color: #a52a1a; }
.adm-alert strong { display: block; margin-bottom: 2px; font-weight: 700; }
.adm-alert.hidden { display: none; }

/* ===== Thống kê ===== */
.adm-main { padding: 28px 0 60px; }
.adm-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.stat-card .stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  font-weight: 600;
}
.stat-card .stat-value {
  font-family: 'Inter', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
  margin-top: 4px;
}
.stat-card .stat-value.small { font-size: 21px; }
.stat-card .stat-hint { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ===== Thanh công cụ ===== */
.adm-toolbar {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.adm-search {
  position: relative;
  flex: 1 1 260px;
  min-width: 200px;
}
.adm-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--gray-400);
}
.adm-search input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: var(--transition);
}
.adm-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,140,79,.12); }
.adm-toolbar select {
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--white);
  cursor: pointer;
}
.adm-toolbar select:focus { border-color: var(--primary); }
.adm-toolbar .spacer { flex: 1 1 auto; }

/* ===== Bảng ===== */
.adm-table-wrap {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
table.adm-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.adm-table thead th {
  text-align: left;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  background: var(--gray-50);
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.adm-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  font-size: 14px;
}
.adm-table tbody tr:last-child td { border-bottom: none; }
.adm-table tbody tr:hover { background: var(--gray-50); }
.cell-property { display: flex; gap: 12px; align-items: center; min-width: 300px; }
.cell-thumb {
  width: 62px; height: 46px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--gray-100);
}
.cell-title {
  font-weight: 600;
  color: var(--navy);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}
.cell-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.cell-price { font-weight: 700; color: var(--primary); white-space: nowrap; }
.cell-price small { display: block; font-weight: 400; color: var(--gray-400); text-decoration: line-through; font-size: 12px; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  color: var(--gray-600);
  transition: var(--transition);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--primary); color: var(--white); }
.icon-btn.danger:hover { background: var(--accent-red); }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-type { background: var(--primary-light); color: var(--primary-dark); }
.pill-available { background: #e6f7ef; color: #087f52; }
.pill-pending { background: #fff4e0; color: #b57200; }
.pill-sold { background: var(--gray-200); color: var(--gray-600); }
.pill-hot { background: #fdecea; color: var(--accent-red); }
.pill-new { background: #e8f1fd; color: var(--accent-blue); }
.pill-sale { background: #fff4e0; color: #b57200; }
.pill-muted { background: var(--gray-100); color: var(--gray-500); }

.adm-empty { padding: 60px 20px; text-align: center; color: var(--text-secondary); }
.adm-empty svg { width: 54px; height: 54px; color: var(--gray-300); margin: 0 auto 12px; }
.adm-empty h3 { font-size: 17px; color: var(--gray-600); margin-bottom: 4px; }

.adm-footnote {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: center;
}

/* ===== Panel biểu mẫu (trượt từ phải) ===== */
.adm-overlay {
  position: fixed; inset: 0;
  background: rgba(26,35,50,.5);
  opacity: 0; visibility: hidden;
  transition: var(--transition);
  z-index: 100;
}
.adm-overlay.active { opacity: 1; visibility: visible; }

.adm-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(720px, 100%);
  background: var(--white);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: -10px 0 40px rgba(0,0,0,.15);
}
.adm-panel.active { transform: translateX(0); }
.adm-panel-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
}
.adm-panel-head h2 { font-size: 18px; font-weight: 700; color: var(--navy); }
.adm-panel-head .close-btn {
  margin-left: auto;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 17px;
  display: grid; place-items: center;
}
.adm-panel-head .close-btn:hover { background: var(--accent-red); color: var(--white); }
.adm-panel-body { flex: 1; overflow-y: auto; padding: 22px 24px; }
.adm-panel-foot {
  padding: 14px 24px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== Biểu mẫu ===== */
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary);
  margin: 24px 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--gray-200);
}
.form-section-title:first-child { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.field label .req { color: var(--accent-red); }
.field input, .field select, .field textarea {
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--white);
  transition: var(--transition);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 86px; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,140,79,.12);
}
.field input[readonly] { background: var(--gray-100); color: var(--gray-600); }
.field .hint { font-size: 12px; color: var(--text-secondary); }
.field .hint.strong { color: var(--primary); font-weight: 600; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--accent-red); }
.field .err { display: none; font-size: 12px; color: var(--accent-red); font-weight: 500; }
.field.has-error .err { display: block; }

/* ===== Chọn ảnh (nhiều ảnh) ===== */
.image-picker { display: flex; flex-direction: column; gap: 14px; padding: 4px; border-radius: var(--radius-md); }
.image-picker.has-error { outline: 1.5px dashed var(--accent-red); outline-offset: 6px; }
.image-picker.has-error .err { display: block; }

.image-gallery { display: flex; gap: 10px; flex-wrap: wrap; min-height: 92px; }
.image-gallery-item {
  position: relative;
  width: 108px; height: 84px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.image-gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.image-cover-badge {
  position: absolute; left: 0; bottom: 0; right: 0;
  background: rgba(0,140,79,0.88);
  color: var(--white);
  font-size: 10px; font-weight: 700;
  text-align: center;
  padding: 2px 4px;
}
.image-remove-btn {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: var(--white);
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.image-remove-btn:hover { background: var(--accent-red); }

/* Trạng thái chưa có ảnh nào */
.image-gallery-empty {
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-height: 92px;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--gray-300);
  background: var(--gray-50);
  color: var(--gray-400);
  font-size: 12.5px;
}
.image-gallery-empty.show { display: flex; }
.image-gallery-empty svg { width: 26px; height: 26px; }

.image-controls { display: flex; flex-direction: column; gap: 9px; }

/* Khối ảnh mẫu - chỉ để xem, không bấm chọn được */
.preset-images-block { margin-top: 4px; }
.preset-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.5;
}
.preset-images { display: flex; gap: 8px; flex-wrap: wrap; }
.preset-images .preset-thumb {
  width: 58px; height: 44px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  opacity: .7;
  filter: grayscale(.15);
  cursor: default;
}
.preset-images .preset-thumb img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

/* ===== Hộp thoại xác nhận ===== */
.adm-confirm {
  position: fixed; inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
  background: rgba(26,35,50,.55);
  padding: 20px;
}
.adm-confirm.active { display: grid; }
.adm-confirm-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 26px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.adm-confirm-box .cf-icon {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: #fdecea;
  color: var(--accent-red);
  display: grid; place-items: center;
  margin: 0 auto 14px;
}
.adm-confirm-box .cf-icon svg { width: 26px; height: 26px; }
.adm-confirm-box h3 { font-size: 18px; color: var(--navy); margin-bottom: 6px; }
.adm-confirm-box p { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }
.adm-confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  background: var(--navy);
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  opacity: 0;
  transform: translateY(14px);
  transition: var(--transition);
  border-left: 4px solid var(--primary);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-left-color: var(--accent-red); }
.toast-warn { border-left-color: var(--accent-gold); }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .adm-header-inner { height: auto; padding: 12px 0; flex-wrap: wrap; }
  .adm-header-actions { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .adm-panel-foot { flex-wrap: wrap; }
  .adm-panel-foot .btn { flex: 1 1 130px; }
  .toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}
@media (max-width: 520px) {
  .adm-logo { font-size: 16px; }
  .adm-tag { display: none; }
  .adm-panel-body { padding: 18px 16px; }
  .adm-panel-head { padding: 14px 16px; }
}
