/* Telegram Combo Bot — Dashboard */
/* กฎ: สีตัวหนังสือสถานะต้องไม่ใช้โทนเดียวกับพื้นหลัง — ใช้สีตัด (contrast) เพื่อให้อ่านชัด */
:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e7e9ea;
  --text-muted: #8b98a5;
  --primary: #1d9bf0;
  --primary-hover: #1a8cd8;
  --run: #00ba7c;
  --run-hover: #00a370;
  --stop: #f4212e;
  --stop-hover: #e01a26;
  --accent: #7856ff;
  --border: #2f3336;
  --radius: 12px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  /* สีสถานะ — ห้ามใช้โทนเดียวกับพื้นหลัง ใช้โทนตัดเพื่อให้มองเห็นชัด */
  --status-contrast: #67e8f9;
  --status-contrast-set: #6ee7b7;
  --status-contrast-empty: #94a3b8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.header {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0 0 6px;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

/* แถบวิธีใช้ — โทนเขียว อ่านง่าย */
.card-header.bg-light {
  background: #1a5f3c;
  color: #e8f5e9;
  border-bottom: 1px solid #2e7d55;
  font-weight: 600;
}

/* การ์ดวิธีใช้ (border-secondary) ทั้งบล็อกโทนเขียว */
.card.border-secondary .card-body {
  background: rgba(26, 95, 60, 0.15);
  color: var(--text);
}

.usage-card {
  border-color: #2e7d55;
}

.usage-card h2 {
  color: #2e7d55;
}

.hint {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.control-card .btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* ข้อความใต้กล่องสถานะ ใช้สีเดียวกับหัวข้อการ์ด (ควบคุม UserBot) */
.control-card .bot-state,
.control-card .run-bot-error,
.control-card .run-reasons-details {
  color: var(--text);
}

.account-card .btn-row,
.connect-section .btn-row {
  display: flex;
  gap: 10px 14px;
  flex-wrap: wrap;
  align-items: center;
}

/* สถานะระหว่างอัปโหลดรูป — สีและตัวหนังสือต่างจากพื้นหลัง มองเห็นชัด */
.combo-image-status-loading {
  color: #0d6efd !important;
  font-weight: 600;
}
.combo-image-status-loading .spinner-border {
  vertical-align: middle;
  color: inherit;
}

/* สถานะ path / ช่องทดสอบ — สีต้องไม่ซ้ำกับพื้นหลัง (กฎ contrast) */
.status-contrast {
  color: var(--status-contrast) !important;
}
.status-path-set {
  color: var(--status-contrast-set) !important;
  font-weight: 500;
}
.status-path-empty {
  color: var(--status-contrast-empty) !important;
}
.path-test-status,
.combo-image-path-status {
  min-height: 1.2em;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-run {
  background: var(--run);
  color: #fff;
}

.btn-run:hover:not(:disabled) {
  background: var(--run-hover);
}

.btn-stop {
  background: var(--stop);
  color: #fff;
}

.btn-stop:hover:not(:disabled) {
  background: var(--stop-hover);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.bot-state {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.connect-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.connect-section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.group-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.btn-remove-group {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  background: transparent;
  color: var(--stop);
  border: 1px solid var(--stop);
  border-radius: 6px;
  cursor: pointer;
}

.btn-remove-group:hover {
  background: rgba(244, 33, 46, 0.15);
}

select {
  width: 100%;
  max-width: 280px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

.broadcast-form label {
  display: block;
  margin: 10px 0 4px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.broadcast-form textarea,
.broadcast-form input[type="text"] {
  margin-bottom: 8px;
}

.official-bot-card .broadcast-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.usage-card h3 {
  margin: 20px 0 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}

.usage-card h3:first-of-type {
  margin-top: 0;
}

.usage-card ul,
.usage-card ol {
  margin: 8px 0 12px 20px;
  padding-left: 8px;
}

.usage-card li {
  margin-bottom: 4px;
}

.usage-card p {
  margin: 8px 0;
  line-height: 1.6;
}

.switch-card .row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.switch-card input[type="text"] {
  flex: 1;
  min-width: 200px;
}

.msg {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

.msg.success { color: var(--run); }
.msg.error   { color: var(--stop); }
.msg.warning { color: #d4a017; }

input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  resize: vertical;
  min-height: 60px;
}

.form .row,
.form-row {
  margin-bottom: 12px;
}

.form .row label,
.form-row label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.nav-link,
.nav-links {
  margin-top: 10px;
  font-size: 0.9rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.nav-link a,
.nav-links a {
  color: var(--primary);
  text-decoration: none;
}

.nav-link a:hover,
.nav-links a:hover {
  text-decoration: underline;
}

.nav-card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.nav-card-links .btn {
  margin: 0;
}

.nav-card {
  text-align: center;
  padding: 16px;
}

.btn-dash {
  display: inline-block;
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-dash:hover {
  background: var(--primary-hover);
}

.card a {
  color: var(--primary);
  text-decoration: none;
}

.card a:hover {
  text-decoration: underline;
}

.combo-set-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.combo-set-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-remove-combo {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  background: transparent;
  color: var(--stop);
  border: 1px solid var(--stop);
  border-radius: 6px;
  cursor: pointer;
}

.btn-remove-combo:hover {
  background: rgba(244, 33, 46, 0.15);
}

.btn-small {
  font-size: 0.9rem;
}

.live-details {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.live-details summary {
  cursor: pointer;
}

.live-details .live-status {
  margin-top: 8px;
  max-height: 120px;
}

.failed-card .table-wrap {
  border-color: rgba(244, 33, 46, 0.3);
  max-height: 420px;
  overflow-y: auto;
}

.failed-card h2 {
  color: var(--stop);
}

/* ข้อความในแถวตารางผลการส่งไม่สำเร็จ — สีเหลือง */
.failed-card td,
.failed-card th {
  color: #facc15;
}

/* หัวข้อรายงานการส่ง (sent_log.json) — สีเหลือง */
.sent-log-card h2 {
  color: #facc15;
}

/* ตารางรายงานการส่ง — แสดงประมาณ 12 แถว มีแถบเลื่อนเมื่อมีรายการเกิน */
.sent-log-card .table-wrap {
  max-height: 420px;
  overflow-y: auto;
}

/* ข้อความในแถวข้อมูลรายงานการส่ง — สีเหลือง */
.sent-log-card td {
  color: #facc15;
}

.live-status {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin: 0;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  color: var(--text);
}

.meta {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: var(--surface2);
}

th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}
