/* ImpactFlow Self-Discovery — shared styles
   Palette: navy #0d1b2a, gold #c9a84c, cream #f8f5ef */

:root {
  --navy: #0d1b2a;
  --gold: #c9a84c;
  --cream: #f8f5ef;
  --navy-soft: #1c3049;
  --shadow: rgba(13, 27, 42, 0.12);
  --green: #2e7d32;
  --yellow: #c9a84c;
  --red: #c0392b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--navy);
  font-family: "DM Sans", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ---------- App bar / navigation ---------- */

.appbar {
  background: var(--navy);
  color: var(--cream);
  border-bottom: 2px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 50;
}

.appbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.appbar-brand {
  font-family: "Playfair Display", "DM Sans", serif;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  text-decoration: none;
  white-space: nowrap;
}

.appbar-nav {
  display: flex;
  gap: 6px;
  flex: 1;
}

.navlink {
  color: rgba(248, 245, 239, 0.75);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
}

.navlink:hover {
  color: var(--cream);
  background: rgba(248, 245, 239, 0.08);
}

.navlink.active {
  color: var(--navy);
  background: var(--gold);
}

.appbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--gold);
}

.nav-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--cream);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-logout {
  background: transparent;
  color: rgba(248, 245, 239, 0.8);
  border: 1px solid rgba(248, 245, 239, 0.3);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
}

.nav-logout:hover:not(:disabled) {
  background: rgba(248, 245, 239, 0.1);
  color: var(--cream);
}

/* Personalized greeting on the intake page. */
.greeting {
  font-family: "Playfair Display", "DM Sans", serif;
  font-size: 1.15rem;
  color: var(--navy);
  margin: 0 0 22px;
}

.greeting strong {
  color: var(--gold);
}

.resume-note {
  color: var(--navy-soft);
  font-size: 0.92rem;
  font-style: italic;
  margin: -10px 0 22px;
}

/* ---------- Discovery flow ---------- */

.brand {
  font-family: "Playfair Display", "DM Sans", serif;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 40px;
}

.progress {
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.prompt-title {
  font-family: "Playfair Display", "DM Sans", serif;
  font-size: 1.35rem;
  color: var(--gold);
  margin: 0 0 10px;
}

.prompt-text {
  font-family: "Playfair Display", "DM Sans", serif;
  font-size: 1.7rem;
  font-weight: 500;
  color: var(--navy);
  margin: 0 0 28px;
  line-height: 1.35;
}

textarea {
  width: 100%;
  min-height: 240px;
  padding: 20px;
  border: 1px solid rgba(13, 27, 42, 0.18);
  border-radius: 12px;
  background: #fff;
  color: var(--navy);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 1.05rem;
  line-height: 1.6;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.25);
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  gap: 16px;
}

button {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  padding: 13px 30px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.2s ease, background 0.2s ease;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gold);
  color: var(--navy);
}

.btn-primary:hover:not(:disabled) {
  background: #d8b95f;
}

.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid rgba(13, 27, 42, 0.25);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(13, 27, 42, 0.05);
}

/* ---------- Loading state ---------- */

.loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 60vh;
  background: var(--cream);
  color: var(--navy);
}

.loading.active {
  display: flex;
}

.loading p {
  font-family: "Playfair Display", "DM Sans", serif;
  font-size: 1.6rem;
  color: var(--navy);
}

.spinner {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(201, 168, 76, 0.3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 22px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Profile page ---------- */

.profile-narrative {
  background: var(--navy);
  color: var(--cream);
  padding: 36px 34px;
  border-radius: 16px;
  font-size: 1.2rem;
  line-height: 1.7;
  box-shadow: 0 10px 30px var(--shadow);
  margin-bottom: 36px;
}

.section-label {
  font-family: "Playfair Display", "DM Sans", serif;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 18px;
}

.ikigai-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 40px;
}

.card {
  background: #fff;
  border: 1px solid rgba(13, 27, 42, 0.1);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 4px 14px rgba(13, 27, 42, 0.05);
}

.card h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: var(--navy);
}

.card p {
  margin: 0;
  color: var(--navy-soft);
  font-size: 0.98rem;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dot.high {
  background: var(--green);
}
.dot.medium {
  background: var(--yellow);
}
.dot.low {
  background: var(--red);
}

.triad-block {
  background: #fff;
  border: 1px solid rgba(13, 27, 42, 0.1);
  border-left: 5px solid var(--gold);
  border-radius: 14px;
  padding: 26px 28px;
  margin-bottom: 40px;
}

.triad-block h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-family: "Playfair Display", "DM Sans", serif;
  font-size: 1.3rem;
  color: var(--navy);
}

.triad-block p {
  margin: 0;
  color: var(--navy-soft);
}

.confirm-row {
  text-align: center;
}

.confirmed {
  background: var(--navy) !important;
  color: var(--cream) !important;
  cursor: default;
}

/* ---------- Profile edit mode ---------- */

.edit-help {
  color: var(--navy-soft);
  margin: 0 0 24px;
}

.edit-field {
  margin-bottom: 18px;
}

.edit-field label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--navy);
  margin-bottom: 8px;
}

textarea.edit {
  min-height: 120px;
  padding: 14px 16px;
  font-size: 0.98rem;
}

/* ---------- Reflection chat ---------- */

.thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 4px 2px 8px;
  margin-bottom: 22px;
}

.bubble {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 1rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.bubble .who {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 5px;
  opacity: 0.7;
}

.bubble.coach {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(13, 27, 42, 0.1);
  color: var(--navy-soft);
  border-bottom-left-radius: 5px;
}

.bubble.person {
  align-self: flex-end;
  background: var(--navy);
  color: var(--cream);
  border-bottom-right-radius: 5px;
}

.bubble.person .who {
  color: var(--gold);
  opacity: 1;
}

.note {
  align-self: center;
  font-size: 0.85rem;
  color: var(--gold);
  font-style: italic;
}

.note.err {
  color: var(--red);
}

.reflect-input textarea.edit {
  min-height: 90px;
}

.back-link {
  margin-top: 8px;
}

.back-link a {
  color: var(--navy-soft);
  text-decoration: none;
  font-size: 0.92rem;
}

.back-link a:hover {
  color: var(--gold);
}

.error-box {
  background: #fdecea;
  border: 1px solid var(--red);
  color: #7a231b;
  padding: 18px 22px;
  border-radius: 12px;
}

/* ---------- Profile version history ---------- */

.history-block {
  margin-top: 36px;
}

.history-toggle {
  background: none;
  border: none;
  color: var(--navy-soft);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.history-toggle:hover {
  color: var(--gold);
}

.revision {
  background: #fff;
  border: 1px solid rgba(13, 27, 42, 0.1);
  border-left: 4px solid var(--gold);
  border-radius: 12px;
  padding: 16px 20px;
  margin-top: 14px;
}

.revision-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.85rem;
}

.revision-source {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}

.revision-date {
  color: var(--navy-soft);
}

.revision-note {
  color: var(--navy-soft);
  font-style: italic;
  margin: 8px 0 0;
  font-size: 0.9rem;
}

.revision details {
  margin-top: 10px;
}

.revision summary {
  cursor: pointer;
  color: var(--navy-soft);
  font-size: 0.85rem;
  font-weight: 600;
}

.revision dl {
  margin: 10px 0 0;
}

.revision dt {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--navy);
  margin-top: 10px;
}

.revision dd {
  margin: 2px 0 0;
  color: var(--navy-soft);
  font-size: 0.9rem;
  white-space: pre-wrap;
}

/* Previous-answers history on the intake page reuses the .revision card. */
.history-wrap {
  padding-top: 0;
}

.revision .history-load {
  margin-top: 12px;
  font-size: 0.85rem;
  padding: 9px 18px;
}

.revision-answer {
  margin: 10px 0 0;
  color: var(--navy-soft);
  font-size: 0.95rem;
  white-space: pre-wrap;
}

/* ---------- Phase 1.5 calibration scales ---------- */

.scale-group {
  margin-bottom: 34px;
}

.scale-pair {
  background: #fff;
  border: 1px solid rgba(13, 27, 42, 0.1);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
  transition: border-color 0.2s ease;
}

.scale-pair.answered {
  border-color: var(--gold);
}

.scale-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.scale-label {
  flex: 1 1 0;
  font-size: 0.95rem;
  color: var(--navy-soft);
}

.scale-label.left {
  text-align: right;
}

.scale-label.right {
  text-align: left;
}

.scale-dots {
  display: flex;
  gap: 12px;
  flex: 0 0 auto;
  padding: 0 4px;
}

.scale-dot {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(13, 27, 42, 0.25);
  background: var(--cream);
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease,
    border-color 0.15s ease;
}

.scale-dot:hover:not(:disabled) {
  border-color: var(--gold);
}

.scale-dot.selected {
  background: var(--gold);
  border-color: var(--gold);
}

.scale-progress {
  text-align: center;
  color: var(--navy-soft);
  font-size: 0.88rem;
  font-style: italic;
  margin: 6px 0 0;
}

@media (max-width: 560px) {
  .ikigai-grid {
    grid-template-columns: 1fr;
  }
  .prompt-text {
    font-size: 1.4rem;
  }
  /* Stack the bipolar labels above/below the dots on narrow screens. */
  .scale-row {
    flex-direction: column;
    gap: 8px;
  }
  .scale-label.left,
  .scale-label.right {
    text-align: center;
    font-weight: 600;
  }
  .scale-dots {
    gap: 16px;
  }
}

/* ---------- Switch-account nav button ---------- */
/* Same chrome as Log out, sitting just before it in the user cluster. */
.nav-switch {
  background: transparent;
  color: rgba(248, 245, 239, 0.8);
  border: 1px solid rgba(248, 245, 239, 0.3);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
}

.nav-switch:hover:not(:disabled) {
  background: rgba(248, 245, 239, 0.1);
  color: var(--cream);
}

/* ---------- Login landing ---------- */
.login-box {
  margin-top: 28px;
}

/* ---------- Admin page ---------- */
/* A wider column than the default reading width so the user table fits. */
.wrap-wide {
  max-width: 1040px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(20, 33, 61, 0.12);
}

.admin-table th {
  font-weight: 600;
  color: var(--navy);
  border-bottom: 2px solid rgba(20, 33, 61, 0.2);
}

.admin-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.admin-table th.sortable:hover {
  color: var(--gold);
}

.admin-row {
  cursor: pointer;
}

.admin-row:hover {
  background: rgba(20, 33, 61, 0.04);
}

.admin-row.open {
  background: rgba(20, 33, 61, 0.06);
}

.role-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.role-badge.admin {
  background: var(--gold);
  color: var(--navy);
}

.role-badge.user {
  background: rgba(20, 33, 61, 0.12);
  color: var(--navy);
}

.admin-detail {
  padding: 8px 4px 20px;
}

.admin-conv {
  margin-bottom: 12px;
  border: 1px solid rgba(20, 33, 61, 0.12);
  border-radius: 8px;
  padding: 10px 14px;
}

.admin-conv-body {
  margin-top: 10px;
}

.admin-profile {
  border: 1px solid rgba(20, 33, 61, 0.12);
  border-radius: 8px;
  padding: 14px;
}

.conv-msg {
  font-size: 0.84rem;
  color: var(--navy);
  opacity: 0.75;
}
