/* =========================================================================
   admin.css — ระบบหลังบ้าน · ฟอร์ม · หน้าล็อกอิน
   ========================================================================= */
html.admin-open { overflow: hidden; }
.admin { position: fixed; inset: 0; z-index: 100; display: none; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); }
.admin.open { display: block; animation: fadeIn .3s ease; }
.admin-bar {
  position: sticky; top: 0; z-index: 5; padding: calc(10px + var(--safe-t)) 0 10px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
}
.admin-bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin-title { white-space: nowrap; }
.admin-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.admin-content { padding-top: 18px; padding-bottom: calc(40px + var(--safe-b)); }
.admin-tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-bottom: 16px; padding-bottom: 2px; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs .btn { flex: none; }
.admin-panel { animation: fadeUp .45s var(--ease) backwards; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: clamp(16px, 3vw, 24px); }
.panel + .panel { margin-top: 16px; }
.notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 16px; padding: 10px 14px; border-radius: 10px; background: #fef3c7; color: #92400e; font-size: 14px;
}

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 13px; font-weight: 600; color: var(--muted); }
.table tbody tr { transition: background-color .2s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table .av { width: 38px; height: 38px; margin: 0; font-size: 12px; }
.t-actions { white-space: nowrap; text-align: right; }
.thumb-sm { width: 72px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }

/* ---------- Form ---------- */
.form-title { font-size: 20px; margin-bottom: 14px; }
.form-grid { display: grid; gap: 12px; }
.field label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; }
.field input:not([type=file]), .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg);
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.pw { position: relative; }
.pw input { padding-right: 42px !important; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.img-field { display: flex; gap: 12px; align-items: flex-start; }
.img-field > div { flex: 1; min-width: 0; }
.preview-img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); animation: scaleIn .3s var(--ease); }
.img-file { margin-top: 6px; font-size: 13px; max-width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- Login (สไตล์ carl.gg) ---------- */
.login-card {
  --logo: 64px; max-width: 400px; margin: clamp(20px, 6vh, 50px) auto; padding: 30px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  animation: scaleIn .5s var(--ease) backwards;
}
.login-card h2 { font-size: 22px; line-height: 1.3; }
.login-card > p { margin: 4px 0 20px; }
.login-card form { text-align: left; }
.btn-discord-lg {
  width: 100%; height: 50px; display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: var(--r); background: var(--discord); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--discord) 35%, transparent);
  transition: transform .3s var(--spring), background-color .2s, box-shadow .3s;
}
.btn-discord-lg:hover { background: #4752c4; transform: translateY(-2px); }
.btn-discord-lg:active { transform: scale(.97); }
.btn-discord-lg i { font-size: 20px; }
.or { display: flex; align-items: center; gap: 10px; margin: 20px 0 14px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.big-av .av { width: 88px; height: 88px; margin: 0 auto 10px; font-size: 28px; box-shadow: 0 0 0 4px var(--discord); animation: popIn .6s var(--spring) backwards; }
.warn-box { margin: 16px 0 10px; padding: 10px 14px; border-radius: 10px; background: #fef3c7; color: #92400e; font-size: 14px; }
.id-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; padding: 6px 10px; border-radius: var(--r-sm); background: var(--bg); }
.shake { animation: shake .45s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- Admin บนมือถือ: ตาราง → การ์ด ---------- */
@media (max-width: 640px) {
  .admin-bar .lbl-opt, .admin-bar .user-chip .lbl { display: none; }
  .table thead { display: none; }
  .table, .table tbody { display: block; }
  .table tr { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 2px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { display: block; padding: 0; border: 0; }
  .table td.t-media { grid-row: span 2; }
  .table td.t-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
  .table.plain tr { grid-template-columns: 1fr; }
  .img-field { flex-direction: column; }
}