/*
 * 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.
 */

:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #1d1d1b;
  --muted: #6f6f68;
  --line: #deded6;
  --accent: #146c5f;
  --accent-ink: #ffffff;
  --commit: #1f6feb;
  --danger: #9f2f2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 64px;
  padding: 10px 24px;
}

.brand {
  font-weight: 800;
  line-height: 1.1;
}

.topbar__identity {
  align-self: center;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.brand-subnav {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  padding-left: 0;
  transition: color 140ms ease;
}

.brand-subnav:hover,
.brand-subnav:focus-visible {
  color: var(--accent);
}

.topbar__right {
  align-self: center;
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  justify-content: end;
}

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

.topbar__actions:not(:has(> :not([hidden]))) {
  display: none;
}

.topbar__account {
  align-content: center;
  align-items: start;
  border-left: 1px solid var(--line);
  display: grid;
  gap: 5px;
  line-height: 1;
  min-width: 92px;
  padding-left: 16px;
}

.topbar__greeting {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}

.topbar nav {
  align-items: center;
  display: flex;
  gap: 4px;
}

.topbar nav a {
  align-items: center;
  border-radius: 5px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 650;
  line-height: 1;
  min-height: 32px;
  padding: 0 9px;
  transition: background 140ms ease, color 140ms ease;
}

.topbar nav a:hover,
.topbar nav a:focus-visible {
  background: #f0f0ea;
  color: var(--accent);
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.link-button--small {
  border-bottom: 1px solid transparent;
  font-size: 12px;
  line-height: 1;
  transition: border-color 140ms ease, color 140ms ease;
}

.topbar__signout {
  line-height: 1;
}

.link-button--small:hover {
  border-bottom-color: currentColor;
  color: var(--ink);
}

.topbar a:focus-visible,
.topbar button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

.link-button--danger {
  color: var(--danger);
}

.flash {
  background: #e8f4ef;
  border-bottom: 1px solid var(--line);
  padding: 10px 18px;
}

.flash--alert {
  background: #fae8e8;
}

.auth {
  margin: 80px auto;
  max-width: 360px;
}

.auth--wide {
  max-width: 520px;
}

.form-panel,
.settings-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.field {
  display: grid;
  gap: 6px;
  margin-block: 12px;
}

.checkbox-field {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-block: 12px;
}

.checkbox-field input {
  width: auto;
}

.checkbox-field label {
  justify-content: start;
}

label {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  font-weight: 650;
  gap: 6px;
  justify-content: space-between;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
}

.required-indicator {
  color: var(--danger);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.form-actions input,
.form-actions .button {
  width: auto;
}

.login-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-weight: 800;
  letter-spacing: 0;
}

.login-code--large {
  background: #f2f2ed;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 28px;
  margin-top: 14px;
  padding: 18px;
  text-align: center;
}

.table-actions {
  align-items: center;
  display: flex;
  white-space: nowrap;
}

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

.table-actions form {
  margin: 0;
}

.action-link {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  font-weight: 720;
  line-height: 1;
  min-height: 32px;
  padding: 7px 10px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.action-link--edit {
  background: var(--ink);
  color: var(--panel);
}

.action-link--refresh {
  background: #f2f2ed;
  border-color: var(--line);
  color: var(--muted);
}

.action-link--danger {
  color: var(--danger);
}

.action-link:hover,
.action-link:focus-visible {
  border-color: currentColor;
}

.action-link--edit:hover,
.action-link--edit:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.action-link--refresh:hover,
.action-link--refresh:focus-visible {
  background: #e8e8e1;
  color: var(--ink);
}

.action-link--danger:hover,
.action-link--danger:focus-visible {
  background: #fae8e8;
}

.button,
.button--secondary,
button,
input[type="submit"] {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: var(--accent-ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
}

.button--secondary {
  background: #e8e8e1;
  color: var(--ink);
}

form:not(.conversation-search) input[type="submit"]:not(.button--secondary) {
  background: #dcdcd4;
  color: var(--muted);
}

form:not(.conversation-search):valid input[type="submit"]:not(.button--secondary) {
  background: var(--commit);
  color: var(--accent-ink);
}

form:not(.conversation-search):has(:invalid) input[type="submit"]:not(.button--secondary) {
  background: #dcdcd4;
  color: var(--muted);
}

.inbox {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfbf8;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  overflow: hidden;
}

.sidebar__header {
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.sidebar__header-main {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
  position: relative;
}

.sidebar__header-main h2 {
  margin: 0;
}

.conversation-list {
  align-content: start;
  display: grid;
  grid-auto-rows: max-content;
  min-height: 0;
  overflow: auto;
}

.conversation-search {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  margin-bottom: 14px;
}

.conversation-search input[type="search"] {
  min-width: 0;
}

.conversation-filters {
  background: #eeeeea;
  border-radius: 6px;
  display: grid;
  gap: 2px;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.35fr) minmax(0, 1fr);
  margin-bottom: 10px;
  padding: 2px;
}

.conversation-filter {
  border-radius: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  min-width: 0;
  padding: 7px 4px;
  text-align: center;
  white-space: nowrap;
}

.conversation-filter--active {
  background: var(--panel);
  color: var(--ink);
}

.conversation-link {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding: 14px 16px;
}

.conversation-link--unread {
  background: #fffdf0;
}

.conversation-link[aria-current="page"] {
  background: #eef5f3;
}

.conversation-link strong,
.message__meta strong {
  font-weight: 760;
}

.conversation-link__header,
.conversation-link__meta {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
}

.conversation-link__header-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex: 0 0 auto;
  font-size: 13px;
  gap: 8px;
}

.conversation-link__phone {
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-link__preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-link__label {
  color: var(--ink);
  font-weight: 650;
}

.unread-dot {
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  height: 8px;
  width: 8px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.thread {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.thread__header {
  align-items: end;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 1fr) auto;
  justify-content: space-between;
  padding: 18px;
}

.thread__identity {
  display: grid;
  gap: 4px;
}

.thread__identity h1 {
  margin: 0;
}

.thread__details {
  display: grid;
  gap: 2px;
}

.back-link {
  align-items: center;
  color: var(--accent);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 4px;
  width: fit-content;
}

.back-link::before {
  content: "<";
  font-size: 12px;
  line-height: 1;
}

.notification-toggle,
.app-install {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  padding: 8px 10px;
  white-space: nowrap;
}

.notification-toggle[hidden],
.app-install[hidden] {
  display: none;
}

.notification-toggle--topbar,
.app-install--topbar {
  font-size: 13px;
  padding: 7px 10px;
}

.notification-toggle__icon,
.app-install__icon {
  fill: none;
  flex: 0 0 auto;
  height: 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 16px;
}

.messages {
  align-content: start;
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  max-width: 720px;
  padding: 10px 12px;
}

.message--outbound {
  background: #e7f2ef;
  justify-self: end;
}

.message--inbound {
  background: var(--panel);
}

.message--failed {
  border-color: var(--danger);
  background: #fae8e8;
}

.message__status {
  font-weight: 650;
}

.message--failed .message__status {
  color: var(--danger);
}

.message__error {
  border-top: 1px solid rgba(159, 47, 47, 0.24);
  color: var(--danger);
  display: grid;
  font-size: 13px;
  gap: 2px;
  padding-top: 6px;
}

.message__images {
  display: grid;
  gap: 8px;
}

.message__image-link {
  display: block;
}

.message__image {
  border-radius: 6px;
  display: block;
  height: auto;
  max-height: 420px;
  max-width: min(100%, 420px);
  object-fit: contain;
}

.composer {
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 14px 18px;
}

.composer--disabled {
  color: var(--muted);
}

.composer__row,
.form-row {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

.composer__inputs {
  display: grid;
  gap: 8px;
}

.thread__actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.contact-editor {
  position: relative;
}

.contact-editor summary {
  display: inline-block;
  list-style: none;
}

.contact-editor summary::-webkit-details-marker {
  display: none;
}

.contact-editor__form {
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 360px) minmax(132px, 180px) auto;
  padding: 12px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 2;
}

.compact-field {
  margin-block: 0;
}

.contact-editor__submit {
  width: 100%;
}

.empty {
  color: var(--muted);
  padding: 24px;
}

.empty--compact {
  padding: 10px 0 0;
}

.empty--inbox {
  align-content: center;
  display: grid;
  gap: 18px;
  justify-items: start;
}

.empty--inbox h1 {
  color: var(--ink);
  margin: 0 0 6px;
}

.empty--inbox p {
  margin: 0;
}

.new-message {
  width: min(100%, 460px);
}

.new-message--sidebar {
  flex: 0 0 auto;
  width: auto;
}

.new-message summary {
  display: inline-block;
  list-style: none;
}

.new-message summary::-webkit-details-marker {
  display: none;
}

.new-message__form {
  margin-top: 12px;
}

.sidebar .new-message__form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 14px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(320px, calc(100vw - 32px));
  z-index: 3;
}

.page {
  margin: 28px auto;
  max-width: 900px;
  padding: 0 18px;
}

.page-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-collapse: collapse;
  width: 100%;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .auth {
    margin: 28px auto;
    padding: 0 16px;
    width: 100%;
  }

  .page {
    margin: 22px auto;
    padding: 0 14px;
  }

  .page-header {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 12px;
  }

  .page-header h1 {
    line-height: 1.02;
    margin: 0;
  }

  .page-header .button {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    justify-content: center;
  }

  .employee-table {
    background: transparent;
    border: 0;
  }

  .employee-table thead {
    display: none;
  }

  .employee-table,
  .employee-table tbody,
  .employee-table tr,
  .employee-table td {
    display: block;
    width: 100%;
  }

  .employee-table tbody {
    display: grid;
    gap: 12px;
  }

  .employee-table tr {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
  }

  .employee-table td {
    align-items: start;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(88px, 0.38fr) minmax(0, 1fr);
    padding: 11px 12px;
  }

  .employee-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 760;
    line-height: 1.3;
    text-transform: uppercase;
  }

  .employee-table td:last-child {
    border-bottom: 0;
  }

  .employee-table td:not(.table-actions) {
    overflow-wrap: anywhere;
  }

  .employee-table .table-actions {
    align-items: start;
    white-space: normal;
  }

  .employee-table .table-actions__controls {
    align-items: stretch;
    display: grid;
    gap: 8px;
  }

  .employee-table .table-actions form {
    min-width: 0;
  }

  .employee-table .action-link {
    justify-content: center;
    width: 100%;
  }

  body:has(.inbox) {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  .topbar {
    flex: 0 0 auto;
    align-items: start;
    gap: 10px 14px;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: auto;
    padding: 12px 16px;
  }

  .topbar__identity {
    grid-column: 1;
    grid-row: 1;
  }

  .topbar__right {
    display: contents;
  }

  .topbar nav {
    gap: 2px;
    grid-column: 1;
    grid-row: 2;
    padding-top: 0;
  }

  .topbar nav a {
    padding: 7px 8px;
  }

  .topbar__account {
    align-self: start;
    grid-column: 2;
    grid-row: 2;
    margin-left: auto;
    min-width: 0;
    padding-left: 10px;
  }

  .topbar__actions {
    align-self: start;
    display: flex;
    gap: 6px;
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .notification-toggle--topbar,
  .app-install--topbar {
    height: 36px;
    justify-content: center;
    padding: 0;
    width: 36px;
  }

  .notification-toggle--topbar span,
  .app-install--topbar span {
    display: none;
  }

  .inbox {
    display: block;
    flex: 1 1 auto;
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .inbox:has(.thread) {
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .inbox:has(.thread) .sidebar {
    display: none;
  }

  .sidebar {
    border-right: 0;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
  }

  .sidebar__header {
    padding: 14px;
  }

  .sidebar .new-message__form {
    padding: 12px;
  }

  .sidebar .new-message__form textarea {
    min-height: 72px;
  }

  .sidebar__header-main {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
  }

  .sidebar .notification-toggle {
    justify-self: start;
    max-width: 100%;
    white-space: normal;
  }

  .conversation-search {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .conversation-search input[type="submit"] {
    width: auto;
  }

  .conversation-link {
    padding: 13px 14px;
  }

  .conversation-link__header {
    align-items: start;
  }

  .conversation-link__header strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .thread {
    height: 100%;
  }

  .thread__header,
  .contact-editor__form {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .thread__header {
    gap: 12px;
    padding: 14px;
  }

  .thread__identity h1 {
    font-size: 32px;
    line-height: 1.05;
    overflow-wrap: anywhere;
  }

  .thread__actions {
    justify-content: stretch;
  }

  .thread__actions > form,
  .thread__actions > .contact-editor {
    flex: 1 1 0;
  }

  .thread__actions .button--secondary,
  .thread__actions button,
  .thread__actions input[type="submit"],
  .contact-editor summary {
    text-align: center;
    width: 100%;
  }

  .contact-editor__form {
    margin-top: 8px;
    position: static;
  }

  .messages {
    gap: 8px;
    padding: 14px;
  }

  .message {
    max-width: min(92%, 720px);
    overflow-wrap: anywhere;
  }

  .message__meta {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .composer {
    padding: 12px 14px;
  }

  .composer__row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .composer input[type="submit"] {
    width: 100%;
  }
}
