/* =============================================
   ADMIN PAGE — admin.css
   Design: Đồng bộ với trang chính (đỏ gradient)
   ============================================= */

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

:root {
  --primary:       #c0392b;
  --primary-dark:  #a93226;
  --primary-light: #e74c3c;
  --bg:            #f4f6f8;
  --card:          #ffffff;
  --border:        #e2e8f0;
  --text:          #2d3748;
  --text-muted:    #718096;
  --shadow-sm:     0 1px 4px rgba(0,0,0,.08);
  --shadow-md:     0 4px 20px rgba(0,0,0,.10);
  --shadow-lg:     0 12px 40px rgba(0,0,0,.14);
  --radius:        12px;
  --radius-sm:     8px;
  --green:         #27ae60;
  --orange:        #e67e22;
  --blue:          #2980b9;
  --red:           #c0392b;
}

body {
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── HEADER ─────────────────────────────────────────── */
.admin-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 3px 16px rgba(0,0,0,.22);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-logo {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}

.admin-title { font-size: 1.2rem; font-weight: 800; letter-spacing: -.01em; }
.admin-sub   { font-size: 0.78rem; opacity: .8; margin-top: 1px; }

.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 8px 16px;
  font-size: 0.85rem; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .18s, transform .12s;
}
.btn-back:hover { background: rgba(255,255,255,0.28); transform: translateY(-1px); }

/* ── LAYOUT ──────────────────────────────────────────── */
.admin-body { max-width: 1300px; margin: 32px auto; padding: 0 24px; }

/* ── TABS ────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  width: fit-content;
}

.tab-btn {
  padding: 9px 24px;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  transition: all .18s;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab-btn:hover { background: var(--bg); color: var(--text); }
.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(192,57,43,.35);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── SECTION CARD ────────────────────────────────────── */
.section-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1rem; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

/* ── SEARCH INPUT ────────────────────────────────────── */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  min-width: 220px;
}
.search-box input {
  border: none; background: transparent; outline: none;
  font-family: inherit; font-size: 0.88rem; color: var(--text);
  flex: 1; min-width: 0;
}
.search-box input::placeholder { color: var(--text-muted); }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all .18s;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(192,57,43,.3);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(192,57,43,.45); transform: translateY(-1px); }

.btn-ghost {
  background: var(--bg); color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: #edf2f7; color: var(--text); }

.btn-sm { padding: 5px 11px; font-size: 0.78rem; border-radius: 6px; }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #219150; }

.btn-warning { background: var(--orange); color: #fff; }
.btn-warning:hover { background: #ca6f1e; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--primary-dark); }

.btn-info { background: var(--blue); color: #fff; }
.btn-info:hover { background: #2471a3; }

/* ── TABLE ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table.admin-table {
  width: 100%; border-collapse: collapse;
}
table.admin-table th {
  padding: 12px 16px;
  font-size: 0.76rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  text-align: left; white-space: nowrap;
}
table.admin-table td {
  padding: 12px 16px;
  font-size: 0.88rem; color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.admin-table tr:last-child td { border-bottom: none; }
table.admin-table tr:hover td { background: #fafbfc; }

/* user avatar cell */
.tbl-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 0.82rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.tbl-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.tbl-user-cell { display: flex; align-items: center; gap: 10px; }
.tbl-user-name { font-weight: 600; font-size: 0.9rem; }
.tbl-username  { font-size: 0.76rem; color: var(--text-muted); margin-top: 1px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: .02em;
}
.badge-active   { background: rgba(39,174,96,.12); color: #1a7a42; border: 1px solid rgba(39,174,96,.25); }
.badge-inactive { background: rgba(150,150,150,.12); color: #666; border: 1px solid rgba(150,150,150,.25); }
.badge-admin    { background: rgba(41,128,185,.12); color: #1a5a8a; border: 1px solid rgba(41,128,185,.25); }
.badge-super    { background: rgba(192,57,43,.12); color: var(--primary); border: 1px solid rgba(192,57,43,.25); }
.badge-user     { background: rgba(100,100,100,.08); color: #555; border: 1px solid rgba(100,100,100,.18); }

/* action cell */
.action-cell { display: flex; gap: 5px; flex-wrap: wrap; }

/* ── EMPTY STATE ─────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 14px; opacity: .4; }
.empty-state p { font-size: 0.9rem; }

/* ── MODAL OVERLAY ───────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--card);
  border-radius: 16px;
  width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .22s cubic-bezier(.34,1.56,.64,1);
  max-height: 90vh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.3rem;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: background .15s;
}
.modal-close:hover { background: var(--bg); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── FORM FIELDS ─────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.single { grid-template-columns: 1fr; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label {
  font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.form-group .req { color: var(--primary); margin-left: 2px; }

.form-control {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.9rem; color: var(--text);
  background: #fff; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192,57,43,.12);
}
.form-control::placeholder { color: #bbb; }
.form-control.error { border-color: #e74c3c; }

/* ── PERMISSIONS PANEL ───────────────────────────────── */
.perms-select-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.perms-select-row label { font-weight: 700; font-size: 0.9rem; }
.perms-select-row select {
  flex: 1; min-width: 200px; max-width: 360px;
  padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.9rem; color: var(--text);
  background: #fff; outline: none; cursor: pointer;
  transition: border-color .18s;
}
.perms-select-row select:focus { border-color: var(--primary); }

.perms-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px; margin-bottom: 24px;
}

.perm-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: border-color .18s, box-shadow .18s;
}
.perm-card:hover { border-color: rgba(192,57,43,.3); box-shadow: 0 2px 8px rgba(192,57,43,.08); }
.perm-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.perm-card-icon { font-size: 1.3rem; }
.perm-card-title { font-size: 0.88rem; font-weight: 700; color: var(--text); }

.perm-check-list { display: flex; flex-direction: column; gap: 8px; }

.perm-check-item {
  display: flex; align-items: center; gap: 9px;
  cursor: pointer;
}
.perm-check-item input[type=checkbox] {
  width: 16px; height: 16px;
  accent-color: var(--primary); cursor: pointer; flex-shrink: 0;
}
.perm-check-item span { font-size: 0.85rem; color: var(--text); }

.perms-actions {
  display: flex; gap: 10px; padding: 20px 0 0;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* ── TOAST ───────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: #1f2937; color: #fff;
  padding: 11px 22px; border-radius: 10px;
  font-size: 0.88rem; font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap; max-width: 90vw;
}
.toast.success { background: #1a7a42; }
.toast.error   { background: #c0392b; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ── RESET PASSWORD MODAL ────────────────────────────── */
.reset-hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }

/* ── CONFIRM DIALOG ──────────────────────────────────── */
.confirm-box { max-width: 400px; }
.confirm-message { font-size: 0.92rem; color: var(--text); margin-bottom: 4px; }
.confirm-sub { font-size: 0.82rem; color: var(--text-muted); }

/* ── LOADING ─────────────────────────────────────────── */
.spinner-inline {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  border-radius: 50%; animation: spin .6s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.table-loading {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted); font-size: 0.9rem;
}

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-header { padding: 14px 18px; }
  .admin-body { padding: 0 12px; margin: 18px auto; }
  .form-row { grid-template-columns: 1fr; }
  .perms-grid { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .tab-bar { width: 100%; }
  .tab-btn { flex: 1; justify-content: center; }
}
