/*
 * IDEFO KPD mobile layout
 * Keeps the desktop and print layouts unchanged.
 */

/*
 * Platform owner → Companies → Company settings.
 * The complete middle part scrolls; the title and bottom actions stay visible.
 * The employee section grows naturally and never receives a nested scrollbar.
 */
.modal:has(.company-editor) {
  width: min(860px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.modal:has(.company-editor) > header {
  position: relative;
  z-index: 5;
  background: #fff;
}

.modal:has(.company-editor) > .modal-body {
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #c89f08 #eceee6;
}

.modal:has(.company-editor) > .modal-body::-webkit-scrollbar {
  width: 10px;
}

.modal:has(.company-editor) > .modal-body::-webkit-scrollbar-track {
  border-left: 1px solid #d9dbd2;
  background: #eceee6;
}

.modal:has(.company-editor) > .modal-body::-webkit-scrollbar-thumb {
  border: 2px solid #eceee6;
  border-radius: 999px;
  background: #c89f08;
}

.company-editor {
  min-width: 0;
  max-height: none !important;
  overflow: visible !important;
  gap: 10px !important;
  padding: 14px 18px 0;
}

.company-editor .company-brand-editor {
  min-width: 0;
  min-height: 94px !important;
  height: auto !important;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}

.company-editor .company-brand-editor > * {
  min-width: 0;
}

.company-editor .company-brand-editor > span {
  display: grid;
  align-content: center;
  gap: 4px;
}

.company-editor .company-brand-editor strong,
.company-editor .company-brand-editor small {
  overflow-wrap: anywhere;
}

.company-editor .company-brand-editor .company-logo-mark {
  width: 150px !important;
  height: 72px !important;
  min-width: 0;
  overflow: hidden;
}

.company-editor .company-brand-editor .company-logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.company-editor .company-brand-editor .upload-button {
  max-width: 100%;
  white-space: nowrap;
}

.company-editor .form-grid {
  min-width: 0;
  gap: 10px;
}

.company-editor .field {
  min-width: 0;
  gap: 4px;
}

.company-editor .field input,
.company-editor .field select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.company-editor .seat-usage-card {
  min-width: 0;
  min-height: 68px;
  height: auto;
  flex: 0 0 auto;
  align-items: center;
  padding: 10px 12px;
}

.company-editor .seat-usage-card > span {
  min-width: 0;
  align-content: center;
}

.company-editor .seat-usage-card strong,
.company-editor .seat-usage-card small {
  display: block;
}

.company-editor .seat-usage-card small {
  line-height: 1.45;
}

.company-members {
  max-height: none !important;
  overflow: visible !important;
}

.company-members > header {
  position: static;
}

.company-editor > .modal-actions {
  position: sticky;
  z-index: 4;
  bottom: 0;
  margin: 2px -18px 0;
  padding: 12px 18px;
  border-top: 1px solid #d9dbd2;
  background: #fff;
  box-shadow: 0 -8px 18px rgb(20 24 16 / 8%);
}

/*
 * Browser zoom reduces the CSS viewport just like a narrower monitor.
 * Switch the logo area before its three columns can collide.
 */
@media screen and (max-width: 1200px) {
  .company-editor .company-brand-editor {
    grid-template-columns: 112px minmax(0, 1fr) auto;
  }

  .company-editor .company-brand-editor .company-logo-mark {
    width: 112px !important;
    height: 72px !important;
  }
}

@media screen and (max-width: 760px) {
  .modal:has(.company-editor) {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 18px;
  }

  .modal:has(.company-editor) > header {
    padding: 16px;
  }

  .company-editor {
    padding: 10px 12px 0;
  }

  .company-editor .company-brand-editor {
    min-height: 128px !important;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 10px 12px;
  }

  .company-editor .company-brand-editor .company-logo-mark {
    width: 84px !important;
    height: 64px !important;
  }

  .company-editor .company-brand-editor .upload-button {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: center;
  }

  .company-editor .form-grid {
    grid-template-columns: 1fr;
  }

  .company-editor .seat-usage-card,
  .company-members > header {
    align-items: stretch;
    flex-direction: column;
  }

  .company-editor .seat-usage-card b,
  .company-members > header button {
    align-self: flex-start;
  }

  .company-editor > .modal-actions {
    margin-right: -12px;
    margin-left: -12px;
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .company-editor > .modal-actions > span {
    display: none;
  }
}

@media screen and (max-width: 480px) {
  .company-editor .company-brand-editor {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .company-editor .company-brand-editor .company-logo-mark {
    width: 72px !important;
    height: 58px !important;
  }

  .company-members > button {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    padding-right: 10px;
    padding-left: 10px;
  }

  .company-editor > .modal-actions button {
    flex: 1 1 calc(50% - 6px);
  }
}

@media screen and (max-width: 900px) {
  html,
  body,
  #root {
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  body {
    -webkit-text-size-adjust: 100%;
  }

  .app {
    --nav-width: 0px !important;
    min-width: 0;
    display: block;
  }

  .side {
    position: sticky;
    z-index: 100;
    top: 0;
    width: 100%;
    height: auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 14px;
    padding: 10px 12px 9px;
    box-shadow: 0 6px 20px rgb(0 0 0 / 16%);
  }

  .side .logo {
    min-width: 0;
    gap: 9px;
    padding: 0;
  }

  .side .logo > b {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    font-size: 19px;
  }

  .side .logo strong {
    font-size: 15px;
  }

  .side .logo small {
    font-size: 8px;
  }

  .side .workspace {
    min-width: 0;
    max-width: 47vw;
    gap: 1px;
    margin: 0;
    padding: 7px 9px;
    border-radius: 10px;
  }

  .side .workspace small {
    display: none;
  }

  .side .workspace strong,
  .side .workspace span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .side .workspace strong {
    font-size: 10px;
  }

  .side .workspace span {
    font-size: 8px;
  }

  .side nav {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0 0 2px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: #d6ad12 #2c2f27;
  }

  .side nav::-webkit-scrollbar {
    height: 4px;
  }

  .side nav::-webkit-scrollbar-track {
    background: #2c2f27;
  }

  .side nav::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #d6ad12;
  }

  .side nav button {
    width: auto;
    min-width: max-content;
    min-height: 38px;
    display: flex;
    flex: 0 0 auto;
    gap: 7px;
    padding: 0 11px;
    border-radius: 9px;
    font-size: 10px;
    white-space: nowrap;
  }

  .side nav button > span {
    font-size: 15px;
  }

  .side-foot {
    display: none;
  }

  .main {
    width: 100%;
    min-width: 0;
  }

  .top {
    min-height: 0;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 14px;
  }

  .top > div:first-child {
    min-width: 0;
  }

  .top h1 {
    font-size: clamp(24px, 8vw, 34px);
    overflow-wrap: anywhere;
  }

  .account,
  .account.role-demo {
    width: 100%;
    max-width: none;
    min-width: 0;
    justify-content: space-between;
  }

  .account label {
    display: none;
  }

  .account select,
  .account.role-demo select {
    width: 100%;
    min-width: 0;
    max-width: none;
    font-size: 11px;
  }

  .content {
    width: 100%;
    min-width: 0;
    gap: 14px;
    padding: 14px 12px 70px;
  }

  .metrics,
  .settings-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .metric,
  .settings-grid article,
  .settings-grid .settings-stat-card {
    min-height: 104px;
    padding: 16px;
  }

  .settings-grid {
    padding: 0 12px 18px;
  }

  .panel {
    min-width: 0;
    border-radius: 15px;
  }

  .panel-title {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    padding: 17px 15px 14px;
  }

  .panel-title > button,
  .panel-title > div + * {
    align-self: flex-start;
  }

  .filters {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
    padding: 10px 14px;
  }

  .filters > label {
    width: 100%;
    min-width: 0;
  }

  .filters > div {
    max-width: 100%;
    overflow-x: auto;
  }

  .company-list article {
    grid-template-columns: 48px minmax(0, 1fr) auto !important;
    gap: 11px;
    min-height: 0;
    padding: 14px;
  }

  .company-list h3 {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  /* Employee lists: independently scrollable with a permanently visible rail. */
  .team-list,
  .participants {
    max-height: min(58vh, 520px);
    overflow-y: scroll !important;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    scrollbar-width: auto;
    scrollbar-color: #c89f08 #eceee6;
  }

  .team-list::-webkit-scrollbar,
  .participants::-webkit-scrollbar {
    width: 9px;
  }

  .team-list::-webkit-scrollbar-track,
  .participants::-webkit-scrollbar-track {
    border-left: 1px solid #d9dbd2;
    background: #eceee6;
  }

  .team-list::-webkit-scrollbar-thumb,
  .participants::-webkit-scrollbar-thumb {
    border: 2px solid #eceee6;
    border-radius: 999px;
    background: #c89f08;
  }

  .team-list article {
    min-height: 0;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 8px 10px;
    padding: 12px 10px 12px 12px;
  }

  .team-list article > :nth-child(3),
  .team-list article > :nth-child(4) {
    grid-column: 2 / -1;
  }

  .team-list article > button {
    grid-column: 2 / -1;
    width: max-content;
  }

  .project-list,
  .client-list {
    min-width: 0;
    overflow-x: auto;
  }

  .global-footer {
    position: static;
    width: 100%;
    height: auto;
    min-height: 46px;
    grid-template-columns: auto 1fr;
    gap: 3px 12px;
    padding: 8px 12px;
    font-size: 9px;
  }

  .global-footer time {
    text-align: right;
  }

  .global-footer strong {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 8px;
  }
}

@media screen and (max-width: 480px) {
  .side {
    grid-template-columns: 1fr;
  }

  .side .workspace {
    max-width: none;
  }

  .side nav {
    grid-column: 1;
  }

  .company-list article {
    grid-template-columns: 42px minmax(0, 1fr) !important;
  }

  .company-list article > button {
    grid-column: 2;
    justify-self: start;
  }
}
