/**
 * AI Chat — fit to screen, back in header, aesthetic options layout.
 */

/* ----- Header: back, Prepriga logo, title center ----- */
.ai-chat-header {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.ai-chat-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 6px;
  margin: 0 -4px;
  border-radius: var(--app-radius-md);
  color: var(--app-text);
  font-size: var(--app-text-sm);
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s;
}

.ai-chat-back:hover {
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.ai-chat-back svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.ai-chat-title {
  justify-self: center;
  max-width: 120px;
}

/* ----- Main: fill viewport, no overflow ----- */
.app-root .app-main {
  overflow-x: hidden;
}

.ai-chat-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ai-chat-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-left: var(--app-space-sm);
  padding-right: var(--app-space-sm);
  padding-bottom: 0;
}

.ai-chat-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: var(--app-space);
}

.ai-chat-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  overflow: hidden;
  padding: var(--app-space);
}

/* ----- Options: mode + quick prompts, compact and aesthetic ----- */
.ai-chat-options {
  flex-shrink: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--app-border-soft);
  margin-bottom: var(--app-space-sm);
}

.ai-chat-options-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-text-muted);
  margin-bottom: 8px;
  margin-top: 10px;
}

.ai-chat-options-label:first-child {
  margin-top: 0;
}

.ai-chat-modes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-chat-mode {
  padding: 8px 14px;
  border-radius: var(--app-radius-full);
  font-size: var(--app-text-sm);
  font-weight: 500;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  color: var(--app-text-secondary);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.1s;
}

.ai-chat-mode:hover {
  border-color: var(--app-primary);
  color: var(--app-primary);
  background: var(--app-primary-soft);
}

.ai-chat-mode.active {
  background: var(--app-primary);
  border-color: var(--app-primary);
  color: #fff;
  font-weight: 600;
}

.ai-chat-mode:active {
  transform: scale(0.98);
}

.ai-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-chat-quick-btn {
  padding: 8px 12px;
  font-size: var(--app-text-xs);
  font-weight: 500;
  background: var(--app-bg);
  border: 1px solid var(--app-border-soft);
  border-radius: var(--app-radius-md);
  color: var(--app-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.2s, color 0.2s, background 0.2s, box-shadow 0.2s;
}

.ai-chat-quick-btn:hover {
  border-color: var(--app-primary);
  color: var(--app-primary);
  background: var(--app-primary-soft);
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.12);
}

.ai-chat-quick-btn:active {
  transform: scale(0.98);
}

/* ----- Messages: scrollable, fills space ----- */
.ai-chat-messages {
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--app-space-sm);
  padding: 0 var(--app-space-sm);
  overflow-wrap: break-word;
  word-break: break-word;
}

.ai-chat-empty {
  font-size: var(--app-text-sm);
  color: var(--app-text-muted);
  margin: 0;
  padding: 8px 0;
}

/* Career counselling welcome (persona) */
.ai-chat-welcome {
  margin-bottom: var(--app-space-md);
  margin-left: 0;
  margin-right: 0;
  padding: var(--app-space-md) 12px;
  background: var(--app-primary-soft);
  border-radius: var(--app-radius-md);
  border: 1px solid rgba(99, 102, 241, 0.2);
}
.ai-chat-welcome-text {
  font-size: var(--app-text-sm);
  color: var(--app-text);
  line-height: 1.5;
  margin: 0 0 8px 0;
}
.ai-chat-welcome-text:last-child {
  margin-bottom: 0;
}

.ai-chat-messages .msg-user,
.ai-chat-messages .msg-bot {
  font-size: var(--app-text-sm);
  margin: 0 0 10px 0;
  padding: 10px 8px 10px 0;
  border-bottom: 1px solid var(--app-border-soft);
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

.ai-chat-messages .msg-user {
  color: var(--app-text);
  font-weight: 500;
}

.ai-chat-messages .msg-bot {
  color: var(--app-text-secondary);
}

/* ----- Form: fixed at bottom of card ----- */
.ai-chat-form {
  flex-shrink: 0;
  display: flex;
  gap: var(--app-space-sm);
  min-width: 0;
  width: 100%;
}

.ai-chat-input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  font-size: var(--app-text-base);
  box-sizing: border-box;
  background: var(--app-surface);
  color: var(--app-text);
}

.ai-chat-input:focus {
  border-color: var(--app-primary);
  outline: none;
  box-shadow: 0 0 0 2px var(--app-primary-soft);
}

.ai-chat-send {
  flex-shrink: 0;
  padding: 12px 20px;
  white-space: nowrap;
  border-radius: var(--app-radius-lg);
}
