/* Family Sentinel customer portal — calm, trustworthy, protective. */

:root {
  --navy: #1d2a23;      /* now ink-green — headers/footers */
  --navy-dark: #12180f;
  --teal: #a67c2e;      /* now brass — accents/borders/links */
  --teal-dark: #8a6725;
  --teal-tint: #f3ebd9;
  --green: #3f6b3a;
  --green-tint: #eef3e9;
  --amber: #a67c2e;
  --amber-tint: #f6edd7;
  --ink: #1d2a23;
  --muted: #42504a;
  --border: #d8cfba;
  --bg: #f7f3ea;
  --paper-deep: #efe8d8;
  --card-bg: #fffdf6;
  --alert: #8c3b2e;
  --brass-soft: #c9a45c;

  --font-display: 'Fraunces', Georgia, 'Iowan Old Style', serif;
  --font-body: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header / footer ---------- */

header.site,
footer.site {
  background: var(--navy);
  color: #fff;
}

header.site {
  padding: 0.9rem 1.25rem;
  border-bottom: 3px solid var(--teal);
}

.site-nav {
  max-width: 46rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  border-radius: 6px;
}

.brand:hover { color: #fff; }

/* CSS-only shield + checkmark mark, no external assets */
.brand-mark {
  display: inline-block;
  position: relative;
  width: 1.65rem;
  height: 1.85rem;
  flex: none;
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, var(--brass-soft), var(--teal) 55%, var(--teal-dark));
  clip-path: polygon(50% 0%, 100% 16%, 100% 56%, 50% 100%, 0% 56%, 0% 16%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 27%;
  top: 38%;
  width: 38%;
  height: 20%;
  border-left: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(-45deg);
  transform-origin: bottom left;
}

.account-strip {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.9rem;
  color: var(--paper-deep);
}

.account-strip .who {
  max-width: 15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.signout-form { margin: 0; }

.signout-btn {
  margin: 0;
  padding: 0.5rem 0.9rem;
  min-height: 44px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 6px;
  cursor: pointer;
}

.signout-btn:hover { background: rgba(255, 255, 255, 0.12); }

footer.site {
  margin-top: auto;
  background: var(--navy-dark);
  padding: 1.25rem 1.5rem;
}

.footer-inner {
  max-width: 46rem;
  margin: 0 auto;
  font-size: 0.85rem;
  color: var(--paper-deep);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

footer.site a {
  color: var(--brass-soft);
}

/* ---------- Layout ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-dark);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem 2.1rem;
  box-shadow: 0 1px 2px rgba(27, 42, 74, 0.04), 0 10px 28px -18px rgba(27, 42, 74, 0.35);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1.25;
  color: var(--navy);
}

h2 {
  font-family: var(--font-display);
  color: var(--navy);
  font-size: 1.2rem;
}

p { color: var(--muted); }

.lede {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0;
}

.actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
}

.actions-row p { margin: 0; }

/* ---------- Forms ---------- */

label {
  display: block;
  margin: 1.25rem 0 0.4rem;
  font-weight: 600;
  color: var(--ink);
}

.hint {
  margin: -0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="email"],
input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

textarea { min-height: auto; }

input[readonly] {
  background: var(--paper-deep);
  color: var(--muted);
}

input::placeholder,
textarea::placeholder { color: #93989f; }

.form-error {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--alert);
  border-radius: 8px;
  background: #fbeae6;
  color: var(--alert);
  font-weight: 600;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.75rem 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 1.1rem 0 0;
  font-weight: 600;
  color: var(--ink);
}

.checkbox-row input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  min-height: 0;
  margin: 0;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 1.5rem;
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--bg);
  background: var(--ink);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.btn:hover { background: var(--navy-dark); }

button.btn-quiet {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
}

button.btn-quiet:hover {
  background: var(--teal-tint);
  border-color: var(--teal);
}

a {
  color: var(--teal-dark);
}

a:hover {
  color: var(--navy);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--teal-dark);
  outline-offset: 2px;
}

input:focus,
textarea:focus,
select:focus,
button:focus,
a:focus {
  outline: 3px solid var(--teal-dark);
  outline-offset: 2px;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: capitalize;
  color: #fff;
  white-space: nowrap;
}

.badge-open { background: var(--teal); }
.badge-answered { background: var(--navy); }
.badge-resolved { background: var(--green); }
.badge-closed { background: var(--muted); }

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 2.25rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fffefb;
}

.empty-state .empty-mark {
  display: inline-block;
  width: 2.4rem;
  height: 2.7rem;
  margin-bottom: 0.75rem;
  position: relative;
}

.empty-state .empty-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--teal-tint);
  border: 2px solid var(--teal);
  clip-path: polygon(50% 0%, 100% 16%, 100% 56%, 50% 100%, 0% 56%, 0% 16%);
}

.empty-state .empty-mark::after {
  content: "";
  position: absolute;
  left: 26%;
  top: 36%;
  width: 40%;
  height: 22%;
  border-left: 3px solid var(--teal-dark);
  border-bottom: 3px solid var(--teal-dark);
  transform: rotate(-45deg);
  transform-origin: bottom left;
}

.empty-state p {
  margin: 0;
  font-size: 1.02rem;
  color: var(--ink);
}

.empty-state .hint { margin-top: 0.4rem; }

/* ---------- Ticket list ---------- */

.ticket-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  border-top: 1px solid var(--border);
}

.ticket-list li {
  border-bottom: 1px solid var(--border);
}

.ticket-list a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 0.25rem;
  min-height: 44px;
  text-decoration: none;
  border-radius: 8px;
}

.ticket-list a:hover,
.ticket-list a:focus-visible {
  background: var(--teal-tint);
}

.ticket-subject {
  flex: 1;
  min-width: 8rem;
  color: var(--ink);
  font-weight: 600;
}

.ticket-id {
  color: var(--muted);
  font-weight: 500;
}

.ticket-meta {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ---------- Message thread ---------- */

.thread {
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.msg {
  border-radius: 12px;
  padding: 0.95rem 1.1rem;
  max-width: 92%;
}

.msg-customer {
  background: #fff;
  border: 1px solid var(--border);
  align-self: flex-start;
}

.msg-admin {
  background: var(--teal-tint);
  border: 1px solid var(--teal);
  align-self: flex-end;
}

.msg-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.msg-meta strong {
  color: var(--ink);
}

.msg p {
  margin: 0;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg-internal {
  background: var(--amber-tint);
  border: 1px dashed var(--amber);
  align-self: stretch;
  max-width: 100%;
}

.msg-internal .msg-meta strong::before {
  content: "\26A0  ";
}

.payload {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
  background: #f2f0e9;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
}

/* ---------- Admin-only bits ---------- */

.customer-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.customer-card dt {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.customer-card dd {
  margin: 0 0 0.6rem;
  color: var(--ink);
  font-weight: 600;
}

.customer-card dd:last-child { margin-bottom: 0; }

.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 1.5rem;
}

.status-actions form { margin: 0; }

.status-actions button {
  margin-top: 0;
  min-height: 40px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  background: var(--navy);
}

.status-actions button:hover {
  background: var(--navy-dark);
}

.status-actions button.btn-quiet {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
}

.status-actions button.btn-quiet:hover {
  background: var(--teal-tint);
  border-color: var(--teal);
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  main { padding: 1.25rem 1rem 2.5rem; }
  .card { padding: 1.5rem 1.25rem; border-radius: 12px; }
  h1 { font-size: 1.4rem; }
  .msg { max-width: 100%; }
  .account-strip .who { max-width: 9rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .card { animation: fs-rise 0.35s ease-out; }
}

@keyframes fs-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
