/* Morpheus PD Central V134.35 — injected/legacy component edge fixes */

/* Profile picture card is injected after the linked stylesheets, so use explicit important theme states. */
html[data-theme="light"] .mpd-avatar-card{
  border-color:rgba(37,99,235,.20)!important;
  background:linear-gradient(145deg,#ffffff,#f2f6fb)!important;
  color:#111827!important;
  box-shadow:0 16px 38px rgba(15,23,42,.10)!important;
}
html[data-theme="light"] .mpd-avatar-card :where(h3,p,small){-webkit-text-fill-color:currentColor!important;}
html[data-theme="light"] .mpd-avatar-card h3{color:#111827!important;}
html[data-theme="light"] .mpd-avatar-card p,
html[data-theme="light"] .mpd-avatar-card small{color:#5f6f84!important;}
html[data-theme="light"] .mpd-avatar-actions label:not(.primary),
html[data-theme="light"] .mpd-avatar-actions button{
  border-color:#d3deea!important;
  background:#ffffff!important;
  color:#172033!important;
  -webkit-text-fill-color:#172033!important;
}
html[data-theme="dark"] .mpd-avatar-card{
  border-color:rgba(96,165,250,.24)!important;
  background:linear-gradient(145deg,#0d1928,#13243a)!important;
  color:#f4f7fb!important;
}
html[data-theme="dark"] .mpd-avatar-actions label:not(.primary),
html[data-theme="dark"] .mpd-avatar-actions button{
  border-color:#2d4562!important;
  background:#14243a!important;
  color:#eef6ff!important;
  -webkit-text-fill-color:#eef6ff!important;
}

/* Investment secondary popups. */
.mpd-investment-modal-front{max-width:calc(100vw - 20px)!important;max-height:calc(100dvh - 20px)!important;}
html[data-theme="dark"] .mpd-investment-modal-front :where(.modal-content,.modal-dialog,.command-window,.command-modal,.modal-card){
  border-color:var(--line,var(--mpd-ui-line))!important;
  background:var(--card,var(--mpd-ui-surface))!important;
  color:var(--text,var(--mpd-ui-text))!important;
}

/* Legacy menu and bottom-sheet surfaces. */
#app :where(.more-menu,.more-menu-panel,.mobile-more-menu,.mobile-menu-sheet,.bottom-sheet,.mobile-sheet,.context-menu,.dropdown-panel,.floating-menu){
  max-width:calc(100vw - 16px)!important;
  max-height:calc(100dvh - 96px)!important;
  overflow:auto!important;
  overscroll-behavior:contain;
  border-color:var(--line,var(--mpd-ui-line))!important;
  background:var(--card,var(--mpd-ui-surface))!important;
  color:var(--text,var(--mpd-ui-text))!important;
  box-shadow:var(--mpd-ui-shadow)!important;
}
#app :where(.more-menu,.more-menu-panel,.mobile-more-menu,.mobile-menu-sheet,.bottom-sheet,.mobile-sheet,.context-menu,.dropdown-panel,.floating-menu) :where(button,a){
  color:var(--text,var(--mpd-ui-text));
  -webkit-text-fill-color:currentColor;
}

/* Gallery, product, user and asset collections scale without forcing fixed card widths. */
#app :where(.gallery-grid,.media-grid,.file-grid,.product-grid,.packaging-grid,.asset-grid,.company-grid,.project-grid,.user-grid,.card-grid){
  grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));
  min-width:0;
}
#app :where(.gallery-card,.media-card,.file-card,.product-card,.packaging-card,.asset-card,.company-card,.project-card,.user-card){
  min-width:0;
  max-width:100%;
  overflow:hidden;
}
#app :where(.gallery-card,.media-card,.file-card,.product-card,.packaging-card,.asset-card) :where(img,video){
  width:100%;
  max-width:100%;
  object-fit:cover;
}

/* Old info/filter blocks that otherwise stay bright white in dark mode. */
html[data-theme="dark"] #app :where(.empty-state,.empty-card,.info-box,.notice-box,.summary-box,.filter-bar,.search-bar,.filter-panel,.quick-panel,.meta-panel){
  border-color:var(--line,var(--mpd-ui-line))!important;
  background:var(--panel,var(--mpd-ui-panel))!important;
  color:var(--text,var(--mpd-ui-text))!important;
}
html[data-theme="light"] #app :where(.empty-state,.empty-card,.info-box,.notice-box,.summary-box,.filter-bar,.search-bar,.filter-panel,.quick-panel,.meta-panel){
  border-color:var(--line,var(--mpd-ui-line))!important;
  color:var(--text,var(--mpd-ui-text))!important;
}

/* Likes tooltip and history rows must stay inside a phone viewport. */
@media(max-width:760px){
  /* Ordinary page forms remain in-flow; only overlay/workspace forms receive sticky actions. */
  #app .form-actions{position:static!important;bottom:auto!important;z-index:auto!important;}
  #app :where(.modal-content,.modal-dialog,.o2-modal,.drawer,.drawer-panel,.sheet,.sheet-panel,.workspace-modal,.project-command-window,.project-command-modal,.project-workspace-window,.company-command-window) .form-actions{
    position:sticky!important;
    bottom:0!important;
    z-index:3!important;
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:8px!important;
    padding-bottom:calc(12px + env(safe-area-inset-bottom))!important;
    background:var(--card,var(--mpd-ui-surface))!important;
  }
  .mpd-investment-modal-front{
    inset:0!important;
    width:100vw!important;
    max-width:100vw!important;
    height:100dvh!important;
    max-height:100dvh!important;
    margin:0!important;
    border-radius:0!important;
  }
  .mpd-avatar-card{grid-template-columns:1fr!important;padding:15px!important;border-radius:19px!important;}
  .mpd-avatar-preview{width:82px!important;height:82px!important;}
  .mpd-avatar-actions{display:grid!important;grid-template-columns:1fr!important;}
  .mpd-avatar-actions label,.mpd-avatar-actions button{width:100%!important;text-align:center!important;}
  .mpd-avatar-toast{left:12px!important;right:12px!important;top:70px!important;max-width:none!important;}
  #app :where(.more-menu,.more-menu-panel,.mobile-more-menu,.mobile-menu-sheet,.bottom-sheet,.mobile-sheet){
    left:8px!important;
    right:8px!important;
    bottom:calc(78px + env(safe-area-inset-bottom))!important;
    width:auto!important;
    max-width:none!important;
    max-height:calc(100dvh - 100px - env(safe-area-inset-bottom))!important;
    border-radius:18px!important;
  }
  #app :where(.bottom-nav,.mobile-bottom-nav,.app-bottom-nav,.mobile-nav){
    min-height:calc(68px + env(safe-area-inset-bottom))!important;
    padding-bottom:env(safe-area-inset-bottom)!important;
    border-color:var(--line,var(--mpd-ui-line))!important;
    background:color-mix(in srgb,var(--card,var(--mpd-ui-surface)) 94%,transparent)!important;
    color:var(--text,var(--mpd-ui-text))!important;
    backdrop-filter:blur(18px);
    -webkit-backdrop-filter:blur(18px);
  }
  #app :where(.bottom-nav,.mobile-bottom-nav,.app-bottom-nav,.mobile-nav) :where(button,a){min-width:0!important;overflow:hidden!important;}
  #app :where(.bottom-nav,.mobile-bottom-nav,.app-bottom-nav,.mobile-nav) :where(span,small){overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
  #app :where(.gallery-grid,.media-grid,.file-grid,.product-grid,.packaging-grid,.asset-grid){
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:8px!important;
  }
  #app :where(.company-grid,.project-grid,.user-grid,.card-grid){grid-template-columns:1fr!important;}
  .task-history-row-v1316>.mpd-comment-feedback{margin-left:0!important;max-width:100%;}
  .mpd-like-count.has-value:where(:hover,:focus-visible):after{
    position:fixed!important;
    left:12px!important;
    right:12px!important;
    bottom:calc(88px + env(safe-area-inset-bottom))!important;
    width:auto!important;
    max-width:none!important;
    transform:none!important;
  }
  .mpd-like-count.has-value:where(:hover,:focus-visible):before{display:none!important;}
}

@media(max-width:420px){
  #app :where(.gallery-grid,.media-grid,.file-grid,.product-grid,.packaging-grid,.asset-grid){grid-template-columns:1fr!important;}
}
