/* MQTT PushLog — shared styles (landing page + log dashboard) */

:root {
  --bg: #0b0f14;
  --panel: #12181f;
  --panel-2: #17202a;
  --border: #26313d;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --accent-dim: rgba(45, 212, 191, 0.14);
  --danger: #f87171;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}

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

/* ------------------------------------------------------------------ header */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 24px;
  background: linear-gradient(120deg, #0e3a33 0%, #10202b 55%, #10151c 100%);
  border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.page-title { margin: 0; font-size: 20px; font-weight: 600; }
.page-subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }

.ws-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.ws-status.ws-on { color: var(--accent); border-color: var(--accent-strong); background: var(--accent-dim); }
.ws-status.ws-off { color: var(--danger); border-color: var(--danger); }
.ws-status.ws-offline { color: var(--muted); border-color: var(--border); }

.user-chip { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ----------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent-strong); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border); }

.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #06231f; }
.btn-primary:hover { background: var(--accent); }

.btn-danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.45); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.12); border-color: var(--danger); }

.btn-ghost { background: transparent; }

.hidden { display: none !important; }

/* ----------------------------------------------------------------- inputs */

input[type="text"],
input[type="password"],
input:not([type]),
textarea {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-dim); }
input::placeholder { color: var(--muted); }
textarea { font-family: var(--mono); resize: vertical; }

/* ------------------------------------------------------------- landing page */

.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }

.status { color: var(--muted); padding: 20px 0; }
.status.error { color: var(--danger); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent-strong); transform: translateY(-2px); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title { margin: 0; font-size: 17px; font-weight: 600; }
.card-desc { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.badge-mqtt { color: var(--accent); border-color: var(--accent-strong); background: var(--accent-dim); }
.badge-http { color: #7dd3fc; border-color: #0ea5e9; background: rgba(14, 165, 233, 0.12); }
.badge-https { color: #7dd3fc; border-color: #0ea5e9; background: rgba(14, 165, 233, 0.12); }
.badge-tcp { color: #c4b5fd; border-color: #8b5cf6; background: rgba(139, 92, 246, 0.12); }

.card-link { font-size: 13px; font-weight: 600; }

/* 10B: ON/OFF switch, edit button, dimmed OFF card */
.card-off { opacity: 0.55; }
.card-off:hover { border-color: var(--border); transform: none; }

.card-controls { display: flex; align-items: center; gap: 10px; }
.card-controls .card-btns { margin-left: auto; display: flex; gap: 8px; }
.toggle-label { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.6px; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.15s, border-color 0.15s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .slider { background: var(--accent-dim); border-color: var(--accent-strong); }
.switch input:checked + .slider::before { transform: translateX(18px); background: var(--accent); }

/* 10B: edit modal form */
.modal-edit { width: 640px; }
.modal-edit select { width: 100%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-grid > * { min-width: 0; }
.form-field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.form-field-wide { grid-column: 1 / -1; }
.form-check { display: flex; flex-direction: row; align-items: center; gap: 8px; grid-column: 1 / -1; }
.form-check input[type="checkbox"] { width: auto; margin: 0; }

.settings {
  margin: 4px 0 0;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
}
.settings dt { color: var(--muted); }
.settings dd { margin: 0; font-family: var(--mono); word-break: break-all; }

/* --------------------------------------------------------------- log page */

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.controls input { width: 240px; }
.controls .spacer { flex: 1; }

.filter-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.filter-count strong { color: var(--accent); font-weight: 600; }

.table-wrap { padding: 0 24px 40px; overflow-x: auto; }

.log-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.log-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 10px 14px;
  background: #125147;
  color: #d9fffa;
  border-bottom: 2px solid var(--accent-strong);
  white-space: nowrap;
}

.log-table tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.log-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
.log-table tbody tr:hover { background: var(--accent-dim); }

.log-table td.col-id { color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.log-table td.col-uid { font-family: var(--mono); white-space: nowrap; }
.log-table td.col-topic { font-family: var(--mono); word-break: break-all; }
.log-table td.col-payload { font-family: var(--mono); word-break: break-all; max-width: 480px; }
.log-table td.col-time { font-family: var(--mono); white-space: nowrap; color: var(--muted); }

.log-table tr.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 30px 0;
}

@keyframes row-flash {
  0% { background-color: rgba(45, 212, 191, 0.35); }
  100% { background-color: transparent; }
}
.log-table tbody tr.row-new { animation: row-flash 3s ease-out forwards; }
.log-table tbody tr.row-new:hover { animation: row-flash 3s ease-out forwards; }

/* ------------------------------------------------------------------- modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 12, 0.7);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  width: 340px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

/* Scrollable region between the pinned header/hint and the pinned
   message/actions, so long forms (MQTT + TLS) never push the Save
   button off-screen. */
.modal-body {
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 6px;
}

.modal h2 { margin: 0; font-size: 17px; }
.modal-hint { margin: 0; color: var(--muted); font-size: 13px; }
.modal input { width: 100%; }
.modal textarea { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.login-error { color: var(--danger); font-size: 13px; min-height: 16px; }

/* ----------------------------------------------------------------- footer */

.site-footer {
  padding: 18px 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}


/* ------------------------------------------- Phase 10A: auth gate + users */

.center-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card .brand { font-size: 19px; }

.login-footer {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin-top: 6px;
}

select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--accent-dim); }

.form-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.hint { color: var(--muted); font-size: 12.5px; }

.inline-msg { font-size: 12.5px; min-height: 16px; }
.inline-msg.error { color: var(--danger); }
.inline-msg.ok { color: var(--accent); }

.panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel-card h2 { margin: 0; font-size: 16px; }

.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* In-app guide page */
.guide-doc { display: flex; flex-direction: column; }
.guide-doc h2 { margin: 0 0 4px; font-size: 16px; }
.guide-doc p { margin: 4px 0; line-height: 1.55; }
.guide-doc ol, .guide-doc ul { margin: 6px 0; padding-left: 22px; line-height: 1.6; }

/* 10.17: WIKI layout — left tree + topic content */
.wiki-wrap {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 60px;
  align-items: start;
}
.wiki-side {
  position: sticky;
  top: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.wiki-side-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 2px 8px 6px;
}
.wiki-group { color: var(--muted); font-size: 12px; font-weight: 700; margin: 12px 8px 4px; }
.wiki-group:first-of-type { margin-top: 2px; }
.wiki-link {
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text);
  font-size: 13.5px;
  border-left: 2px solid transparent;
}
.wiki-link:hover { background: var(--panel-2); text-decoration: none; }
.wiki-link.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent-strong);
  font-weight: 600;
}
.wiki-content { min-width: 0; }
.wiki-topic { display: flex; flex-direction: column; gap: 14px; }
.wiki-topic h2 { margin: 0 0 4px; font-size: 16px; }
.wiki-topic p { margin: 4px 0; line-height: 1.55; }
.wiki-topic ol, .wiki-topic ul { margin: 6px 0; padding-left: 22px; line-height: 1.6; }
.wiki-topic a { color: var(--accent); }

@media (max-width: 800px) {
  .wiki-wrap { grid-template-columns: 1fr; }
  .wiki-side { position: static; }
}
.guide-doc code, .wiki-topic code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
}
.guide-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.guide-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.guide-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }

/* ------------------------------------- 10.13/10.14: delete modal + counter */

.modal-delete { width: 560px; }

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.delete-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.delete-option-info { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.delete-option-info strong { font-size: 13.5px; }
.delete-count {
  min-width: 76px;
  text-align: right;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
