/* =========================================================
   LED-COOP : Main Stylesheet
   Modern minimal theme — เขียว-น้ำเงิน (ราชการทันสมัย)
   ========================================================= */

:root {
  --primary: #0d7c66;        /* เขียวเข้ม */
  --primary-light: #12997f;
  --primary-dark: #095c4c;
  --accent: #1565c0;         /* น้ำเงิน */
  --accent-light: #4a90e2;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --border: #e3e8e7;
  --text: #1c2b28;
  --text-muted: #6b7d79;
  --danger: #d64545;
  --danger-bg: #fdecec;
  --warning: #b8860b;
  --warning-bg: #fff8e6;
  --success: #1f8a4c;
  --success-bg: #e9f8ef;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(13, 124, 102, 0.08);
  --shadow-lg: 0 10px 30px rgba(13, 124, 102, 0.12);
  --font: 'Noto Sans Thai', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

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

/* ---------- Layout ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .3px;
}

.topbar .brand .logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.topbar nav {
  display: flex;
  gap: 6px;
  align-items: center;
}

.topbar nav a, .topbar nav span.divider {
  color: rgba(255,255,255,0.92);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s ease;
  white-space: nowrap;
}

.topbar nav a:hover {
  background: rgba(255,255,255,0.15);
  text-decoration: none;
}

.topbar nav a.active {
  background: rgba(255,255,255,0.22);
}

.topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 8px;
  padding-left: 14px;
  border-left: 1px solid rgba(255,255,255,0.25);
}

.topbar .user-chip .name {
  font-size: 13.5px;
  text-align: right;
  line-height: 1.3;
}

.topbar .user-chip .name small {
  display: block;
  opacity: .75;
  font-size: 11.5px;
}

.topbar .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

main.container {
  flex: 1;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

footer.app-footer {
  text-align: center;
  padding: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ---------- Page header ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--primary-dark);
  font-weight: 700;
}

.page-head p.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 22px;
}

.card-title {
  font-size: 15.5px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Form ---------- */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

label .req { color: var(--danger); }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-family: var(--font);
  background: #fcfdfd;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(13, 124, 102, 0.12);
  background: #fff;
}

textarea { resize: vertical; min-height: 140px; font-family: 'Courier New', monospace; }

.hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, opacity .15s ease;
  font-family: var(--font);
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(13, 124, 102, 0.25);
}
.btn-primary:hover { opacity: .92; text-decoration: none; }

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: #104f9e; text-decoration: none; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary-dark); text-decoration: none; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #b73838; text-decoration: none; }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Alerts ---------- */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: var(--success-bg); color: var(--success); border-color: #b9e6c9; }
.alert-danger  { background: var(--danger-bg); color: var(--danger); border-color: #f3c6c6; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #f0e0ad; }
.alert-info    { background: #eaf3fb; color: var(--accent); border-color: #c9e0f5; }

/* ---------- Badge ---------- */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 700;
}
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-muted   { background: #eef1f0; color: var(--text-muted); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.8px;
  background: #fff;
}

table.data-table th {
  background: #f0f5f3;
  color: var(--primary-dark);
  text-align: left;
  padding: 11px 14px;
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data-table tbody tr:hover { background: #f8fbfa; }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- Result card (single check) ---------- */
.result-box {
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 6px;
  border: 1.5px solid var(--border);
}

.result-box.is-found { background: var(--danger-bg); border-color: #f3c6c6; }
.result-box.is-clean { background: var(--success-bg); border-color: #b9e6c9; }
.result-box.is-error { background: var(--warning-bg); border-color: #f0e0ad; }

.result-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-weight: 700;
  font-size: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.result-field {
  background: rgba(255,255,255,0.65);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
}

.result-field .k { font-size: 11.5px; color: var(--text-muted); margin-bottom: 3px; font-weight: 600; }
.result-field .v { font-size: 14.5px; font-weight: 600; }

/* ---------- Bulk results list ---------- */
.bulk-item {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.bulk-item.is-found { background: var(--danger-bg); border-color: #f3c6c6; }
.bulk-item.is-clean { background: var(--success-bg); border-color: #b9e6c9; }
.bulk-item.is-error { background: var(--warning-bg); border-color: #f0e0ad; }

.bulk-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-card .num { font-size: 28px; font-weight: 800; color: var(--primary-dark); }
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d7c66 0%, #1565c0 100%);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 38px 34px;
}

.login-card .logo-area {
  text-align: center;
  margin-bottom: 22px;
}

.login-card .logo-area .icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 30px;
  color: #fff;
}

.login-card h1 {
  font-size: 18px;
  text-align: center;
  margin: 0 0 4px;
  color: var(--text);
}

.login-card p.tag {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 26px;
}

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.small { font-size: 12.5px; }
.w-100 { width: 100%; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; opacity: .5; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--border);
  color: var(--text);
}
.pagination a:hover { background: #f0f5f3; text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .topbar nav { display: none; }
  .mobile-toggle { display: block; }
  .topbar.nav-open nav {
    display: flex;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--primary-dark);
    flex-direction: column;
    padding: 10px;
    box-shadow: var(--shadow-lg);
  }
  main.container { padding: 18px 14px 40px; }
  .card { padding: 18px; }
}
