/*
 * Application-wide styles (Propshaft). Tailwind utilities live in builds/tailwind.css.
 *
 * Layout rule for new pages:
 *   Wrap page content in <div class="lm-page"> (full width).
 *   Use <div class="lm-page lm-page--form"> only for short forms.
 *   Do NOT add max-w-xl / max-w-2xl / max-w-3xl on page roots.
 */

:root {
  --lm-ink: #14231c;
  --lm-forest: #0f3d2e;
  --lm-moss: #1f6b4a;
  --lm-sand: #eef4ef;
  --lm-glow: #d8ebe0;
  --lm-page-pad-x: 0.75rem;
  --lm-page-pad-y: 0.75rem;
  --lm-bottom-nav-h: 3.75rem;
}

@media (min-width: 640px) {
  :root {
    --lm-page-pad-x: 1.25rem;
    --lm-page-pad-y: 1rem;
  }
}

@media (min-width: 1024px) {
  :root {
    --lm-page-pad-x: 1.5rem;
    --lm-page-pad-y: 1.25rem;
  }
}

.lm-body {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  color: var(--lm-ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--lm-glow), transparent 55%),
    radial-gradient(900px 420px at 90% 0%, #f4f7f2, transparent 50%),
    linear-gradient(180deg, #f7faf8 0%, #eef3f0 100%);
}

.font-display,
.lm-topbar .font-display {
  font-family: "DM Sans", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
}

.lm-shell a {
  text-decoration: none;
}

.lm-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.lm-shell-main {
  width: 100%;
  flex: 1;
  padding: var(--lm-page-pad-y) var(--lm-page-pad-x);
  padding-bottom: calc(var(--lm-page-pad-y) + var(--lm-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .lm-shell-main {
    padding-bottom: var(--lm-page-pad-y);
  }
}

/* Full-bleed page canvas — use on every authenticated page root */
.lm-page {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .lm-page {
    gap: 1.25rem;
  }
}

/* Optional slightly narrower column for login-like forms inside the app */
.lm-page--form {
  max-width: 42rem;
}

.lm-page--split {
  display: grid;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .lm-page--split {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    align-items: start;
    gap: 1.25rem;
  }
}

.lm-dense-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .lm-dense-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .lm-dense-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }
}

@media (min-width: 1280px) {
  .lm-dense-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.lm-panel {
  border: 1px solid rgba(15, 61, 46, 0.12);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
}

@media (min-width: 768px) {
  .lm-panel {
    padding: 1rem 1.15rem;
  }
}

/* Sticky mobile tab bar — live-app feel */
.lm-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.15rem;
  height: calc(var(--lm-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  background: rgba(15, 61, 46, 0.97);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

@media (min-width: 768px) {
  .lm-bottom-nav {
    display: none;
  }
}

.lm-bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border-radius: 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(220, 240, 230, 0.72);
  padding: 0.25rem;
}

.lm-bottom-nav a:hover,
.lm-bottom-nav a.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.lm-bottom-nav .lm-nav-ico {
  font-size: 1rem;
  line-height: 1;
}

/* Guest / login */
.lm-login {
  width: 100%;
  max-width: 22rem;
  margin: 0 auto;
  text-align: center;
}

.lm-login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.lm-login-logo {
  width: 7.5rem;
  height: 7.5rem;
  border-radius: 50%;
  object-fit: cover;
  box-shadow:
    0 0 0 3px #0b0b0b,
    0 12px 28px rgba(15, 61, 46, 0.22);
}

.lm-login h1 {
  font-family: "DM Sans", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--lm-ink);
  margin: 0;
}

.lm-login-lead {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: #5b6b62;
}

.lm-login-form {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.9rem;
  text-align: left;
}

.lm-login-form input[type="email"],
.lm-login-form input[type="password"],
.lm-login-form input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid #c9d5ce;
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 35, 28, 0.04);
  font: inherit;
  color: var(--lm-ink);
}

.lm-login-form input:focus {
  outline: 2px solid var(--lm-moss);
  outline-offset: 1px;
  border-color: var(--lm-moss);
}

.lm-login-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
  margin-top: 0.15rem;
}

.lm-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 0;
  border-radius: 0.5rem;
  padding: 0.7rem 1.25rem;
  font: inherit;
  font-weight: 600;
  color: #fff !important;
  background: var(--lm-forest);
  box-shadow: 0 2px 8px rgba(15, 61, 46, 0.28);
}

.lm-btn-primary:hover {
  background: var(--lm-moss);
}

.lm-login-actions a {
  font-size: 0.875rem;
  color: #4a5c53;
  text-decoration: underline;
}

.lm-login-flash {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.lm-login-flash-alert {
  background: #fef2f2;
  color: #dc2626;
}

.lm-login-flash-notice {
  background: #ecfdf5;
  color: #059669;
}

/* —— WhatsApp inbox (live chat workspace) —— */
/* Lock the shell so only list/thread/side scroll — never a double page scrollbar */
body:has(.wa-inbox-page) {
  overflow: hidden;
  height: 100dvh;
}

.lm-shell:has(.wa-inbox-page) {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.lm-shell:has(.wa-inbox-page) .lm-breadcrumb {
  display: none;
}

.lm-shell:has(.wa-inbox-page) .lm-shell-main {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.lm-shell:has(.wa-inbox-page) #flash:empty {
  display: none;
}

@media (max-width: 767px) {
  .lm-shell:has(.wa-inbox-page) {
    padding-bottom: calc(var(--lm-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  }
}

.wa-inbox-page {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #12161a;
  color: #e8eee9;
}

.wa-inbox-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #0e1316;
}

.wa-inbox-toolbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.wa-live-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: #9db5a8;
}

.wa-live-dot::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.wa-live-dot.is-off::before {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.wa-live-dot.is-err::before {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

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

@media (min-width: 768px) {
  .wa-inbox-body {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }
}

@media (min-width: 1200px) {
  .wa-inbox-body {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(240px, 300px);
  }
}

.wa-inbox-list {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: #161b20;
}

.wa-inbox-search {
  padding: 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.wa-inbox-search input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0f1418;
  color: #e8eee9;
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
}

.wa-inbox-search input::placeholder {
  color: #6b7f74;
}

.wa-conv-scroll {
  flex: 1;
  overflow-y: auto;
}

.wa-conv-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: start;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: inherit;
  text-decoration: none;
}

.wa-conv-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.wa-conv-item.is-active {
  background: rgba(31, 107, 74, 0.28);
}

.wa-avatar {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  background: #1f6b4a;
  color: #ecfdf5;
}

.wa-avatar.is-amber {
  background: #b45309;
}

.wa-conv-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #f3f7f4;
}

.wa-conv-preview {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: #8fa398;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 11rem;
}

.wa-conv-meta {
  text-align: right;
  font-size: 0.65rem;
  color: #6b7f74;
}

.wa-thread {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0f1316;
}

.wa-thread-empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: #6b7f74;
  padding: 2rem;
}

.wa-thread-empty strong {
  display: block;
  margin-top: 0.75rem;
  color: #c5d5cb;
  font-size: 1.05rem;
}

.wa-thread-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #141a1e;
}

.wa-thread-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.wa-bubble {
  max-width: min(85%, 32rem);
  border-radius: 0.85rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.wa-bubble.is-in {
  align-self: flex-start;
  background: #1c2429;
  color: #e8eee9;
}

.wa-bubble.is-out {
  align-self: flex-end;
  background: #1f6b4a;
  color: #ecfdf5;
}

.wa-bubble-meta {
  font-size: 0.65rem;
  opacity: 0.65;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
}

.wa-compose {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #141a1e;
}

.wa-compose input[type="text"] {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0f1418;
  color: #e8eee9;
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.875rem;
}

.wa-side {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background: #161b20;
  padding: 0.85rem;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

@media (min-width: 1200px) {
  .wa-side {
    display: block;
  }
}

.wa-side h2 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8fa398;
}

.wa-side-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.65rem;
  padding: 0.75rem;
  background: #12171b;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}

.wa-side-card label {
  display: block;
  font-size: 0.7rem;
  color: #8fa398;
  margin-bottom: 0.25rem;
}

.wa-side-card input,
.wa-side-card select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0f1418;
  color: #e8eee9;
  border-radius: 0.4rem;
  padding: 0.45rem 0.55rem;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.wa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.45rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 0;
  text-decoration: none;
}

.wa-btn-primary {
  background: #1f6b4a;
  color: #ecfdf5;
}

.wa-btn-primary:hover {
  background: #258356;
}

.wa-btn-ghost {
  background: transparent;
  color: #c5d5cb;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.wa-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
}

.wa-btn-danger {
  background: transparent;
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

@media (max-width: 767px) {
  .wa-inbox-page.is-thread-open .wa-inbox-list {
    display: none;
  }

  .wa-inbox-page:not(.is-thread-open) .wa-thread {
    display: none;
  }
}
