/* Opptimise coach UI — tokens from opptimise_design_system.md */

:root {
  --primary: #5db2af;
  --primary-dark: #1c706e;
  --primary-light: #b8d7d6;
  --primary-mist: #d6f5f4;
  --primary-bg: rgba(184, 215, 214, 0.3);
  --success: #21be77;
  --warning: #ff6b00;
  --secondary: #f3f4f6;
  --muted-foreground: #a1a3ab;
  --secondary-foreground: #1c1c1c;
  --border-teal: #5db2af;
  --destructive: #d4183d;
  --white: #ffffff;
  --shadow-subtle: 0 4px 4px rgba(0, 0, 0, 0.04);
  --shadow-light: 0 4px 4px rgba(0, 0, 0, 0.05);
  --gradient-header: linear-gradient(98deg, #5db2af 0%, #b8d7d6 100%);
  --font-display: 'Darker Grotesque', system-ui, sans-serif;
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-body: 'Open Sans', system-ui, sans-serif;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-pill: 9999px;
  --radius-chat-input: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--secondary-foreground);
  background: var(--secondary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Auth --- */
#auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#auth-overlay.hidden {
  display: none;
}

#auth-box {
  background: var(--white);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-xl);
  padding: 2rem 2.25rem;
  width: min(380px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-subtle);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.auth-brand img {
  height: 28px;
  width: auto;
  display: block;
}

.auth-brand h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.1;
}

#auth-box p {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

#auth-input {
  background: var(--white);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-md);
  color: var(--secondary-foreground);
  padding: 0.65rem 0.875rem;
  font-size: 0.875rem;
  font-family: var(--font-body);
  outline: none;
}

#auth-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(93, 178, 175, 0.25);
}

#auth-error {
  font-size: 0.75rem;
  color: var(--destructive);
  min-height: 1rem;
}

/* --- Shell --- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.coach-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  background: var(--gradient-header);
  border-bottom: 2px solid var(--white);
  box-shadow: var(--shadow-subtle);
  flex-shrink: 0;
}

.coach-header-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.coach-header-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: #000;
  background-image: url('/static/images/logo.png');
  background-position: center;
  background-repeat: no-repeat;
  background-size: 30px 16px;
  flex-shrink: 0;
}

.coach-header-title {
  font-family: var(--font-ui);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--white);
  line-height: 1.1;
  white-space: nowrap;
}

.coach-header-sub {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  margin-left: 0.25rem;
}

.coach-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-spacer {
  flex: 1;
}

.user-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.user-controls label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}

#user-id-input {
  width: min(280px, 40vw);
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius-pill);
  color: var(--white);
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-family: ui-monospace, Menlo, Monaco, Consolas, monospace;
  outline: none;
}

#user-id-input::placeholder {
  color: rgba(255, 255, 255, 0.65);
}

#user-id-input:focus {
  border-color: var(--white);
  background: rgba(255, 255, 255, 0.22);
}

.btn-header-ghost {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-pill);
  color: var(--white);
  padding: 0.35rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-header-ghost:hover {
  background: rgba(255, 255, 255, 0.28);
}

.btn-header-solid {
  background: var(--white);
  border: none;
  border-radius: var(--radius-pill);
  color: var(--primary-dark);
  padding: 0.4rem 1rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-header-solid:hover {
  background: var(--primary-mist);
}

/* --- Layout --- */
#main {
  flex: 1;
  display: flex;
  overflow: hidden;
  padding: 1rem;
  gap: 1rem;
}

/* --- Prompt sidebar (design: Prompt Suggestions) --- */
#sidebar {
  width: 280px;
  background: var(--white);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-subtle);
}

#sidebar-header {
  padding: 1rem 1rem 0.75rem;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary-dark);
  text-align: center;
  border-bottom: 1px solid var(--primary-light);
}

.sidebar-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 0.5rem 0.75rem 0.75rem;
}

.sidebar-section-label {
  padding: 0.75rem 0.25rem 0.35rem;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.prompt-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
  font-family: var(--font-body);
  font-size: 0.6875rem;
  line-height: 1.45;
  color: var(--secondary-foreground);
  background: var(--primary-bg);
  border: 1px solid var(--border-teal);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.prompt-item:hover {
  background: rgba(184, 215, 214, 0.5);
  border-color: var(--primary);
}

/* --- Chat column --- */
#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--secondary);
  border: 2px solid var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-subtle);
  overflow: hidden;
}

#chat {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#chat::-webkit-scrollbar {
  width: 6px;
}

#chat::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 3px;
}

/* Chat bubbles */
.message {
  display: flex;
  max-width: 80%;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.75rem;
  line-height: 1.5;
}

.message.user {
  align-self: flex-end;
  flex-direction: row;
  align-items: center;
}

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

.message-content {
  padding: 0.75rem 1rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message.user .message-content {
  background: var(--primary);
  color: var(--white);
  border-radius: var(--radius-xl);
  border-bottom-right-radius: 0;
}

.message.assistant .message-content {
  background: var(--white);
  color: var(--secondary-foreground);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-xl);
  border-bottom-left-radius: 0;
  box-shadow: var(--shadow-subtle);
  white-space: normal;
}

.message-content.coach-markdown strong,
.message.assistant .message-content strong,
.message.assistant .message-content b {
  font-weight: 700;
}

.message.assistant .message-content em {
  font-style: italic;
}

.message.assistant .message-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background: var(--primary-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.message.assistant .message-content ul,
.message.assistant .message-content ol {
  margin: 0.35em 0;
  padding-left: 1.25em;
}

.message.assistant .message-content li {
  margin: 0.2em 0;
}

.message.assistant .message-content li + li {
  margin-top: 0.15em;
}

.message.assistant .message-content p {
  margin: 0 0 0.5em;
}

.message.assistant .message-content p:last-child {
  margin-bottom: 0;
}

.message.assistant .message-content blockquote {
  margin: 0.35em 0;
  padding-left: 0.75em;
  border-left: 3px solid var(--primary-light);
  color: var(--muted-foreground);
}

.message.assistant.streaming .message-content {
  opacity: 0.92;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.message-avatar.bot-avatar {
  background: #000 url('/static/images/logo.png') center / 30px 16px no-repeat;
}

.message-avatar.user-avatar {
  background: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
}

.message-avatar.user-avatar svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

/* Typing indicator (manager coach) */
.message.assistant.thinking .message-content {
  min-height: 42px;
  display: flex;
  align-items: center;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.35;
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* Chat input (design: Chat Input) */
#input-area {
  margin: 0 1rem 1rem;
  background: var(--white);
  border: 2px solid var(--primary);
  border-radius: var(--radius-chat-input);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: var(--shadow-subtle);
  flex-shrink: 0;
}

#input-area textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  min-height: 2.5rem;
  max-height: 7.5rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--secondary-foreground);
}

#input-area textarea::placeholder {
  color: var(--muted-foreground);
}

.input-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-secondary-outline {
  background: var(--white);
  border: 2px solid var(--primary-dark);
  border-radius: var(--radius-pill);
  color: var(--primary-dark);
  padding: 0.45rem 1.1rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary-outline:hover {
  background: var(--primary-mist);
}

.btn-ask-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary-dark);
  border: none;
  border-radius: var(--radius-pill);
  color: var(--white);
  padding: 0.45rem 1.15rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-ask-pill:hover:not(:disabled) {
  background: #165956;
  transform: translateY(-1px);
}

.btn-ask-pill:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-ask-pill svg {
  width: 14px;
  height: 14px;
}

.btn-primary {
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  color: var(--white);
  padding: 0.65rem 1.5rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.875rem;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

/* --- Modals --- */
.coach-modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 28, 28, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
}

.coach-modal.hidden {
  display: none;
}

.coach-modal-inner {
  background: var(--white);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-xl);
  padding: 1.75rem 2rem;
  width: min(680px, 96vw);
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-light);
}

.coach-modal-inner h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 1.25rem;
}

.coach-modal-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.coach-modal-close:hover {
  color: var(--secondary-foreground);
}

.profile-categories,
.team-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.profile-category,
.team-card {
  background: var(--white);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-subtle);
}

.profile-category h3,
.team-card h3 {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  gap: 0.5rem;
}

.score-name {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  text-transform: capitalize;
  width: 9rem;
  flex-shrink: 0;
}

.score-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--secondary);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
}

.score-bar.mid {
  background: var(--warning);
}

.score-bar.low {
  background: var(--destructive);
}

.score-val {
  font-size: 0.75rem;
  color: var(--secondary-foreground);
  width: 2rem;
  text-align: right;
}

.score-category-label {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

@media (max-width: 900px) {
  #main {
    flex-direction: column;
    padding: 0.75rem;
  }

  #sidebar {
    width: 100%;
    max-height: 200px;
  }

  .coach-header-title {
    font-size: 1.25rem;
  }

  .coach-header-sub {
    display: none;
  }
}
