/* VOCA Back Office — สไตล์ทั้งหมดอยู่ไฟล์เดียว ไม่พึ่ง CDN
   เหตุผล: หน้าเว็บนี้ deploy บน IIS ในองค์กรลูกค้า บางที่ออกเน็ตไม่ได้
   และไม่มี build step ของ JS/CSS ในโปรเจกต์นี้ */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #dfe1e6;
  --text: #172b4d;
  --muted: #6b778c;
  --brand: #0b6bcb;
  --brand-dark: #084d94;
  --ok: #1f845a;
  --ok-bg: #e7f6ef;
  --warn: #a54800;
  --warn-bg: #fff4e5;
  --bad: #ae2e24;
  --bad-bg: #ffecea;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(9, 30, 66, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans Thai", "Sarabun", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- โครงหน้า ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex: 0 0 230px;
  background: #0d1b2a;
  color: #c9d3df;
  padding: 18px 0;
}
.sidebar .brand {
  font-size: 20px; font-weight: 700; color: #fff;
  padding: 0 20px 14px; letter-spacing: .5px;
}
.sidebar .brand small { display: block; font-size: 12px; font-weight: 400; color: #8fa3b8; letter-spacing: 0; }
.sidebar nav a {
  display: block; padding: 9px 20px; color: #c9d3df; font-size: 14.5px;
}
.sidebar nav a:hover { background: #16293d; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar .group { padding: 16px 20px 6px; font-size: 11.5px; text-transform: uppercase; color: #7d8fa3; letter-spacing: .8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13.5px; color: var(--muted); }
.topbar .who b { color: var(--text); }

.content { padding: 22px; max-width: 1180px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 26px 0 10px; }
.lede { color: var(--muted); margin: 0 0 18px; }

/* ---------- การ์ด / ตาราง ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 18px;
}
.card h2 { margin-top: 0; }
.card-title { font-weight: 600; margin-bottom: 12px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 25px; font-weight: 700; line-height: 1.25; }
.stat .sub { font-size: 12.5px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ---------- ฟอร์ม ---------- */

label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 3px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--text);
  background: #fff; border: 1px solid #b9bec7; border-radius: 6px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
input[type=checkbox] { width: 16px; height: 16px; vertical-align: -2px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }
.inline { display: inline; }

button, .btn {
  display: inline-block; padding: 8px 15px; font: inherit; font-weight: 600;
  border-radius: 6px; border: 1px solid transparent; cursor: pointer;
  background: var(--brand); color: #fff; text-decoration: none;
}
button:hover, .btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn-plain { background: #fff; color: var(--text); border-color: #b9bec7; }
.btn-plain:hover { background: #f1f2f4; color: var(--text); }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #8e2018; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* ---------- ป้ายสถานะ / ข้อความแจ้ง ---------- */

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-muted { background: #ebecf0; color: var(--muted); }

.alert { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14.5px; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #b3e0cb; }
.alert-bad { background: var(--bad-bg); color: var(--bad); border: 1px solid #f5b8b2; }
.alert-info { background: #e9f2fb; color: var(--brand-dark); border: 1px solid #b8d4f0; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.nowrap { white-space: nowrap; }

/* ---------- แถบโควตา ---------- */

.quota { margin-top: 6px; }
.quota .bar { height: 8px; background: #ebecf0; border-radius: 999px; overflow: hidden; }
.quota .bar span { display: block; height: 100%; background: var(--brand); }
.quota.full .bar span { background: var(--bad); }
.quota .caption { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- คลังสื่อ + ลำดับการแสดง ---------- */

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.media {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; overflow: hidden; display: flex; flex-direction: column;
}
.media .thumb {
  height: 96px; background: #eceef1 center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px;
}
.media .meta { padding: 8px 10px; font-size: 12.5px; }
.media .name { font-weight: 600; word-break: break-all; }
.media .actions { padding: 0 10px 10px; display: flex; gap: 6px; }

.playlist { list-style: none; margin: 0; padding: 0; }
.playlist li {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; margin-bottom: 8px; background: #fff;
}
.playlist .order { font-weight: 700; color: var(--muted); min-width: 22px; text-align: center; padding-top: 7px; }
.playlist .body { flex: 1; min-width: 0; }
.playlist .body .row > * { flex: 1 1 130px; }
.playlist .move { display: flex; flex-direction: column; gap: 4px; }

/* ---------- หน้าเข้าสู่ระบบ ---------- */

.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0d1b2a, #123a63);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: #fff;
  border-radius: 12px; padding: 28px; box-shadow: 0 12px 32px rgba(0, 0, 0, .3);
}
.login-card .brand { font-size: 26px; font-weight: 700; margin-bottom: 2px; }
.login-card .brand small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.login-card form { margin-top: 18px; }
.login-card button { width: 100%; padding: 10px; }

.validation { color: var(--bad); font-size: 13px; margin-top: 4px; }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; padding-bottom: 8px; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar .group { display: none; }
  .content { padding: 16px; }
}
