/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

.hidden { display: none; }

/* Variables */

:root {
  --bg:              #f0f0f0;
  --surface:         #ffffff;
  --surface-alt:     #f0f0f0;
  --text:            #333333;
  --text-secondary:  #555555;
  --text-muted:      #808080;
  --text-disabled:   #a0a0a0;
  --border:          #dddddd;
  --border-alt:      #eeeeee;
  --border-focus:    #DC3545;
  --primary:         #DC3545;
  --primary-hover:   #c82333;
  --primary-text:    #ffffff;
  --nav-bg:          #1e1e1e;
  --nav-text:        #ffffff;
  --error-bg:        #fff0f0;
  --error-text:      #cc0000;
}

html.dark {
  --bg:              #1a1a1a;
  --surface:         #242424;
  --surface-alt:     #2e2e2e;
  --text:            #f0f0f0;
  --text-secondary:  #cccccc;
  --text-muted:      #888888;
  --text-disabled:   #555555;
  --border:          #3a3a3a;
  --border-alt:      #2e2e2e;
  --border-focus:    #DC3545;
  --primary:         #DC3545;
  --primary-hover:   #c82333;
  --primary-text:    #ffffff;
  --nav-bg:          #111111;
  --nav-text:        #ffffff;
  --error-bg:        #2d1515;
  --error-text:      #ff6b6b;
}

/* Base */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Header */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--nav-bg);
}

.header__logo {
  height: 40px;
  width: auto;
  object-fit: contain;
  mix-blend-mode: screen;
}


/* Profile */

.header__profile {
  position: relative;
}

.header__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.header__avatar:hover {
  opacity: 0.85;
}

.header__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 220px;
  padding: 6px;
  z-index: 100;
}

.header__dropdown.hidden {
  display: none;
}

.header__dropdown-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 6px 10px 4px;
}

.header__dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.header__dropdown-item:hover {
  background: var(--surface-alt);
}

.header__dropdown-label {
  font-size: 14px;
  color: var(--text);
}

.header__dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.header__dropdown-link {
  color: var(--text);
}

.header__dropdown-signout {
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--error-text);
  text-align: left;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}

.header__dropdown-signout:hover {
  background: var(--surface-alt);
}

/* Toggle switch */

.toggle {
  position: relative;
  display: flex;
  align-items: center;
}

.toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  cursor: pointer;
}

.toggle__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle__input:checked + .toggle__track {
  background: var(--primary);
}

.toggle__input:checked + .toggle__track::after {
  transform: translateX(16px);
}

/* Auth */

.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth__card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 40px;
}

.auth__logo {
  display: block;
  width: 180px;
  height: auto;
  object-fit: contain;
  margin: 0 auto 24px;
}

.auth__title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.auth__subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.auth__form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.auth__input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}

.auth__input:focus {
  border-color: var(--border-focus);
}

.auth__remember {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth__checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.auth__remember-label {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.auth__submit {
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}

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

.auth__links {
  margin-top: 20px;
  text-align: center;
}

.auth__link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}

.auth__link:hover {
  color: var(--text);
}

/* Page title */

.page-title {
  font-size: 30px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  text-align: center;
}

.page-title__sub {
  font-size: 20px;
  font-weight: 400;
  color: var(--text-muted);
}

/* Chat */

.chat {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  height: 80vh;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.bot-avatar {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: contain;
  background: #ffffff;
  padding: 1px;
  margin-bottom: 2px;
}

.message {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.message--user {
  align-self: flex-end;
  background: #3a3a3a;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

html.dark .message--user {
  background: #808080;
  color: #ffffff;
}

html.dark .message--assistant {
  background: #333333;
  color: #f0f0f0;
}

.message--assistant {
  align-self: flex-start;
  background: var(--surface-alt);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.message--typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}

.message--typing span {
  display: block;
  width: 8px;
  height: 8px;
  background: var(--text-disabled);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}

.message--typing span:nth-child(1) { animation-delay: 0s; }
.message--typing span:nth-child(2) { animation-delay: 0.2s; }
.message--typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.message--markdown {
  max-width: calc(100% - 48px);
}

.table-scroll {
  overflow-x: auto;
  width: 100%;
}

.message--markdown p {
  margin-bottom: 8px;
}

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

.message--markdown table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 14px;
}

.message--markdown th,
.message--markdown td {
  border: 1px solid var(--border);
  padding: 6px 12px;
  text-align: left;
  white-space: nowrap;
}

.message--markdown th {
  background: var(--surface-alt);
  font-weight: 600;
}

.message--markdown tr:nth-child(even) td {
  background: var(--bg);
}

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

.message--markdown li {
  margin-bottom: 4px;
}

.message--markdown code {
  background: var(--surface-alt);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
}

.message--markdown pre {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}

.message--markdown pre code {
  background: none;
  padding: 0;
  font-size: 13px;
}

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

.message--error {
  align-self: center;
  background: var(--error-bg);
  color: var(--error-text);
  font-size: 13px;
  border-radius: 8px;
}

.chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border-alt);
  background: var(--surface);
}

.chat__input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  max-height: 160px;
  overflow-y: auto;
  line-height: 1.5;
}

.chat__input:focus {
  border-color: var(--border-focus);
}

.chat__button {
  flex-shrink: 0;
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.chat__button:hover:not(:disabled) {
  background: var(--primary-hover);
}

.chat__button:disabled {
  background: var(--text-disabled);
  cursor: not-allowed;
}

.chat__disclaimer,
.chat__session {
  font-size: 0.75rem;
  color: var(--text-muted, #888);
  text-align: center;
  margin: 4px 16px 0;
  padding-bottom: 16px;
}
