/* Box Asia Chat — brand theme (slate + red) */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #16171c;
  --panel: #1f2129;
  --panel-2: #2b2c36;      /* Box Asia brand slate */
  --panel-3: #32343f;
  --border: #383a45;
  --border-soft: #2c2e38;
  --text: #eceef2;
  --muted: #9498a3;
  --faint: #6c6f7a;
  --brand: #d6332e;        /* BAGI red */
  --brand-hover: #b82a26;
  --danger: #e24b4a;
  --radius: 10px;
}

body {
  font-family: -apple-system, "Segoe UI", "Noto Sans Thai", Roboto, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }

/* ============ AUTH (login / setup) ============ */
.auth-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-brand {
  background: var(--panel-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
}
.auth-brand .logo { width: 150px; height: auto; display: block; margin-bottom: 28px; }
.auth-brand h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.2px; }
.auth-brand p { color: var(--muted); margin-top: 10px; max-width: 320px; font-size: 15px; }
.auth-brand .rule { width: 44px; height: 3px; background: var(--brand); border-radius: 3px; margin-top: 24px; }

.auth-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.auth-card { width: 100%; max-width: 360px; }
.auth-card h2 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 26px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--faint); }
.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(214,51,46,0.15);
}
.btn {
  width: 100%;
  padding: 12px;
  background: var(--brand);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--brand-hover); }
.error {
  background: rgba(226,75,74,0.12);
  border: 1px solid rgba(226,75,74,0.4);
  color: #f0a5a5;
  font-size: 13px;
  padding: 11px 13px;
  border-radius: var(--radius);
  margin-bottom: 18px;
}

@media (max-width: 760px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand { padding: 40px 28px 28px; border-right: none; border-bottom: 1px solid var(--border); }
  .auth-brand h1 { font-size: 22px; }
}

/* ============ APP SHELL (dashboard) ============ */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--panel-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
}
.sidebar .logo { width: 120px; height: auto; display: block; margin: 6px 6px 22px; }
.side-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--faint);
  margin: 6px 10px 8px;
}
.chan-list { list-style: none; }
.chan-list li {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.chan-list li:hover { background: var(--panel-3); color: var(--text); }
.chan-list .empty { color: var(--faint); font-size: 13px; padding: 8px 12px; cursor: default; }

.side-foot {
  margin-top: auto;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.who { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.who .name { font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .role { font-size: 12px; color: var(--faint); }
.side-foot a.logout { color: var(--muted); font-size: 13px; white-space: nowrap; }
.side-foot a.logout:hover { color: var(--brand); }

.main { display: flex; flex-direction: column; }
.main-head {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.main-body { padding: 26px 24px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  max-width: 640px;
}
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 14px; }
.dot { display:inline-block; width:8px; height:8px; border-radius:50%; background:#3ec46d; margin-right:7px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ============ Sidebar nav + admin tables ============ */
.side-nav { list-style: none; margin-bottom: 18px; }
.side-nav li a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
}
.side-nav li a:hover { background: var(--panel-3); color: var(--text); }
.side-nav li a.active { background: var(--panel-3); color: var(--text); }

.card.wide { max-width: none; }
.ok {
  background: rgba(62,196,109,0.12);
  border: 1px solid rgba(62,196,109,0.4);
  color: #7fd89b;
  font-size: 13px;
  padding: 11px 13px;
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.row-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-form .full { grid-column: 1 / -1; }
select {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
}
.btn-inline { display: inline-block; width: auto; padding: 10px 20px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  color: var(--faint);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border-soft); }
.table tr:last-child td { border-bottom: none; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--panel-3); color: var(--muted); }
.pill.on { background: rgba(62,196,109,0.15); color: #5fd083; }
.pill.off { background: rgba(226,75,74,0.15); color: #f0a5a5; }
.linkbtn { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0; }

/* ============ Chat module ============ */
.shell-chat { height: 100vh; }
.chat-col { height: 100vh; overflow: hidden; }
.chat-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  flex-shrink: 0;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.empty-chat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-size: 14px;
}
.msg { max-width: 72%; }
.msg .meta { font-size: 12px; color: var(--faint); margin-bottom: 3px; }
.msg .bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.mine { align-self: flex-end; }
.msg.mine .meta { text-align: right; }
.msg.mine .bubble { background: var(--brand); border-color: var(--brand); color: #fff; }
.composer {
  display: flex;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.composer input {
  flex: 1;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
}
.composer input:focus { outline: none; border-color: var(--brand); }
.composer-btn { width: auto; padding: 11px 22px; }
.chan-list li.active { background: var(--panel-3); color: var(--text); }

/* AI assistant messages */
.msg.ai { align-self: flex-start; max-width: 80%; }
.msg.ai .meta { color: var(--brand); }
.msg.ai .bubble {
  background: rgba(214,51,46,0.10);
  border-color: rgba(214,51,46,0.40);
  color: var(--text);
}
