/* ==========================================================
   ChatGPT-style layout overrides
   Loaded AFTER chat.css — scoped under body.chatgpt-layout
   ========================================================== */

/* ---- Theme-specific variables (extends chat.css :root) ---- */
body.chatgpt-layout {
  --input-bg: #ffffff;
  --input-text: #1a1d1d;
  --input-placeholder: #999;
  --typing-bg: #3a3d3d;
  --typing-text: #ccc;
  --hover-bg: rgba(7, 129, 140, 0.1);
}

/* Light theme */
body.chatgpt-layout[data-theme="light"] {
  --primary: #07818C;
  --primary-light: #07818C;
  --bg-dark: #ffffff;
  --bg-messages: #f7f7f8;
  --bg-assistant: #e8e8e8;
  --bg-input: #ffffff;
  --border: #d1d5db;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --input-bg: #f0f0f0;
  --input-text: #1a1a1a;
  --input-placeholder: #9ca3af;
  --typing-bg: #e0e0e0;
  --typing-text: #555;
  --hover-bg: rgba(7, 129, 140, 0.08);
}

/* 8seats teal theme */
body.chatgpt-layout[data-theme="teal"] {
  --primary: #17D3E5;
  --primary-light: #7eeaf4;
  --bg-dark: #064e56;
  --bg-messages: #07818C;
  --bg-assistant: rgba(255, 255, 255, 0.12);
  --bg-input: #064e56;
  --border: rgba(255, 255, 255, 0.2);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.6);
  --input-bg: rgba(255, 255, 255, 0.15);
  --input-text: #ffffff;
  --input-placeholder: rgba(255, 255, 255, 0.5);
  --typing-bg: rgba(255, 255, 255, 0.15);
  --typing-text: rgba(255, 255, 255, 0.8);
  --hover-bg: rgba(255, 255, 255, 0.1);
}

/* ---- Full-page app container ---- */
body.chatgpt-layout {
  overflow: hidden;
  height: 100%;
}

body.chatgpt-layout #chat-app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: none;
  transform: none;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---- Minimal header ---- */
body.chatgpt-layout #chat-header {
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
}

body.chatgpt-layout .header-left svg {
  display: none;
}

body.chatgpt-layout .header-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

body.chatgpt-layout .header-title {
  font-size: 16px;
  color: var(--text);
}

body.chatgpt-layout .header-icon-btn {
  color: var(--text-muted);
}

body.chatgpt-layout .header-icon-btn:hover {
  color: var(--text);
}

/* Hide close button in full-page mode */
body.chatgpt-layout #close-btn {
  display: none;
}

/* ---- Messages area ---- */
body.chatgpt-layout .messages {
  flex: 1;
  padding: 0;
  background: var(--bg-messages);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* Center all message children in a 768px column */
body.chatgpt-layout .messages > * {
  width: 100%;
  max-width: 768px;
  padding-left: 24px;
  padding-right: 24px;
  box-sizing: border-box;
}

body.chatgpt-layout .messages > .msg {
  padding-top: 8px;
  padding-bottom: 8px;
}

/* ---- ChatGPT-style messages: no bubbles ---- */

/* Both message types: full width within the column */
body.chatgpt-layout .msg {
  max-width: 768px;
  width: 100%;
}

/* User messages: right-aligned subtle chip */
body.chatgpt-layout .msg.user {
  align-self: center;
  display: flex;
  justify-content: flex-end;
}

body.chatgpt-layout .msg.user .msg-bubble {
  background: var(--primary);
  color: #fff;
  border-radius: 18px;
  padding: 10px 16px;
  font-size: 15px;
  max-width: 80%;
}

/* Assistant messages: no bubble, plain text */
body.chatgpt-layout .msg.assistant {
  align-self: center;
}

body.chatgpt-layout .msg.assistant .msg-bubble {
  background: transparent;
  color: var(--text);
  padding: 4px 0;
  font-size: 15px;
  line-height: 1.6;
  border-radius: 0;
}

body.chatgpt-layout .msg.assistant .msg-bubble a {
  color: var(--primary-light);
}

/* Suggestion pills after messages — full width */
body.chatgpt-layout .msg-actions {
  padding: 0;
}

body.chatgpt-layout .msg-actions .suggestion-btn {
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 10px;
  background: var(--bg-assistant);
  border: 1px solid var(--border);
  color: var(--text);
}

body.chatgpt-layout .msg-actions .suggestion-btn:hover {
  border-color: var(--primary);
  background: var(--hover-bg);
  color: var(--primary-light);
}

/* Tell me more button */
body.chatgpt-layout .tell-more-btn {
  border-radius: 10px;
  background: var(--bg-assistant);
  border: 1px solid var(--border);
  color: var(--text);
}

body.chatgpt-layout .tell-more-btn:hover {
  border-color: var(--primary);
  background: var(--hover-bg);
}

/* Typing indicator: visible pill within the column */
body.chatgpt-layout .typing {
  align-self: center;
  max-width: 768px;
  width: 100%;
  padding-left: 24px;
  padding-right: 24px;
  box-sizing: border-box;
}

body.chatgpt-layout .typing .msg-bubble {
  background: var(--typing-bg);
  border-radius: 18px;
  padding: 10px 18px;
  display: inline-flex;
  color: var(--typing-text);
}

/* ---- Welcome: default (with messages) ---- */
body.chatgpt-layout #welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px;
  min-height: auto;
}

body.chatgpt-layout .welcome-icon img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  box-shadow: 0 4px 24px rgba(7, 129, 140, 0.25);
}

body.chatgpt-layout .welcome-title {
  font-size: 24px;
  font-weight: 600;
  margin-top: 20px;
}

body.chatgpt-layout .welcome-sub {
  font-size: 15px;
  margin-top: 10px;
  max-width: 480px;
  line-height: 1.6;
}

/* Suggestion pills — larger rounded rectangles */
body.chatgpt-layout .welcome-suggestions {
  margin-top: 32px;
  gap: 10px;
  max-width: 560px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

body.chatgpt-layout .welcome-suggestions .suggestion-btn {
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 12px;
  background: var(--bg-assistant);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

body.chatgpt-layout .welcome-suggestions .suggestion-btn:hover {
  border-color: var(--primary);
  background: var(--hover-bg);
  color: var(--primary-light);
}

/* ---- Input area: centered, floating style ---- */
body.chatgpt-layout .input-area {
  background: var(--bg-dark);
  border-top: none;
  padding: 12px 24px 8px;
  max-width: 816px; /* 768 + 48 padding */
  margin: 0 auto;
  width: 100%;
  display: flex;
  gap: 10px;
  box-sizing: border-box;
}

body.chatgpt-layout #message-input {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--input-text);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  transition: border-color 0.2s;
}

body.chatgpt-layout #message-input::placeholder {
  color: var(--input-placeholder);
}

body.chatgpt-layout #message-input:focus {
  border-color: var(--primary);
  outline: none;
}

body.chatgpt-layout .send-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* ---- Footer note ---- */
body.chatgpt-layout .chatgpt-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0 12px;
  background: var(--bg-dark);
}

/* ==========================================================
   EMPTY STATE — centered layout (no messages yet)
   Uses :has() to detect when #welcome is the only child
   ========================================================== */

/* Pull header out of flow so flex centering works */
body.chatgpt-layout:has(#welcome:last-child) #chat-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

/* Center the messages + input group vertically */
body.chatgpt-layout:has(#welcome:last-child) #chat-app {
  justify-content: center;
  align-items: center;
}

/* Messages container: don't grow, just fit content */
body.chatgpt-layout:has(#welcome:last-child) .messages {
  flex: none;
  overflow: visible;
  background: transparent;
  width: 100%;
  max-width: 768px;
}

/* Welcome: compact centered, no min-height */
body.chatgpt-layout:has(#welcome:last-child) #welcome {
  padding: 0 24px 24px;
  justify-content: flex-end;
}

/* Input: tighter width to match centered welcome */
body.chatgpt-layout:has(#welcome:last-child) .input-area {
  max-width: 600px;
  padding: 0 24px;
  background: transparent;
}

/* Footer: pinned to bottom */
body.chatgpt-layout:has(#welcome:last-child) .chatgpt-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: transparent;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  body.chatgpt-layout .messages > * {
    padding-left: 16px;
    padding-right: 16px;
  }

  body.chatgpt-layout .input-area {
    padding: 12px 16px 8px;
  }

  body.chatgpt-layout:has(#welcome:last-child) .input-area {
    padding: 0 16px;
  }

  body.chatgpt-layout .welcome-title {
    font-size: 20px;
  }

  body.chatgpt-layout .welcome-sub {
    font-size: 14px;
  }

  body.chatgpt-layout .welcome-suggestions .suggestion-btn {
    font-size: 13px;
    padding: 8px 16px;
  }

  body.chatgpt-layout .chatgpt-footer {
    font-size: 10px;
    padding: 4px 0 10px;
  }
}
