/* src/web/styles.css */
*, *:before, *:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #1b1a19;
  --bg2: #252423;
  --bg3: #323130;
  --bg4: #3b3a39;
  --border: #484644;
  --border-focus: #479ef5;
  --text: #f3f2f1;
  --text-sub: #c8c6c4;
  --text-dim: #797775;
  --accent: #479ef5;
  --accent-hover: #6cb8f6;
  --accent-press: #2886de;
  --accent-subtle: #479ef51f;
  --green: #54b054;
  --green-bg: #54b0541f;
  --red: #f1707b;
  --red-bg: #f1707b1f;
  --yellow: #ffc83d;
  --shadow-2: 0 1.6px 3.6px #0000005c, 0 .3px .9px #00000047;
  --shadow-4: 0 3.2px 7.2px #0000005c, 0 .6px 1.8px #00000047;
  --shadow-8: 0 6.4px 14.4px #0000005c, 0 1.2px 3.6px #00000047;
  --radius: 4px;
  --radius-lg: 8px;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
}

html, body, #root {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  height: 100%;
  font-size: 14px;
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  overflow: hidden;
  height: 100vh;
}

.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  overflow: hidden;
  flex-direction: column;
}

.sidebar-header {
  border-bottom: 1px solid var(--border);
  padding: 14px 12px 10px;
}

.sidebar-logo {
  color: var(--accent);
  letter-spacing: -.01em;
  font-size: 15px;
  font-weight: 600;
}

.sidebar-logo span {
  color: var(--text-sub);
  font-weight: 400;
}

.sidebar-section {
  padding: 8px 0 4px;
}

.sidebar-label {
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 12px 4px;
  font-size: 11px;
  font-weight: 600;
}

.sessions-list {
  overflow-y: auto;
  flex: 1;
}

.session-item {
  cursor: pointer;
  display: flex;
  border-radius: var(--radius);
  flex-direction: column;
  gap: 2px;
  margin: 1px 6px;
  padding: 7px 12px;
  transition: background .1s;
}

.session-item:hover {
  background: var(--bg3);
}

.session-item.active {
  background: var(--accent-subtle);
}

.session-item .sid {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.session-item .preview {
  color: var(--text-sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.session-item .date {
  color: var(--text-dim);
  font-size: 11px;
}

.sidebar-new-session {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
}

.btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
  padding: 5px 12px;
  transition: background .1s, border-color .1s;
  font-size: 13px;
  font-weight: 400;
  line-height: 20px;
}

.btn:hover {
  background: var(--bg3);
  border-color: var(--border);
}

.btn:active {
  background: var(--bg4);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-accent:active {
  background: var(--accent-press);
}

.main {
  display: flex;
  overflow: hidden;
  background: var(--bg);
  flex-direction: column;
}

.main-header {
  border-bottom: 1px solid var(--border);
  display: flex;
  background: var(--bg2);
  flex-shrink: 0;
  align-items:  center;
  gap: 12px;
  height: 48px;
  padding: 0 20px;
}

.main-header .client-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.conn-dot {
  background: var(--text-dim);
  border-radius: 50%;
  width: 8px;
  height: 8px;
  margin-left: auto;
}

.conn-dot.connected {
  background: var(--green);
}

.conn-dot.error {
  background: var(--red);
}

.chat-area {
  overflow-y: auto;
  display: flex;
  scroll-behavior: smooth;
  flex-direction: column;
  flex: 1;
  gap: 20px;
  padding: 24px 28px;
}

.chat-empty {
  display: flex;
  color: var(--text-dim);
  flex-direction: column;
  flex: 1;
  justify-content: center;
  align-items:  center;
  gap: 8px;
}

.chat-empty .big {
  opacity: .2;
  font-size: 40px;
}

.chat-empty .hint {
  color: var(--text-dim);
  font-size: 13px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 860px;
}

.message-label {
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
}

.message.user .message-label {
  color: var(--accent);
}

.message.assistant .message-label {
  color: var(--text-sub);
}

.message-body {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-2);
  color: var(--text);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
}

.message.user .message-body {
  background: var(--accent-subtle);
  border-color: #479ef54d;
}

.message-body h1, .message-body h2, .message-body h3 {
  color: var(--text);
  margin: 10px 0 4px;
  font-weight: 600;
}

.message-body h1 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  font-size: 17px;
}

.message-body h2 {
  font-size: 15px;
}

.message-body h3 {
  color: var(--text-sub);
  font-size: 14px;
}

.message-body code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: #ce9178;
  padding: 1px 5px;
  font-family: Cascadia Code, Fira Code, ui-monospace, monospace;
  font-size: 12.5px;
}

.message-body pre {
  border-radius: var(--radius-lg);
  overflow-x: auto;
  background: #1e1e1e;
  border: 1px solid #333;
  margin: 8px 0;
  padding: 14px 16px;
}

.message-body pre code {
  color: #d4d4d4;
  background: none;
  border: none;
  padding: 0;
  font-size: 12.5px;
}

.message-body ul, .message-body ol {
  margin: 6px 0;
  padding-left: 20px;
}

.message-body li {
  margin: 3px 0;
}

.message-body p {
  margin: 5px 0;
}

.message-body strong {
  font-weight: 600;
}

.message-body em {
  color: var(--text-sub);
  font-style: italic;
}

.message-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.status-bar {
  display: flex;
  color: var(--text-dim);
  align-items:  center;
  gap: 8px;
  min-height: 26px;
  padding: 4px 28px;
  font-size: 12px;
}

.spinner {
  display: inline-block;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0);
  }

  to {
    transform: rotate(360deg);
  }
}

.cost-line {
  color: var(--text-dim);
  margin-left: auto;
  font-size: 11px;
}

.input-area {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  padding: 12px 20px 16px;
}

.input-row {
  display: flex;
  align-items:  flex-end;
  gap: 8px;
}

.input-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  resize: none;
  outline: none;
  flex: 1;
  min-height: 40px;
  max-height: 160px;
  padding: 9px 12px;
  transition: border-color .1s, box-shadow .1s;
  font-size: 14px;
  line-height: 1.5;
}

.input-box:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--border-focus);
}

.input-box:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.input-box::placeholder {
  color: var(--text-dim);
}

.send-btn {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font);
  cursor: pointer;
  flex-shrink: 0;
  height: 40px;
  padding: 0 16px;
  transition: background .1s, border-color .1s;
  font-size: 14px;
  font-weight: 600;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.send-btn:active:not(:disabled) {
  background: var(--accent-press);
}

.send-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.no-client {
  display: flex;
  color: var(--text-dim);
  flex: 1;
  justify-content: center;
  align-items:  center;
  font-size: 14px;
}

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

::-webkit-scrollbar-track {
  background: none;
}

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

::-webkit-scrollbar-thumb:hover {
  background: #c1bfbd;
}

.login-screen {
  display: flex;
  background: var(--bg);
  justify-content: center;
  align-items:  center;
  height: 100vh;
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-8);
  width: 380px;
  padding: 36px 32px;
}

.login-logo {
  color: var(--accent);
  letter-spacing: -.02em;
  margin-bottom: 4px;
  font-size: 22px;
  font-weight: 700;
}

.login-sub {
  color: var(--text-sub);
  margin-bottom: 24px;
  font-size: 13px;
  line-height: 1.4;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  outline: none;
  width: 100%;
  padding: 9px 12px;
  transition: border-color .1s, box-shadow .1s;
  font-size: 14px;
}

.login-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--border-focus);
}

.login-input:disabled {
  opacity: .4;
}

.login-input::placeholder {
  color: var(--text-dim);
}

.login-btn {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font);
  cursor: pointer;
  width: 100%;
  padding: 9px 16px;
  transition: background .1s, border-color .1s;
  font-size: 14px;
  font-weight: 600;
}

.login-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.login-btn:active:not(:disabled) {
  background: var(--accent-press);
}

.login-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.login-error {
  color: var(--red);
  margin-top: 8px;
  font-size: 12px;
}

.wizard-screen {
  display: flex;
  background: var(--bg);
  justify-content: center;
  align-items:  center;
  height: 100vh;
}

.wizard-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-8);
  width: 540px;
  padding: 36px 32px;
}

.wizard-header {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  margin-bottom: 28px;
}

.wizard-brand {
  color: var(--accent);
  letter-spacing: -.01em;
  font-size: 16px;
  font-weight: 700;
}

.wizard-brand span {
  color: var(--text-sub);
  font-weight: 400;
}

.wizard-progress {
  display: flex;
  align-items:  center;
  gap: 5px;
}

.wizard-dot {
  background: var(--border);
  border-radius: 50%;
  width: 8px;
  height: 8px;
  transition: background .2s;
}

.wizard-dot.active {
  background: var(--accent);
}

.wizard-title {
  color: var(--text);
  margin-bottom: 18px;
  font-size: 16px;
  font-weight: 600;
}

.wizard-body {
  margin-bottom: 24px;
}

.wizard-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wizard-label {
  color: var(--text-sub);
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
}

.wizard-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  outline: none;
  width: 100%;
  padding: 8px 12px;
  transition: border-color .1s, box-shadow .1s;
  font-size: 14px;
}

.wizard-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--border-focus);
}

.wizard-textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  resize: vertical;
  outline: none;
  width: 100%;
  padding: 8px 12px;
  transition: border-color .1s, box-shadow .1s;
  font-size: 14px;
  line-height: 1.55;
}

.wizard-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--border-focus);
}

.wizard-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wizard-pill {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-family: var(--font);
  cursor: pointer;
  border-radius: 16px;
  padding: 5px 14px;
  transition: border-color .1s, background .1s, color .1s;
  font-size: 13px;
}

.wizard-pill:hover, .wizard-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.wizard-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wizard-checkbox {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-sub);
  align-items:  center;
  gap: 7px;
  padding: 6px 12px;
  transition: border-color .1s, background .1s, color .1s;
  font-size: 13px;
}

.wizard-checkbox input {
  display: none;
}

.wizard-checkbox:hover, .wizard-checkbox.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.wizard-actions {
  display: flex;
  border-top: 1px solid var(--border);
  align-items:  center;
  gap: 10px;
  padding-top: 8px;
}

.admin-layout {
  display: flex;
  background: var(--bg);
  flex-direction: column;
  height: 100vh;
}

.admin-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  box-shadow: var(--shadow-2);
  flex-shrink: 0;
  justify-content: space-between;
  align-items:  center;
  height: 48px;
  padding: 0 24px;
}

.admin-body {
  overflow-y: auto;
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 32px;
}

.admin-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  flex: 1;
  padding: 20px 22px;
}

.stat-value {
  color: var(--accent);
  letter-spacing: -.02em;
  margin-bottom: 6px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 400;
}

.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  margin-bottom: 12px;
}

.admin-section-header h2 {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.admin-table {
  border-collapse: collapse;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-2);
  width: 100%;
  font-size: 13px;
}

.admin-table th {
  text-align: left;
  border-bottom: 1px solid var(--border);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-sub);
  background: var(--bg3);
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
}

.admin-table td {
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover td {
  background: var(--bg3);
}

.badge {
  display: inline-block;
  letter-spacing: .02em;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active {
  background: var(--green-bg);
  color: var(--green);
}

.badge-inactive {
  background: var(--bg4);
  color: var(--text-dim);
}

.modal-backdrop {
  position: fixed;
  display: flex;
  z-index: 100;
  background: #0006;
  justify-content: center;
  align-items:  center;
  inset: 0;
}

.modal-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-8);
  width: 460px;
  padding: 24px 24px 20px;
}

.modal-header {
  display: flex;
  color: var(--text);
  justify-content: space-between;
  align-items:  center;
  margin-bottom: 18px;
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  color: var(--text-dim);
  cursor: pointer;
  border-radius: var(--radius);
  background: none;
  border: none;
  padding: 0 4px;
  font-size: 18px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--bg3);
  color: var(--text);
}
