/* =============================================================
   admin.css — หน้าจัดการแหล่งน้ำ (ใช้ร่วมกับ dashboard.css)
   ============================================================= */

.ad-sr {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}
.ad-muted { color: #64748b; font-size: 14px; margin: 4px 0 0; line-height: 1.6; }
html.dark .ad-muted { color: #94a3b8; }
.ad-muted code, .ad-alert code, .ad-login code {
    background: rgba(148,163,184,.18); padding: 1px 6px; border-radius: 5px; font-size: .92em;
}

.ad-card {
    background: #fff; border: 1px solid rgba(168,210,240,.6); border-radius: 18px;
    padding: 20px 22px; margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(18,83,160,.06);
}
html.dark .ad-card { background: #1a1d27; border-color: #2d3148; }
.ad-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ad-card-head h2 { margin: 0; font-size: 17px; }
html.dark .ad-card-head h2, html.dark .ad-title { color: #e2e8f0; }

/* ── login ── */
.ad-login { max-width: 420px; margin: 40px auto; }
.ad-login h1 { margin: 0 0 6px; font-size: 22px; }
.ad-login pre { background: #0f172a; color: #e2e8f0; padding: 10px 12px; border-radius: 10px; overflow-x: auto; }
.ad-field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; font-weight: 700; font-size: 14px; }
.ad-field input {
    font-family: inherit; font-size: 15px; padding: 10px 12px;
    border: 1px solid #cbd5e1; border-radius: 10px; background: #f8fafc; color: #0f172a;
}
.ad-field input:focus { outline: 3px solid #93c5fd; border-color: #2563eb; }
html.dark .ad-field input { background: #0f1117; border-color: #2d3148; color: #e2e8f0; }

/* ── ปุ่ม ── */
.ad-btn {
    font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
    padding: 8px 16px; border-radius: 10px; border: 1px solid transparent;
    transition: background .15s, opacity .15s;
}
.ad-btn:focus-visible { outline: 3px solid #1d91c8; outline-offset: 2px; }
.ad-btn:disabled { opacity: .45; cursor: not-allowed; }
.ad-btn-primary { background: #1253a0; color: #fff; }
.ad-btn-primary:hover:not(:disabled) { background: #0e4386; }
.ad-btn-ghost { background: transparent; color: #475569; border-color: #cbd5e1; }
.ad-btn-ghost:hover:not(:disabled) { background: #f1f5f9; }
html.dark .ad-btn-ghost { color: #cbd5e1; border-color: #2d3148; }
html.dark .ad-btn-ghost:hover:not(:disabled) { background: #232736; }
.ad-btn-block { width: 100%; padding: 11px; font-size: 15px; margin-top: 6px; }
.ad-btn-sm { padding: 5px 12px; font-size: 13px; }

/* ── แถบเตือน ── */
.ad-alert { border-radius: 12px; padding: 11px 14px; margin: 0 0 18px; font-size: 14px; line-height: 1.7; }
.ad-alert-err  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.ad-alert-warn { background: #fffbeb; border: 1px solid #fcd34d; color: #78350f; }
.ad-alert-ok   { background: #f0fdf4; border: 1px solid #86efac; color: #14532d; }
html.dark .ad-alert-warn { background: #2d2007; border-color: #78350f; color: #fcd34d; }
html.dark .ad-alert-err  { background: #2d0f0f; border-color: #7f1d1d; color: #fca5a5; }

/* ── หัวหน้า ── */
.ad-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.ad-title { margin: 0; font-size: 24px; }
.ad-who { display: flex; align-items: center; gap: 10px; font-size: 14px; }

/* ── สรุปจำนวน ── */
.ad-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.ad-chip {
    display: inline-flex; align-items: center; gap: 8px;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    padding: 8px 14px; font-size: 14px;
}
.ad-chip b { font-size: 18px; font-variant-numeric: tabular-nums; }
.ad-chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
html.dark .ad-chip { background: #1a1d27; border-color: #2d3148; color: #e2e8f0; }

/* ── ตัวกรอง ── */
.ad-filters { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; margin-bottom: 14px; }
.ad-fgroup { display: flex; flex-direction: column; gap: 6px; }
.ad-flabel { font-size: 12px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .04em; }
.ad-search { margin-left: auto; }
.ad-search input {
    font-family: inherit; font-size: 14px; padding: 8px 12px; min-width: 220px;
    border: 1px solid #cbd5e1; border-radius: 10px; background: #f8fafc; color: #0f172a;
}
html.dark .ad-search input { background: #0f1117; border-color: #2d3148; color: #e2e8f0; }

/* ── ตาราง ── */
/* ตารางกว้างกว่าจอมือถือ → เลื่อนแนวนอนในกล่องของตัวเอง */
.ad-table-wrap { overflow-x: auto; }
.ad-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 980px; }
.ad-table th {
    text-align: left; font-size: 12px; font-weight: 700; color: #64748b;
    padding: 9px 10px; border-bottom: 2px solid #e2e8f0; white-space: nowrap;
}
.ad-table td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.ad-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ad-table tr.is-dirty td { background: #fffbeb; }
.ad-table tr.is-saving td { opacity: .6; }
html.dark .ad-table th { color: #94a3b8; border-color: #2d3148; }
html.dark .ad-table td { border-color: #232736; color: #e2e8f0; }
html.dark .ad-table tr.is-dirty td { background: #2d2007; }
.ad-name b { display: block; }
.ad-name small { color: #94a3b8; }
.ad-name a { color: #1d91c8; text-decoration: none; font-size: 12px; }
.ad-name a:hover { text-decoration: underline; }
.ad-unnamed { color: #64748b; font-weight: 600 !important; }

.ad-table select, .ad-table input[type="text"] {
    font-family: inherit; font-size: 14px; padding: 6px 8px; width: 100%;
    border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: #0f172a;
}
.ad-table select { border-left-width: 5px; }
.ad-table select:focus, .ad-table input:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }
html.dark .ad-table select, html.dark .ad-table input[type="text"] { background: #0f1117; border-color: #2d3148; color: #e2e8f0; }

.ad-save { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.ad-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.ad-badge.pending { background: #fef3c7; color: #92400e; }
.ad-badge.synced  { background: #dcfce7; color: #166534; }
.ad-badge.failed  { background: #fee2e2; color: #991b1b; }
.ad-badge.none    { background: #f1f5f9; color: #64748b; }
.ad-when { font-size: 11.5px; color: #94a3b8; }

.ad-pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 14px; font-weight: 700; }
.ad-empty { text-align: center; color: #94a3b8; padding: 26px 0; }

/* ── คิว / ประวัติ ── */
.ad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ad-grid .ad-card { margin-bottom: 0; }
.ad-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.ad-list li { padding: 8px 2px; border-bottom: 1px dashed #e2e8f0; font-size: 13.5px; line-height: 1.55; }
.ad-list li:last-child { border-bottom: 0; }
html.dark .ad-list li { border-color: #2d3148; color: #cbd5e1; }
.ad-list .meta { color: #94a3b8; font-size: 12px; }
.ad-err-text { color: #b91c1c; font-size: 12px; }

.ad-details { margin-top: 14px; }
.ad-details summary { cursor: pointer; font-weight: 700; font-size: 14px; color: #1253a0; }
.ad-details pre {
    background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 10px;
    font-size: 12.5px; overflow-x: auto; margin: 10px 0 6px;
}

/* ── แจ้งผล (toast) ── */
.ad-toast {
    position: fixed; right: 20px; bottom: 20px; z-index: 1000;
    max-width: 380px; padding: 12px 16px; border-radius: 12px;
    font-size: 14px; line-height: 1.5; box-shadow: 0 10px 30px rgba(15,23,42,.25);
}
.ad-toast[hidden] { display: none; }

@media (max-width: 1000px) {
    .ad-grid { grid-template-columns: 1fr; }
    .ad-search { margin-left: 0; }
}

.ad-btn-row { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* กล่องตรวจระบบ */
.ad-alert-err { background: #fef2f2; border: 1px solid #fca5a5; color: #7f1d1d; }
.ad-diag { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: .84rem; line-height: 1.5; }
.ad-diag li { padding: 6px 10px; border-radius: 8px; background: rgba(148, 163, 184, .08); }
.ad-diag li.is-fail { background: #fef2f2; }
.ad-diag li.is-warn { background: #fffbeb; }
.ad-diag li.is-ok { background: #f0fdf4; }

/* กล่องบอกวิธีแก้เมื่อบันทึกไม่ได้ (สิทธิ์โฟลเดอร์บนเซิร์ฟเวอร์) */
.ad-fix { margin-top: 8px; display: grid; gap: 6px; }
.ad-fix code {
    display: block; background: #0f172a; color: #e2e8f0; padding: 7px 10px;
    border-radius: 8px; font-size: .8rem; overflow-x: auto; user-select: all;
}
