/*
  Seam Signal UI simplicity layer.

  This file is loaded after page-level styles so older templates can keep working
  while new screens opt into the explicit action/disclosure/tab utilities below.
*/

:where(body.portal-signed-in, body.portal-auth){
  --action-secondary-bg:var(--surface-container-lowest);
  --action-secondary-fg:var(--foreground);
  --action-secondary-border:var(--outline-variant);
  --action-quiet-fg:var(--secondary);
  --action-focus-ring:0 0 0 3px color-mix(in srgb,var(--primary) 24%,transparent);
}

:where(.btn,.action,.action-primary,.action-secondary,.action-quiet,.action-destructive,.action-btn,.qlk-btn){
  max-width:100%;
  min-width:0;
  min-height:40px;
  white-space:normal;
  overflow-wrap:anywhere;
  text-align:center;
  text-transform:none;
  letter-spacing:0;
}

/* Plain .btn is now the normal secondary action. Orange is reserved for explicit primary CTAs. */
:where(.btn):not(.primary):not(.destructive):not(.danger){
  background:var(--action-secondary-bg);
  color:var(--action-secondary-fg);
  border:1px solid var(--action-secondary-border);
  box-shadow:none;
}

.btn.primary,.action-primary,.action.primary,.action-btn.primary,a.cta,button.cta,
.login .btn:not(.ghost):not(.secondary):not(.quiet):not(.destructive),
.right-now .btn:not(.ghost):not(.secondary):not(.quiet):not(.destructive){
  background:var(--primary);
  color:var(--primary-foreground);
  border:1px solid var(--primary);
  box-shadow:var(--shadow-btn);
}

.btn.secondary,.btn.ghost,.action-secondary,.action.secondary,.action-btn.ghost,.qlk-btn{
  background:var(--action-secondary-bg);
  color:var(--action-secondary-fg);
  border:1px solid var(--action-secondary-border);
  box-shadow:none;
}

.btn.quiet,.action-quiet,.action.quiet,.quiet-action,.link-quiet{
  background:transparent;
  color:var(--action-quiet-fg);
  border:1px solid transparent;
  box-shadow:none;
  padding-inline:8px;
}

.btn.destructive,.btn.danger,.action-destructive,.action.destructive,.action-btn.destructive{
  background:var(--destructive);
  color:#fff;
  border:1px solid var(--destructive);
  box-shadow:var(--shadow-btn);
}

:where(.btn:hover,.action:hover,.action-primary:hover,.action-secondary:hover,.action-quiet:hover,.action-destructive:hover,.action-btn:hover,.qlk-btn:hover){
  text-decoration:none;
}

:where(.btn:focus-visible,.action:focus-visible,.action-primary:focus-visible,.action-secondary:focus-visible,.action-quiet:focus-visible,.action-destructive:focus-visible,.action-btn:focus-visible,.qlk-btn:focus-visible,details>summary:focus-visible){
  outline:2px solid var(--primary);
  outline-offset:2px;
  box-shadow:var(--action-focus-ring);
}

:where(.action-row,.action-cluster,.button-row,.panel-controls,.work-actions,.client-actions,.task-actions,.status-line){
  min-width:0;
}

:where(.action-row,.action-cluster,.button-row){
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}

:where(.action-stack){
  min-width:0;
}

.action-stack .action-btn:not(.primary):not(.destructive){
  background:var(--surface-container-lowest);
  color:var(--foreground);
  border-color:var(--outline-variant);
  box-shadow:none;
}

/* Active chips and repeated tabs should show selection without reading as the next main action. */
.view-chip.active,.quick-chip.active,.queue-tabs .btn.active,.lead-tabs a[aria-current="page"]{
  background:var(--primary-container);
  color:var(--on-primary-container);
  border-color:color-mix(in srgb,var(--primary) 34%,var(--outline-variant));
  box-shadow:none;
}

.view-chip.active .count,.quick-chip.active .count{
  color:var(--on-primary-container);
}

:where(.ui-disclosure,.disclosure,details.mobile-disclosure){
  border:1px solid var(--outline-variant);
  border-radius:8px;
  background:var(--surface-container-lowest);
}

:where(.ui-disclosure>summary,.disclosure>summary,details.mobile-disclosure>summary,.filter-drawer>summary,.lead-filter-drawer>summary,.row-tools>summary,.tools-menu>summary){
  display:flex;
  align-items:center;
  gap:8px;
  min-height:40px;
  cursor:pointer;
  color:var(--foreground);
  font-weight:850;
  overflow-wrap:anywhere;
}

:where(.ui-disclosure>summary,.disclosure>summary,details.mobile-disclosure>summary){
  padding:8px 10px;
}

:where(.ui-disclosure>summary::-webkit-details-marker,.disclosure>summary::-webkit-details-marker,details.mobile-disclosure>summary::-webkit-details-marker){
  display:none;
}

:where(.ui-disclosure>summary::after,.disclosure>summary::after,details.mobile-disclosure>summary::after){
  content:"";
  width:8px;
  height:8px;
  margin-left:auto;
  border-right:2px solid currentColor;
  border-bottom:2px solid currentColor;
  transform:rotate(45deg);
  opacity:.7;
}

:where(.ui-disclosure[open]>summary::after,.disclosure[open]>summary::after,details.mobile-disclosure[open]>summary::after){
  transform:rotate(225deg);
}

:where(.ui-disclosure-body,.disclosure-body){
  padding:0 10px 10px;
}

:where(.tab-list,.ui-tabs,[role="tablist"]){
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  min-width:0;
  border-bottom:1px solid var(--outline-variant);
}

:where(.tab,.ui-tab,[role="tablist"] a,[role="tab"]){
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:40px;
  padding:8px 10px;
  border:1px solid transparent;
  border-bottom:0;
  border-radius:8px 8px 0 0;
  color:var(--muted-foreground);
  text-decoration:none;
  font-weight:850;
  overflow-wrap:anywhere;
}

:where(.tab[aria-current="page"],.ui-tab[aria-current="page"],[role="tab"][aria-selected="true"],[role="tablist"] a[aria-current="page"]){
  background:var(--surface-container-lowest);
  color:var(--foreground);
  border-color:var(--outline-variant);
}

:where(.mobile-scroll-row,.mobile-chip-row){
  display:flex;
  gap:8px;
  max-width:100%;
  overflow-x:auto;
  overscroll-behavior-inline:contain;
  scrollbar-width:none;
}

:where(.mobile-scroll-row::-webkit-scrollbar,.mobile-chip-row::-webkit-scrollbar){
  display:none;
}

:where(.wrap-anywhere,.text-wrap,.panel,.work-card,.lead-card,.kpi,.pill,.badge,td,th){
  min-width:0;
  overflow-wrap:anywhere;
}

:where(.empty-state){
  border:1px dashed var(--outline-variant);
  border-radius:8px;
  background:var(--surface-container-lowest);
  color:var(--muted-foreground);
  padding:18px;
}

/* Shared guided wizard patterns. */
:where(.guided-wizard){
  max-width:min(920px,100%);
  margin:clamp(12px,3vw,28px) auto;
  display:grid;
  gap:14px;
}

:where(.guided-wizard-header){
  display:grid;
  gap:6px;
}

:where(.guided-step-meta){
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
  justify-content:space-between;
  color:var(--muted-foreground);
  font-size:13px;
}

:where(.guided-step-count,.guided-save-note){
  display:inline-flex;
  align-items:center;
  min-height:28px;
}

:where(.guided-step-count){
  color:var(--foreground);
  font-weight:850;
}

:where(.guided-save-note){
  color:var(--muted-foreground);
}

:where(.guided-wizard .wizard-progress,.guided-wizard .wizard-steps,.guided-wizard .help-steps,.guided-wizard .realtor-steps,.guided-wizard .timeline-steps){
  gap:8px;
}

:where(.guided-wizard .wizard-dot,.guided-wizard .wizard-step,.guided-wizard .help-step,.guided-wizard .realtor-step,.guided-wizard .timeline-step){
  min-height:44px;
  border-radius:8px;
  box-shadow:none;
}

:where(.guided-wizard .wizard-dot.done,.guided-wizard .wizard-step.done,.guided-wizard .help-step.done,.guided-wizard .realtor-step.done,.guided-wizard .timeline-step.done){
  background:var(--primary-container);
  color:var(--on-primary-container);
  border-color:color-mix(in srgb,var(--primary) 24%,var(--outline-variant));
}

:where(.guided-wizard .wizard-dot.on,.guided-wizard .wizard-step.on,.guided-wizard .help-step.on,.guided-wizard .realtor-step.on,.guided-wizard .timeline-step.on){
  background:var(--primary);
  color:var(--primary-foreground);
  border-color:var(--primary);
}

:where(.guided-step-panel){
  display:grid;
  gap:14px;
  box-shadow:var(--shadow-soft);
}

.guided-step-panel{
  background:#fff;
}

:where(.guided-step-heading){
  display:grid;
  gap:4px;
}

:where(.guided-step-heading h2){
  margin:0;
}

:where(.guided-instruction){
  margin:0;
  color:var(--muted-foreground);
  font-size:14px;
  line-height:1.45;
}

:where(.guided-feedback){
  min-height:36px;
  display:flex;
  align-items:center;
  border:1px solid var(--outline-variant);
  border-radius:8px;
  background:#fff;
  color:var(--muted-foreground);
  padding:8px 10px;
  font-size:13px;
}

:where(.guided-wizard .option-grid,.guided-wizard .choice-grid){
  gap:10px;
}

:where(.guided-wizard .option-card,.guided-wizard .match-card,.guided-wizard .choice){
  position:relative;
  min-height:72px;
  border-radius:8px;
  transition:border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.guided-wizard .option-card,
.guided-wizard .match-card,
.guided-wizard .choice{
  background:#fff;
}

.guided-wizard .btn{
  text-transform:none!important;
  letter-spacing:0!important;
}

:where(.guided-wizard .option-card,.guided-wizard .match-card){
  padding:14px;
}

:where(.guided-wizard .option-card:focus-within,.guided-wizard .match-card:focus-within,.guided-wizard .choice:focus-within){
  outline:2px solid var(--primary);
  outline-offset:2px;
}

:where(.guided-wizard .option-card:has(input:checked),.guided-wizard .match-card:has(input:checked),.guided-wizard .choice:has(input:checked)){
  border-color:var(--primary);
  background:color-mix(in srgb,var(--primary-container) 28%,var(--surface-container-lowest));
  box-shadow:0 0 0 2px color-mix(in srgb,var(--primary) 18%,transparent);
}

:where(.guided-wizard .option-card strong,.guided-wizard .match-card strong){
  font-size:15px;
}

:where(.guided-wizard .wizard-fields,.guided-wizard .wizard-grid,.guided-wizard .help-grid,.guided-wizard .realtor-grid,.guided-wizard .timeline-grid){
  gap:12px;
}

:where(.guided-wizard .f){
  min-width:0;
}

:where(.guided-wizard input,.guided-wizard select,.guided-wizard textarea){
  max-width:100%;
}

:where(.guided-wizard .review-list div){
  min-width:0;
}

:where(.guided-actions,.guided-wizard .wizard-actions,.guided-wizard .help-actions,.guided-wizard .realtor-actions,.guided-wizard .timeline-actions){
  gap:10px;
  margin-top:4px;
}

:where([data-path-panel][hidden]){
  display:none!important;
}

@media (max-width:860px){
  .btn,.btn.sm,.action,.action-primary,.action-secondary,.action-quiet,.action-destructive,
  .action-btn,.qlk-btn,.view-chip,.quick-chip,.lead-tabs a,.mobile-tabbar a,
  .topnav .nav-link,.topnav .topgrp>summary,.topnav .signout,details>summary{
    min-height:44px;
  }

  .btn,.action,.action-primary,.action-secondary,.action-quiet,.action-destructive,.action-btn,.qlk-btn{
    width:100%;
  }

  :where(.action-row,.action-cluster,.button-row,.task-actions,.status-line){
    display:grid;
    grid-template-columns:1fr;
    align-items:stretch;
  }

  :where(.saved-views,.quick-chips,.queue-tabs,.lead-tabs,.mobile-scroll-row,.mobile-chip-row){
    flex-wrap:nowrap;
    overflow-x:auto;
    padding-bottom:4px;
    scroll-snap-type:x proximity;
  }

  :where(.saved-views>a,.quick-chips>a,.queue-tabs>a,.lead-tabs>a,.mobile-scroll-row>*,.mobile-chip-row>*){
    flex:0 0 auto;
    max-width:min(82vw,320px);
    scroll-snap-align:start;
    white-space:normal;
  }

  :where(.mobile-stack){
    display:grid!important;
    grid-template-columns:1fr!important;
  }

  :where(.mobile-full){
    width:100%;
  }

  :where(.mobile-tabbar){
    grid-auto-columns:minmax(64px,1fr);
  }

  :where(.guided-wizard){
    gap:12px;
    margin:10px auto;
  }

  :where(.guided-step-panel){
    gap:12px;
  }

  :where(.guided-wizard .wizard-progress,.guided-wizard .wizard-steps,.guided-wizard .help-steps,.guided-wizard .realtor-steps,.guided-wizard .timeline-steps){
    display:flex;
    overflow-x:auto;
    margin-inline:-16px;
    padding:0 16px 4px;
    scroll-snap-type:x proximity;
    scrollbar-width:none;
  }

  :where(.guided-wizard .wizard-progress::-webkit-scrollbar,.guided-wizard .wizard-steps::-webkit-scrollbar,.guided-wizard .help-steps::-webkit-scrollbar,.guided-wizard .realtor-steps::-webkit-scrollbar,.guided-wizard .timeline-steps::-webkit-scrollbar){
    display:none;
  }

  :where(.guided-wizard .wizard-dot,.guided-wizard .wizard-step,.guided-wizard .help-step,.guided-wizard .realtor-step,.guided-wizard .timeline-step){
    flex:0 0 min(58vw,156px);
    scroll-snap-align:start;
  }

  :where(.guided-wizard .wizard-fields,.guided-wizard .wizard-grid,.guided-wizard .help-grid,.guided-wizard .realtor-grid,.guided-wizard .timeline-grid,.guided-wizard .option-grid,.guided-wizard .choice-grid,.guided-wizard .review-list){
    grid-template-columns:1fr!important;
  }

  :where(.guided-wizard .wizard-fields .wide,.guided-wizard .wizard-grid .wide,.guided-wizard .help-grid .wide,.guided-wizard .realtor-grid .wide,.guided-wizard .timeline-grid .wide){
    grid-column:auto!important;
  }

  :where(.guided-actions,.guided-wizard .wizard-actions,.guided-wizard .help-actions,.guided-wizard .realtor-actions,.guided-wizard .timeline-actions){
    position:sticky;
    bottom:calc(64px + env(safe-area-inset-bottom));
    z-index:10;
    display:grid;
    grid-template-columns:1fr;
    align-items:stretch;
    background:var(--surface-container-lowest);
    border:1px solid var(--outline-variant);
    border-radius:8px;
    padding:8px;
    box-shadow:var(--shadow-float);
  }

  :where(.guided-actions>div,.guided-wizard .wizard-actions>div,.guided-wizard .help-actions>div,.guided-wizard .realtor-actions>div,.guided-wizard .timeline-actions>div){
    display:grid;
    gap:8px;
  }
}

.legal-document,
.legal-document :where(section, ul, li, p) {
  min-width: 0;
  max-width: 100%;
}

.legal-document a {
  display: inline-block;
  min-width: 44px;
  min-height: 44px;
  max-width: 100%;
  padding: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (prefers-reduced-motion:reduce){
  :where(.btn,a.cta,button.cta,.card){
    transition:none!important;
  }

  :where(.btn:hover,a.cta:hover,button.cta:hover,.card:hover){
    transform:none!important;
  }
}
