/* Shell and responsive layout (mobile 375, tablet 768, desktop 1440). */

/* Avatar colors for account switcher */
.rb-av-0 { background: var(--c-pink); }
.rb-av-1 { background: #36bed9; }
.rb-av-2 { background: #54b772; }
.rb-av-3 { background: var(--c-warn-icon); }
.rb-av-4 { background: #7a5af8; }

/* Accessible hidden text */
.rb-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Guard against top bar overflow */
.proto-bar { max-width: 100vw; box-sizing: border-box; overflow: hidden; }
.proto-bar select { max-width: 220px; }

/* Section title in settings menu */
.rb-settings-header {
  font-size: 11px; line-height: 16px; text-transform: uppercase;
  color: var(--muted); letter-spacing: .04em; padding: 16px 16px 8px; font-weight: 500;
}

/* Base interactive items */
.rb-chip { display: inline-flex; align-items: center; gap: 8px; }
.rb-chip a[data-del] {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; min-height: 24px; line-height: 24px; font-size: 16px; text-decoration: none;
}
.rb-line { min-height: 32px; display: flex; align-items: center; gap: 8px; }
.user-info { display: flex; align-items: center; gap: 12px; }
.user-info-left { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.useremail, .user-info .useremail {
  white-space: normal !important; overflow: visible !important; text-overflow: clip !important;
  overflow-wrap: break-word !important;
}

/* Table actions toolbar: align button to left edge of table */
.sms-table-actions {
  display: flex !important;
  flex-direction: row !important;
  justify-content: flex-start !important;
  align-items: center !important;
  gap: 16px !important;
  margin-bottom: 16px !important;
  padding: 0 !important;
}

/* Card sections for employee security, keys, activity */
.rb-card-sec {
  margin-top: 16px;
  margin-bottom: 24px;
}
.rb-card-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.rb-card-actions {
  margin-top: 16px;
}


/* Account menu: above save bar (z-index > 100), full text wrapping */
.rb-acc-menu, #acc-menu { z-index: 150 !important; }
.rb-acc-text,
.rb-acc-text b,
.rb-acc-text .rb-sub {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  overflow-wrap: break-word !important;
}

/* Tables: full text wrapping, no ellipsis, no clipping */
table.contacts-table.sms-table td,
table.contacts-table.sms-table th,
.table-lk td,
.table-lk th {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  overflow-wrap: break-word !important;
}

/* Tablet (768 - 1199 px): settings menu above content, tables fit without scroll */
@media (min-width: 768px) and (max-width: 1199px) {
  .container { max-width: 100%; padding-left: 20px; padding-right: 20px; box-sizing: border-box; }
  .sidebar.sidebar-leftside { display: flex; flex-direction: column; }
  .sidebar.sidebar-leftside .sidebar-left,
  .sidebar.sidebar-leftside .sidebar-left.sidebar-180 {
    width: 100%; max-width: 100%; margin: 0 0 16px 0; float: none;
  }
  #settings-menu { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  #settings-menu .button {
    width: auto; margin-bottom: 0; padding: 8px 12px; display: inline-flex; align-items: center;
  }
  .rb-settings-header { padding: 0 8px; align-self: center; }
  .sidebar .content { max-width: 100%; width: 100%; margin-right: 0; float: none; }
  .table-lk { width: 100%; table-layout: fixed; }
  .table-lk td, .table-lk th {
    padding: 8px 8px !important; font-size: 12px !important; overflow-wrap: break-word;
  }
  /* the members table takes its column widths from <colgroup> in accounts.js (docs/proto-v2/02-accounts.md § 2);
     v2.css switches .rb-members to table-layout: auto and sets the min width */
}

/* Mobile (up to 767 px): full-width container, single line scrollable menus, card tables */
@media (max-width: 767px) {
  .container {
    width: 100% !important; max-width: 100% !important;
    padding-left: 16px !important; padding-right: 16px !important; box-sizing: border-box !important;
  }
  .header { padding: 12px 0; }
  .header .container {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  }
  .logo { float: none; }
  .logo .logo-img { width: 140px; height: 28px; background-size: contain; }
  .header-right { float: none; margin: 0; }
  .user-info { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
  .user-info-left { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
  .useremail { font-size: 11px; }
  .user-balance { font-size: 13px; }
  .button, a.button {
    min-height: 40px !important; padding: 0 16px !important; box-sizing: border-box !important;
    display: inline-flex !important; align-items: center !important; justify-content: center !important;
  }
  .sign-out .button { min-width: 40px !important; padding: 0 !important; }
  .proto-bar select { max-width: 140px; }
  .desktop-main-menu {
    display: block !important; overflow-x: auto !important; overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch; white-space: nowrap; border-bottom: 1px solid var(--c-line); padding: 4px 0;
  }
  .desktop-main-menu ul#main-menu {
    display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important;
    gap: 12px; margin: 0; padding: 0; list-style: none;
  }
  .desktop-main-menu ul#main-menu li { flex: none !important; display: inline-block !important; }
  .desktop-main-menu ul#main-menu li a { font-size: 12px; padding: 8px 4px; white-space: nowrap; }
  .sidebar.sidebar-leftside { display: flex; flex-direction: column; }
  .sidebar.sidebar-leftside .sidebar-left,
  .sidebar.sidebar-leftside .sidebar-left.sidebar-180 {
    width: 100% !important; max-width: 100% !important; margin: 0 0 16px 0;
    float: none; max-height: 120px !important; overflow: hidden;
  }
  #settings-menu {
    float: none !important; width: 100% !important; max-width: 100% !important;
    margin-left: 0 !important;
    display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important;
    overflow-x: auto !important; overflow-y: hidden !important; -webkit-overflow-scrolling: touch;
    gap: 8px; padding: 4px 0 8px; align-items: center; box-sizing: border-box;
  }
  #settings-menu .button {
    flex: 0 0 calc(50% - 4px) !important; width: calc(50% - 4px) !important; white-space: nowrap !important;
    margin-bottom: 0 !important; height: 40px !important; display: inline-flex !important; align-items: center !important;
    justify-content: center !important; box-sizing: border-box !important; padding: 0 8px !important;
  }
  .rb-settings-header {
    flex: 0 0 auto !important; padding: 0 8px !important; white-space: nowrap !important; align-self: center !important;
  }
  .sidebar .content { max-width: 100% !important; width: 100% !important; margin-right: 0 !important; float: none; }
  .rb-tabs { gap: 8px; margin-bottom: 16px; }
  .rb-tabs .button { flex: 1 1 auto; text-align: center; white-space: nowrap; padding: 0 8px !important; }
  .sms-table-actions {
    display: flex !important; flex-direction: column !important; align-items: stretch !important;
    gap: 8px !important; margin-bottom: 16px !important;
  }
  .sms-table-actions .rb-inline { width: 100% !important; min-width: 0 !important; }
  .sms-table-actions .button { width: 100% !important; }
  table.contacts-table.sms-table.table-lk,
  table.contacts-table.sms-table.table-lk tbody,
  table.contacts-table.sms-table.table-lk tr,
  table.contacts-table.sms-table.table-lk td {
    display: block !important; width: 100% !important; box-sizing: border-box !important;
  }
  table.contacts-table.sms-table.table-lk thead { display: none !important; }
  table.contacts-table.sms-table.table-lk tr.item {
    margin-bottom: 12px; background: #fff; border: 1px solid var(--c-line);
    border-radius: 8px; padding: 12px 16px;
  }
  table.contacts-table.sms-table.table-lk td {
    padding: 8px 0 !important; border: 0 !important; display: flex !important;
    justify-content: space-between !important; align-items: flex-start !important;
    gap: 12px; min-height: 24px; font-size: 13px !important; line-height: 18px !important; text-align: right;
  }
  /* card field: the label on the left, every value of the field stacked in one column on the right */
  table.contacts-table.sms-table.table-lk.rb-members td[data-label] {
    display: grid !important; grid-template-columns: minmax(96px, 40%) 1fr; column-gap: 12px; row-gap: 4px; justify-items: start; text-align: left;
  }
  .rb-members td[data-label] > * { grid-column: 2; }
  .rb-members td[data-label]::before { grid-column: 1; grid-row: 1 / span 6; justify-self: start; max-width: none !important; }
  table.contacts-table.sms-table.table-lk td[data-label]::before {
    content: attr(data-label); font-weight: 500; color: var(--muted);
    font-size: 12px; line-height: 18px; text-align: left; flex: none; max-width: 45%;
  }
  table.contacts-table.sms-table.table-lk td.rb-acts {
    justify-content: flex-end !important; padding-top: 8px !important;
    margin-top: 8px; border-top: 1px solid var(--c-line) !important;
  }
  table.contacts-table.sms-table.table-lk td.rb-acts[data-label]::before { display: none; }
  .rb-line { min-height: 40px !important; display: flex !important; align-items: center !important; }
  .rb-ip-add { max-width: 100% !important; flex-wrap: wrap !important; }
  .rb-ip-add .rb-input, .rb-ip-add .button, #sec-save { width: 100% !important; }
  .rb-overlay { padding: 16px !important; align-items: center !important; }
  .rb-modal {
    max-width: 100% !important; width: 100% !important; padding: 24px 16px !important;
    box-sizing: border-box !important; margin: 0 !important;
  }
  .rb-modal-actions { flex-direction: column !important; }
  .rb-modal-actions .button { width: 100% !important; }
  .rb-acc-menu { max-width: calc(100vw - 32px); right: 0; }
  .rb-acc-item kbd, #acc-menu kbd { display: none !important; }
  /* Accounts page: the toolbar wraps to several lines, search takes the full width */
  .rb-toolbar { gap: 8px !important; }
  .rb-toolbar-right { width: 100% !important; margin-left: 0 !important; flex-wrap: wrap !important; gap: 8px !important; }
  .rb-search-acc { width: 100% !important; }
  /* tap targets 44×44 on the phone (founder, round 6) */
  .rb-toolbar .button, .rb-toolbar .rb-search-acc .sidebar-search-input { height: 44px; min-height: 44px; box-sizing: border-box; }
  .rb-toolbar .rb-icon-btn, .rb-acts .rb-icon-btn {
    width: 44px !important; height: 44px !important; min-width: 44px; min-height: 44px; padding: 0 !important; margin-left: 0 !important; margin-right: 8px;
  }
  .rb-cb-hit { width: 44px; height: 44px; }
  .rb-impersonation { padding: 8px 12px; }
  .rb-impersonation .rb-imp-exit { width: 100% !important; }
}

/* Tablet (768–1199 px): the accounts table keeps readable columns and scrolls inside its own block, the page never scrolls sideways */
@media (min-width: 768px) and (max-width: 1199px) {
  .rb-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .rb-table-wrap .rb-members { min-width: 1012px; }  /* the colgroup sum; v2.css re-sets it after layout */
}
