/* ============================================================
   MPT Dashboard — combined stylesheet
   ============================================================ */

/* ---- base ---- */
body { font-family: Arial, sans-serif; margin: 0; background: #f5f6fa; color: #222; }
header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #1f2937; color: #fff; }
header h1 { margin: 0; font-size: 20px; }
.actions button { margin-left: 8px; padding: 8px 10px; cursor: pointer; }
main { padding: 16px; display: grid; gap: 16px; }
.card { background: #fff; border-radius: 8px; padding: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid #e5e7eb; padding: 8px; font-size: 14px; text-align: left; }
#liveView { background: #111827; color: #fff; border-radius: 6px; min-height: 80px;
            display: flex; align-items: center; justify-content: center; padding: 12px; }
#map { height: 380px; border-radius: 6px; }

/* ---- generic badges ---- */
.badge { padding: 3px 8px; border-radius: 999px; font-size: 12px; }
.online  { background: #dcfce7; color: #166534; }
.offline { background: #fee2e2; color: #991b1b; }
.warn    { background: #fef9c3; color: #854d0e; }

/* ---- device type badges ---- */
.type-badge  { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.type-mpt    { background: #dbeafe; color: #1d4ed8; }
.type-camera { background: #fce7f3; color: #9d174d; }
.type-nvr    { background: #ecfdf5; color: #065f46; }
.type-dvr    { background: #fef3c7; color: #92400e; }
.type-unknown{ background: #f3f4f6; color: #6b7280; }

/* ---- action buttons ---- */
.action-cell { white-space: nowrap; }
button.btn-reg   { background: #16a34a; color: #fff; border: none; padding: 4px 10px; border-radius: 5px; cursor: pointer; font-size: 13px; }
button.btn-reg:hover   { background: #15803d; }
button.btn-unreg { background: #dc2626; color: #fff; border: none; padding: 4px 10px; border-radius: 5px; cursor: pointer; font-size: 13px; }
button.btn-unreg:hover { background: #b91c1c; }
button.btn-view  { background: #2563eb; color: #fff; border: none; padding: 4px 10px; border-radius: 5px; cursor: pointer; font-size: 13px; margin-left: 4px; }
button.btn-view:hover  { background: #1d4ed8; }
button.btn-del   { background: transparent; color: #9ca3af; border: 1px solid #d1d5db; padding: 4px 8px; border-radius: 5px; cursor: pointer; font-size: 13px; margin-left: 4px; }
button.btn-del:hover   { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
button.btn-login { background: #2d7ef7; color: #fff; border: none; padding: 5px 10px; border-radius: 5px; cursor: pointer; }
button.btn-login:hover     { background: #1c63d0; }
button.btn-login:disabled  { background: #9bb8e6; cursor: default; }
button.btn-info  { background: #7c3aed; color: #fff; border: none; padding: 4px 8px; border-radius: 5px; cursor: pointer; font-size: 12px; margin-left: 4px; }
button.btn-info:hover  { background: #6d28d9; }

/* ---- non-SOS event panel ---- */
.evt-controls { display: flex; gap: 18px; align-items: center; margin-bottom: 10px; font-size: 13px; color: #374151; flex-wrap: wrap; }
.evt-controls select { padding: 3px 6px; border-radius: 5px; border: 1px solid #d1d5db; }
.evt-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.evt-critical { background: #fee2e2; color: #991b1b; }
.evt-warning  { background: #fef9c3; color: #854d0e; }
.evt-info     { background: #e0f2fe; color: #075985; }
.evt-pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 10px; }
.evt-pager button { background: #2563eb; color: #fff; border: none; padding: 5px 12px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.evt-pager button:hover:not(:disabled) { background: #1d4ed8; }
.evt-pager button:disabled { background: #cbd5e1; cursor: default; }
.evt-pager .muted { font-style: normal; }

/* ---- recording query / pull ---- */
.rec-query { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; }
.rec-query h3, #recTable + h3, .rec-query + h3 { margin: 4px 0 8px; font-size: 14px; }
.rec-query-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.rec-query-row label { display: flex; flex-direction: column; font-size: 12px; color: #475569; gap: 3px; }
.rec-query-row select, .rec-query-row input { padding: 5px 7px; border: 1px solid #cbd5e1; border-radius: 5px; font-size: 13px; }
.rec-results { margin-top: 12px; }
.rec-seg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rec-seg-table th, .rec-seg-table td { padding: 5px 8px; border-bottom: 1px solid #eef2f7; text-align: left; }
.modal-box-wide { max-width: 860px; width: 90vw; }

/* ---- misc ---- */
.muted { color: #9ca3af; text-align: center; font-style: italic; }
.hint  { color: #6b7280; font-size: 13px; margin: 4px 0 10px; }

/* ---- netsdk banner ---- */
.netsdk      { font-size: 12px; padding: 4px 10px; border-radius: 12px; background: #e5e7eb; color: #374151; margin-right: 8px; }
.netsdk.ok   { background: #d1fae5; color: #065f46; }
.netsdk.warn { background: #fef3c7; color: #92400e; }
.netsdk.err  { background: #fee2e2; color: #991b1b; }

/* ---- login modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: #fff; padding: 24px; border-radius: 10px; width: 340px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.modal-box h3 { margin: 0 0 6px; }
.modal-box label { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 600; }
.modal-box input { width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box; }
.modal-actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }
.reg-msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.reg-msg .ok  { color: #15803d; font-weight: 600; }
.reg-msg .err { color: #dc2626; font-weight: 600; }

/* ---- device info modal ---- */
.info-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 1100; }
.info-box { background: #1e293b; color: #e2e8f0; border-radius: 12px; width: 440px; max-width: 96vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 16px 48px rgba(0,0,0,.5); }
.info-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px; border-bottom: 1px solid #334155; }
.info-header h3 { margin: 0; font-size: 16px; color: #f1f5f9; }
.info-close { background: none; border: none; color: #94a3b8; font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1; }
.info-close:hover { color: #f1f5f9; }
.info-body { padding: 14px 20px 20px; }
.info-section { margin-bottom: 14px; }
.info-section-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #64748b; margin-bottom: 6px; }
.info-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 4px 0; font-size: 13px; border-bottom: 1px solid #0f172a; }
.info-row:last-child { border-bottom: none; }
.info-label { color: #94a3b8; flex-shrink: 0; margin-right: 12px; }
.info-val { color: #e2e8f0; text-align: right; word-break: break-all; }
.info-event { padding: 4px 0; font-size: 12px; border-bottom: 1px solid #0f172a; }
.info-event:last-child { border-bottom: none; }
.info-event-type { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; margin-right: 6px; background: #334155; color: #94a3b8; }
.info-event-type.SOS { background: #7f1d1d; color: #fca5a5; }
.info-event-type.LOGIN { background: #14532d; color: #86efac; }
.info-event-type.LOGOUT { background: #431407; color: #fdba74; }

/* ---- live view ---- */
.live-wrap { width: 100%; max-width: 760px; }
.live-head { font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.live-spacer { flex: 1; min-width: 4px; }
.live-dot  { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; display: inline-block; animation: pulse 1.2s infinite; flex-shrink: 0; }
@keyframes pulse { 0%,100%{ opacity: 1; } 50%{ opacity: .35; } }
#liveVideo { width: 100%; max-width: 760px; border-radius: 8px; background: #000; display: block; min-height: 200px; }
#liveImg   { width: 100%; max-width: 760px; border-radius: 8px; background: #0d1117; display: block; min-height: 200px; object-fit: contain; }
.live-mode-lbl { font-size: 11px; background: #1e293b; color: #94a3b8; padding: 2px 8px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }
.live-stats-lbl { font-size: 11px; background: #0f172a; color: #38bdf8; padding: 2px 8px; border-radius: 10px; font-family: monospace; white-space: nowrap; flex-shrink: 0; }
/* quality buttons — no auto margin (live-spacer handles alignment) */
button.btn-qual { background: #475569; color: #fff; border: none; padding: 4px 10px; border-radius: 5px; cursor: pointer; font-size: 13px; margin-left: 0; flex-shrink: 0; }
button.btn-qual:hover  { background: #334155; }
button.btn-qual.active { background: #2563eb; }

/* ---- map ---- */
#map { height: 400px; border-radius: 6px; cursor: default; }
#map.place-mode { cursor: crosshair; }
.map-place-banner { display: none; background: #fbbf24; color: #1c1917; padding: 8px 14px; border-radius: 6px; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.map-place-banner button { margin-left: 10px; padding: 2px 10px; cursor: pointer; background: #1f2937; color: #fff; border: none; border-radius: 4px; }
/* div-icon markers */
.map-icon-mpt    { font-size: 24px; line-height: 1; text-align: center; }
.map-icon-camera { font-size: 20px; line-height: 1; text-align: center; }
/* Leaflet popup button */
.leaflet-popup-content button { margin-top: 6px; padding: 3px 10px; cursor: pointer; background: #2563eb; color: #fff; border: none; border-radius: 4px; font-size: 12px; }
.leaflet-popup-content button:hover { background: #1d4ed8; }
button.btn-place { background: #d97706; color: #fff; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 12px; }
button.btn-place:hover { background: #b45309; }

/* ---- GPS relay info modal ---- */
.relay-modal-root { display: none; }
.relay-modal-box  { width: 480px; max-width: 96vw; }
.relay-section    { margin-top: 14px; }
.relay-section:first-of-type { margin-top: 12px; }
.relay-hint-spaced { margin-bottom: 8px; }
.relay-list   { margin: 4px 0 0 16px; line-height: 1.8; }
.relay-code   { background: #0f172a; color: #7dd3fc; font-size: 12px; padding: 10px 12px;
                border-radius: 6px; overflow-x: auto; white-space: pre; margin: 6px 0; }

/* ---- GPS cell badge in device table ---- */
.badge-gps      { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-gps-ok   { background: #d1fae5; color: #065f46; }
.badge-gps-old  { background: #fef3c7; color: #92400e; }
.badge-gps-none { background: #f3f4f6; color: #9ca3af; }

/* ---- push-to-talk ---- */
.talk-controls { margin: 8px 0; }
.talk-panel { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.ptt-btn { background:#2563eb; color:#fff; border:none; padding:12px 24px; border-radius:8px; font-size:15px; cursor:pointer; -webkit-user-select:none; user-select:none; }
.ptt-btn.ptt-active { background:#dc2626; box-shadow:0 0 0 4px rgba(220,38,38,.25); }

.group-dev-list { display:flex; flex-wrap:wrap; gap:10px 18px; margin-bottom:10px; }
.group-dev-list label { font-size:13px; color:#374151; }
