/* Cavalry Salesforce Assistant — portal styles (dark navy) */
:root {
  --cavalry-blue: #1b3a78;
  --cavalry-blue-dark: #0a1730;
  --cavalry-gold: #d0973d;
  --cavalry-gold-light: #f3d29d;
  --bg: #08152b;
  --surface: #102544;
  --surface-2: #0c1d3a;
  --surface-3: #15295a;
  --ink: #eaf0fa;
  --muted: #93a6c4;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 560px at 88% -8%, rgba(208, 151, 61, 0.16), transparent 60%),
    radial-gradient(900px 520px at -6% 112%, rgba(27, 58, 120, 0.55), transparent 55%),
    linear-gradient(162deg, #0a1730 0%, #08152b 52%, #060f20 100%);
  background-attachment: fixed;
}

main {
  width: min(960px, calc(100% - 2rem));
  min-height: 100vh;
  margin: 0 auto;
  padding: 4.5rem 0 3rem;
}

/* ---------- Brand header ---------- */
.brand-header {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1.75rem;
}

.brand-mark {
  width: 3.6rem;
  height: 3.6rem;
  flex: 0 0 auto;
  border-radius: 0.9rem;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  background: #fff;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--cavalry-gold-light);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.3rem;
  color: var(--white, #fff);
  font-size: clamp(1.9rem, 4vw, 2.85rem);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1.02;
}

.brand-subtitle {
  margin: 0;
  color: rgba(234, 240, 250, 0.7);
  font-size: 0.98rem;
}

/* ---------- Status pill ---------- */
#status {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.5rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  font-size: 0.88rem;
  font-weight: 650;
  backdrop-filter: blur(12px);
}

#status::before {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--cavalry-gold);
  box-shadow: 0 0 0 0.24rem rgba(208, 151, 61, 0.2);
  content: "";
}

/* ---------- Cards / sections ---------- */
section {
  margin: 1rem 0;
  padding: clamp(1.25rem, 3vw, 2rem);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

section h2 {
  margin-bottom: 0.55rem;
  color: var(--ink);
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

section p {
  color: var(--muted);
  line-height: 1.6;
}

label {
  display: inline-block;
  margin-bottom: 0.45rem;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

input,
textarea {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.65rem;
  outline: none;
  color: var(--ink);
  background: var(--surface-2);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
  font: inherit;
  line-height: 1.5;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 8rem;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #6f86a8;
}

input:focus,
textarea:focus {
  border-color: var(--cavalry-gold);
  background: #0f2244;
  box-shadow: 0 0 0 4px rgba(208, 151, 61, 0.16);
}

/* ---------- Buttons ---------- */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.7rem;
  padding: 0.7rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--cavalry-blue), #0a1730);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #2553a8, #0a1730);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
}

button:focus-visible {
  outline: 3px solid var(--cavalry-gold-light);
  outline-offset: 3px;
}

button:active {
  transform: translateY(0);
}

button + button {
  margin-left: 0.55rem;
}

.secondary-button {
  min-height: 2.4rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border-strong);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
  font-size: 0.83rem;
  white-space: nowrap;
}

.secondary-button:hover {
  border-color: var(--cavalry-gold);
  color: #fff;
  background: rgba(208, 151, 61, 0.12);
  box-shadow: none;
}

#sign-out {
  border-color: var(--border-strong);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

#sign-out:hover {
  border-color: var(--cavalry-gold);
  background: rgba(208, 151, 61, 0.12);
  box-shadow: none;
}

/* ---------- Signed-in bar ---------- */
.signed-in-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem clamp(1.1rem, 3vw, 1.7rem);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
}

.signed-in-bar #user-email {
  margin: 0;
  color: var(--ink);
  font-weight: 650;
  font-size: 0.9rem;
}

/* ---------- Chat shell ---------- */
.chat-shell {
  padding: 0;
  overflow: hidden;
  border-top: 4px solid var(--cavalry-gold);
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.2rem, 3vw, 1.7rem);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
}

.chat-header .eyebrow {
  margin-bottom: 0.3rem;
  color: var(--cavalry-gold);
}

.chat-header h2 {
  margin-bottom: 0.3rem;
  color: #fff;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.chat-header p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Chat thread ---------- */
.chat-thread {
  display: flex;
  min-height: 22rem;
  max-height: 38rem;
  flex-direction: column;
  gap: 1rem;
  padding: clamp(1.1rem, 3vw, 1.6rem);
  overflow-y: auto;
  background:
    radial-gradient(900px 420px at 80% -10%, rgba(208, 151, 61, 0.06), transparent 60%),
    var(--surface-2);
}

/* ---------- Empty state ---------- */
.chat-empty-state {
  display: grid;
  min-height: 17rem;
  place-content: center;
  text-align: center;
  gap: 0.4rem;
}

.chat-empty-state .empty-mark {
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto 0.5rem;
  border-radius: 0.85rem;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  background: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.chat-empty-state h3 {
  margin: 0 0 0.3rem;
  color: #fff;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.chat-empty-state p {
  max-width: 30rem;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.suggestion-chip {
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.suggestion-chip:hover {
  border-color: var(--cavalry-gold);
  background: rgba(208, 151, 61, 0.12);
  transform: translateY(-1px);
}

/* ---------- Message rows + avatars ---------- */
.chat-message-row {
  display: flex;
  max-width: 88%;
  gap: 0.6rem;
  align-items: flex-start;
}

.chat-message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message-row.assistant {
  align-self: flex-start;
}

.chat-avatar {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  background: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.user .chat-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #1e52ae, #0a1730);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.chat-message-bubble {
  padding: 0.78rem 1rem;
  border-radius: 1rem;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3);
  font-size: 0.94rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.user .chat-message-bubble {
  color: #fff;
  background: linear-gradient(135deg, #1b3a78, #0a1730);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom-right-radius: 0.3rem;
}

.assistant .chat-message-bubble {
  color: var(--ink);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-bottom-left-radius: 0.3rem;
}

.chat-message-bubble h1,
.chat-message-bubble h2,
.chat-message-bubble h3 {
  color: #fff;
  margin: 0.5rem 0 0.3rem;
  line-height: 1.25;
}

.chat-message-bubble h1 { font-size: 1.1rem; }
.chat-message-bubble h2 { font-size: 1.02rem; }
.chat-message-bubble h3 { font-size: 0.95rem; }

.chat-message-bubble ul,
.chat-message-bubble ol {
  margin: 0.45rem 0;
  padding-left: 1.25rem;
}

.chat-message-bubble li {
  margin: 0.3rem 0;
}

.chat-message-bubble p {
  margin: 0.4rem 0;
}

.chat-message-bubble strong {
  color: var(--cavalry-gold-light);
  font-weight: 800;
}

.user .chat-message-bubble strong {
  color: #fff;
}

.chat-message-bubble a {
  color: var(--cavalry-gold-light);
  text-decoration: underline;
}

/* ---------- Typing indicator ---------- */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.2rem;
}

.typing-dots span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--cavalry-gold);
  animation: typing-blink 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-blink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-0.2rem); }
}

/* ---------- Composer ---------- */
.chat-composer {
  margin: 0;
  padding: clamp(1rem, 3vw, 1.4rem);
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.chat-composer textarea {
  min-height: 5.4rem;
  margin-bottom: 0.8rem;
  background: var(--surface-2);
}

.chat-composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.chat-composer-footer p {
  margin: 0;
  color: #72809a;
  font-size: 0.76rem;
  line-height: 1.4;
}

.chat-composer-footer button {
  min-width: 7rem;
}

.screen-reader-message {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* ---------- Scrollbar (dark) ---------- */
.chat-thread::-webkit-scrollbar {
  width: 0.5rem;
}
.chat-thread::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}
.chat-thread::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  main {
    width: min(100% - 1.25rem, 960px);
    padding: 2rem 0;
  }

  .brand-header {
    align-items: flex-start;
  }

  .brand-mark {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
  }

  h1 {
    font-size: 1.9rem;
  }

  section {
    padding: 1.2rem;
    border-radius: 1rem;
  }

  button {
    width: 100%;
  }

  button + button {
    width: 100%;
    margin: 0.6rem 0 0;
  }

  .chat-header,
  .chat-composer-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-header .secondary-button,
  .chat-composer-footer button {
    width: 100%;
  }

  .chat-message-row {
    max-width: 96%;
  }

  .chat-thread {
    min-height: 18rem;
    max-height: 30rem;
  }
}
