/* =========================================================
 * สไตล์กลาง - แจ้งปัญหาระบบสารสนเทศ กรมพัฒนาฝีมือแรงงาน
 * ========================================================= */
:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-soft: #e0e7ff;
  --accent: #db2777;
  --accent-dark: #be185d;
  --danger: #dc2626;
  --success: #15803d;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f6fb;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(30, 64, 175, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px;
  background: var(--bg);
  font-family: 'Sarabun', Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
img { border: 0; }

.container { max-width: 1400px; margin: 0 auto; }

.ico { width: 18px; height: 18px; vertical-align: -3px; flex: 0 0 auto; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
  text-align: center;
  flex-wrap: wrap;
}
.header img { width: 84px; }
.header h1 { margin: 0; font-size: 26px; font-weight: 700; color: var(--primary); }
.header p { margin: 0; color: var(--muted); font-size: 14px; }
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft, #fdf2f8);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  vertical-align: middle;
}

/* ---------- กล่องแจ้งเตือน ---------- */
.notice {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 14px;
  background: linear-gradient(90deg, #fdf2f8 0%, #fff 100%);
  border-left: 5px solid var(--accent);
}
.notice-icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 2s infinite;
}
.notice-icon img { width: 34px; }
.notice-title { font-weight: 700; color: var(--accent); font-size: 16px; }
.notice-text { color: #4b5563; font-size: 14px; }
.notice-text img { width: 22px; vertical-align: middle; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(219, 39, 119, .45); }
  70%  { box-shadow: 0 0 0 12px rgba(219, 39, 119, 0); }
  100% { box-shadow: 0 0 0 0 rgba(219, 39, 119, 0); }
}

/* ---------- ข้อความวิ่ง ---------- */
.ticker { display: flex; align-items: stretch; overflow: hidden; margin-bottom: 20px; }
.ticker-label {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}
.ticker-track {
  flex: 1 1 auto;
  overflow: hidden;
  padding: 10px 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.ticker-content {
  display: inline-block;
  white-space: nowrap;
  padding-left: 100%;
  animation: ticker 90s linear infinite;
}
.ticker-track:hover .ticker-content,
.ticker.paused .ticker-content { animation-play-state: paused; }
.ticker-item { display: inline-block; margin-right: 48px; }
.ticker-item b { color: var(--accent); }
.ticker-item .sep { color: #cbd5e1; margin-left: 48px; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-100%); } }

.ticker-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-left: 1px solid var(--border);
  background: #f8fafc;
  color: var(--primary);
  padding: 0 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ticker-btn:hover { background: var(--primary-soft); }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn img { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: wait; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-light { background: #fff; color: var(--primary); border-color: #d1d5db; }
.btn-light:hover { background: #f1f5f9; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #166534; color: #fff; }
.btn-accent {
  background: var(--accent);
  color: #fff;
  height: 46px;
  padding: 0 20px;
  font-size: 15px;
  box-shadow: 0 6px 16px rgba(219, 39, 119, .25);
}
.btn-accent:hover { background: var(--accent-dark); color: #fff; }
.btn-accent img { width: 26px; height: 26px; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-sm .ico { width: 15px; height: 15px; }

/* ---------- แถบค้นหา ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-form { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; }
.search-form select { max-width: 320px; }
.search-form input[type=text] { min-width: 220px; flex: 1 1 220px; }

/* ---------- ช่องกรอก ---------- */
select,
input[type=text],
input[type=email],
input[type=number],
textarea {
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 160px; padding: 10px 12px; width: 100%; resize: vertical; line-height: 1.6; }
select:focus, input[type=text]:focus, input[type=email]:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input[type=file] {
  font-family: inherit;
  font-size: 14px;
  max-width: 100%;
}
input[type=file]::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--primary);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- ตาราง ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.data thead th {
  position: sticky;
  top: 0;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 12px 10px;
  text-align: center;
  white-space: nowrap;
}
table.data thead th:first-child { border-top-left-radius: var(--radius); }
table.data thead th:last-child  { border-top-right-radius: var(--radius); }
table.data tbody td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr:nth-child(even) { background: #fafbff; }
table.data tbody tr:hover { background: #eef2ff; }
table.data tbody tr:last-child td { border-bottom: 0; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

.id-badge {
  display: inline-block;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  font-size: 13px;
}
.code-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #fef3c7;
  color: #92400e;
  font-family: Consolas, monospace;
  font-size: 13px;
}
.sys-tag {
  display: inline-block;
  min-width: 96px;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
}
.reporter { font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.msg { min-width: 240px; }
.answer {
  min-width: 240px;
  color: #1d4ed8;
  background: #f0f7ff;
  border-left: 3px solid #93c5fd;
  padding: 6px 10px;
  border-radius: 6px;
}
.answer-time { display: block; margin-top: 4px; color: var(--danger); font-size: 12px; }

.status { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status img { width: 42px; }
.status span { padding: 1px 8px; border-radius: 999px; }
.st-done span     { background: #dcfce7; color: #15803d; }
.st-wait span     { background: #fef3c7; color: #b45309; }
.st-edit span     { background: #ede9fe; color: #6d28d9; }
.st-checking span { background: #ffedd5; color: #c2410c; }
.st-answered span { background: #dbeafe; color: #1d4ed8; }

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: 4px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--primary);
  vertical-align: middle;
  transition: background .15s;
}
.icon-link:hover { background: var(--primary-soft); }
.icon-link .ico { width: 15px; height: 15px; }
a.attach {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 2px 2px 0 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  vertical-align: middle;
}
a.attach:hover { background: var(--primary-soft); color: var(--primary); }
a.attach .ico { width: 13px; height: 13px; }
.ok-link img { width: 38px; transition: transform .15s; }
.ok-link:hover img { transform: scale(1.12) rotate(-6deg); }
.actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- ส่วนล่าง ---------- */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}
.total { color: var(--muted); font-size: 14px; }
.total b { color: var(--text); }

.pagination { display: flex; flex-wrap: wrap; gap: 4px; }
.pg {
  display: inline-block;
  min-width: 34px;
  padding: 5px 10px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 14px;
}
a.pg:hover { background: var(--primary-soft); border-color: #c7d2fe; color: var(--primary); }
.pg.current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pg.disabled { color: #cbd5e1; cursor: default; }
.pg.dots { border: 0; background: transparent; }

.legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin: 20px 0;
  padding: 14px 16px;
  font-size: 14px;
}
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend img { width: 30px; }

.footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 13px; }
.footer-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--primary); }
.footer-link img { width: 24px; }

/* ---------- หน้าฟอร์ม / popup ---------- */
body.popup { padding: 16px; }
.form-card { max-width: 860px; margin: 0 auto; padding: 22px 24px; }
.form-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}
.form-title .ico { width: 24px; height: 24px; }
.form-subtitle { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.field { margin-bottom: 16px; }
.field > label,
.field .label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #374151;
}
.req { color: var(--danger); margin-left: 2px; }
.field select, .field input[type=text] { width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { margin-top: 6px; color: var(--muted); font-size: 13px; }
.wait-inline { display: inline-block; margin-left: 6px; vertical-align: middle; }
.wait-inline img { height: 18px; }

.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  padding: 8px 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}
.file-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.captcha { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.captcha img { height: 44px; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
.captcha input { width: 200px; }

.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 500;
}
.radio-pill:hover { border-color: var(--primary); }
.radio-pill input { accent-color: var(--primary); margin: 0; }

.code-input {
  width: 100%;
  max-width: 260px;
  height: 52px !important;
  font-size: 22px !important;
  letter-spacing: 4px;
  text-align: center;
  font-weight: 700;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.form-actions.center { justify-content: center; }

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert .ico { width: 20px; height: 20px; margin-top: 1px; }
.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

.center-box { text-align: center; padding: 30px 20px; }
.center-box .big-icon {
  display: inline-flex;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.center-box .big-icon .ico { width: 32px; height: 32px; }
.big-icon.danger { background: #fee2e2; color: var(--danger); }
.big-icon.success { background: #dcfce7; color: var(--success); }

/* CKEditor ให้กลมกลืน */
.cke_chrome { border-radius: 10px !important; overflow: hidden; border-color: #d1d5db !important; }

/* พรีวิวรูป (ปลั๊กอินเดิม) */
#screenshot, #screenshot1 {
  position: absolute;
  border: 1px solid #ccc;
  background: #333;
  padding: 5px;
  display: none;
  color: #fff;
  border-radius: 8px;
  z-index: 999;
}
#toolTipBox {
  display: none;
  padding: 5px;
  font-size: 12px;
  border: 1px solid #000;
  position: absolute;
  background-color: #A9F5D0;
  color: #000;
}

@media (max-width: 640px) {
  body { padding: 12px; }
  .header h1 { font-size: 20px; }
  .search-form select, .search-form input[type=text] { max-width: none; width: 100%; }
  .toolbar .btn-accent { width: 100%; }
  .field-row { grid-template-columns: 1fr; }
  .form-card { padding: 16px; }
  .form-actions .btn { flex: 1 1 auto; }
}
