/* Modern, responsive, mobile-first chat UI */
:root {
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --bg: #0f1220;
  --panel: #12162a;
  --card: #171b31;
  --text: #e9eefc;
  --muted: #a9b4d0;
  --accent: #4f8cff;
  --border: rgba(255,255,255,.08);
  --shadow: 0 10px 30px rgba(0,0,0,.30);
  --user-bubble: #4f8cff;
  --bot-bubble: #2a2f4a;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  background: linear-gradient(180deg, #0b1020, var(--bg));
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* App Layout */
.app {
  display: flex;
  flex: 1;
  min-height: 0;
}

@media (min-width: 900px) { .app { flex-direction: row; } }

.sidebar {
  width: 240px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  transition: width 0.3s ease;
}
.sidebar.collapsed {
  width: 60px;
}
@media (max-width: 900px) { .sidebar { width: 100%; } }

/* Brand */
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(79,140,255,.18);
  display: grid; place-items: center;
  border: 1px solid var(--border);
}
.title { font-weight: 800; }
.sub { color: var(--muted); font-size: 12px; }

/* Main Column */
.main { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.topbar {
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

/* Chat Panel */
.chatwrap {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 10px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.chat-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-bubble.bot {
  background: var(--bot-bubble);
  color: var(--text);
  align-self: flex-start;
}

.chat-bubble.user {
  background: var(--user-bubble);
  color: #fff;
  align-self: flex-end;
}

/* Input Bar */
.input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.input-bar input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}

.input-bar .send-button {
  padding: 10px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
}

.input-bar .send-button:hover {
  filter: brightness(1.1);
}

/* Dark theme buttons + selects */
button, select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

button:hover, select:hover {
  background: rgba(255,255,255,0.08);
}

select {
  appearance: none;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%),
                    linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position: calc(100% - 12px) calc(50% - 3px),
                       calc(100% - 7px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 24px;
}

/* Sidebar control groups */
.sidebar .controls {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar .group {
  background: var(--card);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar .group-title {
  font-weight: 600;
  color: var(--text);
  font-size: 19px;
  opacity: 0.9;
}

/* Layout rows */
.sidebar .row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sidebar .row.buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Polished selects and buttons */
.sidebar select,
.sidebar button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar select:hover,
.sidebar button:hover {
  background: rgba(255,255,255,0.08);
}

.sidebar button:active {
  background: rgba(255,255,255,0.12);
}

/* Make dropdown arrow match theme */
.sidebar select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%),
                    linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 8px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

/* Fix long "Signed in as" label wrapping */
.sidebar #status {
  display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
  font-size: 12px;
}

.sidebar .row {
  flex-wrap: wrap;
}
.sidebar .row span {
  max-width: 100%;
}

/* Fix dropdown hover showing white background */
.sidebar select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.sidebar select:hover,
.sidebar select:focus {
  background: var(--card);
  color: var(--text);
}


.sidebar select option {
  background: var(--card);
  color: var(--text);
}

/* Fix Web Chat citation/link white background */
#webchat a,
#webchat a:visited {
  background: transparent !important;
  color: var(--accent) !important;
}

#webchat a:hover,
#webchat a:focus {
  background: rgba(255,255,255,0.05) !important;
  color: var(--accent) !important;
}

/* Ensure markdown link container never gets white background */
#webchat .webchat__markdown__link,
#webchat .webchat__markdown__paragraph {
  background: transparent !important;
  color: var(--text) !important;
}
