/* Mount Morris Mobile Park — staff portal styles.
   Calm, simple, mobile-first. No framework. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e2e8f0;
  --accent: #2f7d5b;
  --accent-hover: #276649;
  --error: #b3261e;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #1a212b;
    --text: #e6edf3;
    --muted: #9aa7b4;
    --border: #2a3340;
    --accent: #3fa775;
    --accent-hover: #4cb985;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Brand ---------- */
.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  font-size: 1.6rem;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand span {
  font-weight: 500;
  color: var(--accent);
  font-size: 0.95rem;
}
.brand.small {
  font-size: 1rem;
  flex-direction: row;
  gap: 0.4rem;
  align-items: baseline;
}
.brand.small span {
  font-size: 0.8rem;
}

/* ---------- Login ---------- */
.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 360px;
}

.card .muted {
  margin-top: 0.25rem;
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 125, 91, 0.18);
}

button {
  font-family: inherit;
  cursor: pointer;
}

#login-form button[type="submit"] {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  transition: background 0.15s ease;
}
#login-form button[type="submit"]:hover {
  background: var(--accent-hover);
}
button:disabled {
  opacity: 0.6;
  cursor: default;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}
.center {
  text-align: center;
}

.error {
  color: var(--error);
  font-size: 0.9rem;
  margin: 0.9rem 0 0;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.link-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
.link-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}

.msg {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  max-width: 85%;
}
.msg p {
  margin: 0;
}
.msg.system {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  align-self: flex-start;
  white-space: pre-wrap;
}
.msg.user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  white-space: pre-wrap;
}
.msg.restored-note {
  background: transparent;
  align-self: center;
  font-size: 0.75rem;
  font-style: italic;
  color: var(--muted);
  padding: 0.1rem 0.4rem;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0;
}
.attachments .thumb {
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.attachments .thumb button {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.composer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem;
  margin-top: 0.5rem;
}
.composer input[type="text"] {
  flex: 1;
  border: none;
  background: transparent;
}
.composer input[type="text"]:focus {
  box-shadow: none;
}

.attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  margin: 0;
  font-size: 1.2rem;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.attach-btn:hover {
  background: var(--bg);
}

.composer button[type="submit"] {
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
}
.composer button[type="submit"]:hover {
  background: var(--accent-hover);
}

.hint {
  margin-top: 0.6rem;
}

/* ---------- Nav + generic page ---------- */
.topnav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.topnav a.link-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}
.page-title {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.4rem;
}

/* ---------- History list ---------- */
.history {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.history-summary {
  margin: 0;
  font-weight: 500;
}
.history-meta {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}
.tag-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}
.tag-badge.action-upsert {
  color: var(--accent);
  border-color: var(--accent);
}
.tag-badge.action-delete {
  color: var(--error);
  border-color: var(--error);
}
.tag-badge.action-rollback,
.tag-badge.action-rejected {
  color: #9a6b00;
  border-color: #9a6b00;
}
.tag-badge.action-approved {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Approval cards ---------- */
.file-preview {
  margin: 0.6rem 0 0.2rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.6rem;
}
.file-name {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  word-break: break-all;
}
.file-body {
  margin: 0 0 0.6rem;
  padding: 0.6rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

/* ---------- Approval card diff (before/after) ---------- */
.file-diff {
  margin-bottom: 0.6rem;
}
.diff-note {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.diff-body {
  margin: 0 0 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto;
}
.diff-line {
  padding: 0.05rem 0.6rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.diff-ctx {
  color: var(--text);
}
.diff-add {
  background: rgba(47, 125, 91, 0.14);
  color: #1a6b46;
}
.diff-del {
  background: rgba(179, 38, 30, 0.12);
  color: #b3261e;
}
@media (prefers-color-scheme: dark) {
  .diff-add { color: #6ee7a8; }
  .diff-del { color: #ff8a80; }
}
.diff-move {
  font-size: 0.8rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(59, 130, 160, 0.10);
  overflow-x: auto;
  white-space: nowrap;
}
.diff-move-from,
.diff-move-to { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.diff-move-arrow { font-weight: 700; }
.diff-move-count { color: var(--muted); }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}
.actions .link-btn {
  text-decoration: none;
}
.btn-approve,
.btn-reject {
  padding: 0.5rem 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
}
.btn-approve {
  color: #fff;
  background: var(--accent);
}
.btn-approve:hover {
  background: var(--accent-hover);
}
.btn-reject {
  color: var(--error);
  background: transparent;
  border-color: var(--error);
}
.btn-reject:hover {
  background: rgba(179, 38, 30, 0.08);
}
.history-item.decided {
  opacity: 0.85;
}
