/* ══════════════════════════════════════════════════════════════
   phonebook.css — دفترچه تلفن
   scoped زیر .phonebook-page
══════════════════════════════════════════════════════════════ */

.phonebook-page {
  --pb-primary: var(--navy-mid, #1a4f8a);
  --pb-primary-light: var(--blue, #2166b8);
  --pb-primary-pale: #e8f2fb;
  --pb-sidebar-w: 260px;
  --pb-toolbar-h: 68px;
  --pb-radius: var(--radius, 12px);
  --pb-shadow: var(--shadow, 0 2px 12px rgba(0, 0, 0, 0.09));
  --pb-shadow-md: var(--shadow-md, 0 4px 20px rgba(0, 0, 0, 0.12));

  /* alias برای کلاس‌های sidebar/card */
  --primary: var(--pb-primary);
  --primary-light: var(--pb-primary-light);
  --primary-pale: var(--pb-primary-pale);
  --radius: var(--pb-radius);
  --shadow: var(--pb-shadow);
  --shadow-md: var(--pb-shadow-md);

  padding-top: var(--header-total-height);
  background: var(--off-white, #f8fafc);
  min-height: 100vh;
}

/* ── TOOLBAR ──────────────────────────────────────────────── */

.pb-toolbar-wrap {
  position: sticky;
  top: calc(var(--header-top-offset) + 76px);
  z-index: 900;
  padding: 0 16px 14px;
  background: linear-gradient(to bottom, var(--off-white, #f8fafc) 80%, transparent);
}

.pb-toolbar {
  width: 100%;
  max-width: 1450px;
  margin: 0 auto;
  min-height: var(--pb-toolbar-h);
  background: var(--pb-primary);
  border-radius: 60px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 24px;
  gap: 12px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.pb-toolbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.pb-toolbar__icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
}

.pb-toolbar__text {
  line-height: 1.2;
  min-width: 0;
}

.pb-toolbar__text strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-toolbar__text span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-toolbar__search {
  flex: 1 1 280px;
  max-width: 380px;
  min-width: 180px;
  position: relative;
}

.pb-toolbar__search form {
  position: relative;
}

.pb-toolbar__search input {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 0 16px 0 42px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: background 0.2s;
}

.pb-toolbar__search input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.pb-toolbar__search input:focus {
  background: rgba(255, 255, 255, 0.22);
}

.pb-toolbar__search button {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  cursor: pointer;
  padding: 6px;
}

.pb-toolbar__position {
  flex: 0 1 180px;
  min-width: 140px;
}

.pb-toolbar__position select {
  width: 100%;
  height: 38px;
  border-radius: 19px;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-family: inherit;
  font-size: 12.5px;
  padding: 0 12px;
  outline: none;
  cursor: pointer;
}

.pb-toolbar__position select option {
  color: #111;
}

.pb-toolbar__tabs {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.pb-tab-btn {
  height: 36px;
  padding: 0 16px;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 18px;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.pb-tab-btn i {
  font-size: 12px;
}

.pb-tab-btn.active,
.pb-tab-btn:hover {
  background: #fff;
  color: var(--pb-primary);
  border-color: #fff;
}

/* ── LAYOUT ──────────────────────────────────────────────── */

.pb-layout {
  display: flex;
  max-width: 1450px;
  margin: 0 auto;
  padding: 22px 16px 40px;
  gap: 20px;
  min-height: calc(100vh - var(--header-total-height) - var(--pb-toolbar-h));
}

.pb-sidebar {
  width: var(--pb-sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-top-offset) + 76px + var(--pb-toolbar-h) + 22px);
  max-height: calc(100vh - var(--header-total-height) - var(--pb-toolbar-h) - 44px);
  overflow-y: auto;
  align-self: flex-start;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */

.phonebook-page .sidebar-card {
  background: #fff;
  border-radius: var(--pb-radius);
  box-shadow: var(--pb-shadow);
  overflow: hidden;
}

.phonebook-page .sidebar-head {
  background: var(--pb-primary);
  color: #fff;
  padding: 13px 16px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.phonebook-page .s-all {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--pb-primary);
  border-bottom: 2px solid var(--pb-primary-pale);
  cursor: pointer;
  transition: background 0.15s;
}

.phonebook-page .s-all:hover,
.phonebook-page .s-all.active {
  background: var(--pb-primary-pale);
}

.phonebook-page .s-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.phonebook-page .s-list li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: #333;
  border-bottom: 1px solid #f0f4f8;
  transition: background 0.15s, color 0.15s;
}

.phonebook-page .s-list li a span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phonebook-page .s-list li a:hover {
  background: var(--pb-primary-pale);
  color: var(--pb-primary);
}

.phonebook-page .s-list li a.active {
  background: var(--pb-primary-pale);
  color: var(--pb-primary);
  font-weight: 700;
}

.phonebook-page .badge {
  flex-shrink: 0;
  background: var(--pb-primary);
  color: #fff;
  border-radius: 12px;
  font-size: 11px;
  padding: 1px 8px;
  font-weight: 700;
}

/* ── MAIN ────────────────────────────────────────────────── */

.phonebook-page .main {
  flex: 1;
  min-width: 0;
}

.phonebook-page .status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 8px;
}

.phonebook-page .status-text {
  font-size: 13px;
  color: #666;
  line-height: 1.6;
  flex: 1 1 200px;
}

.phonebook-page .status-text strong {
  color: var(--pb-primary);
}

.phonebook-page .clear-btn {
  font-size: 12px;
  color: var(--pb-primary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.phonebook-page .clear-btn:hover {
  background: var(--pb-primary-pale);
}

/* ── DEPT SECTION ────────────────────────────────────────── */

.phonebook-page .dept-section {
  margin-bottom: 26px;
}

.phonebook-page .dept-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  background: var(--pb-primary);
  color: #fff;
  border-radius: var(--pb-radius) var(--pb-radius) 0 0;
}

.phonebook-page .dept-ico {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.phonebook-page .dept-name {
  font-size: 14px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phonebook-page .dept-cnt {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 2px 12px;
  font-size: 11px;
  font-weight: 600;
}

/* ── MEMBERS GRID ────────────────────────────────────────── */

.phonebook-page .members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  background: #fff;
  border-radius: 0 0 var(--pb-radius) var(--pb-radius);
  box-shadow: var(--pb-shadow);
  padding: 14px;
}

/* ── CARD ────────────────────────────────────────────────── */

.phonebook-page .card {
  border: 1px solid #e4edf5;
  border-radius: 10px;
  padding: 13px;
  background: #fafdff;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
  min-width: 0;
}

.phonebook-page .card:hover {
  box-shadow: var(--pb-shadow-md);
  transform: translateY(-2px);
  border-color: #b8d0e8;
}

.phonebook-page .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--pb-primary), var(--pb-primary-light));
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phonebook-page .card-body {
  flex: 1;
  min-width: 0;
}

.phonebook-page .card-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #111e2d;
  margin-bottom: 5px;
}

.phonebook-page .card-name,
.phonebook-page .card-name small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phonebook-page .card-name small {
  display: block;
  font-weight: 400;
  color: #8494a3;
  font-size: 11px;
}

.phonebook-page .card-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.phonebook-page .crow {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: #555;
  line-height: 1.5;
  min-width: 0;
}

.phonebook-page .crow i {
  width: 13px;
  margin-top: 3px;
  color: var(--pb-primary-light);
  font-size: 11px;
  flex-shrink: 0;
}

.phonebook-page .crow span,
.phonebook-page .crow a {
  min-width: 0;
  word-break: break-word;
}

.phonebook-page .crow a {
  color: var(--pb-primary);
  transition: color 0.15s;
  direction: ltr;
  unicode-bidi: embed;
}

.phonebook-page .crow a:hover {
  color: var(--pb-primary-light);
  text-decoration: underline;
}

.phonebook-page .card-tag {
  display: inline-block;
  margin-top: 7px;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  background: var(--pb-primary-pale);
  color: var(--pb-primary);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── EMPTY ───────────────────────────────────────────────── */

.phonebook-page .empty {
  text-align: center;
  padding: 56px 20px;
  background: #fff;
  border-radius: var(--pb-radius);
  box-shadow: var(--pb-shadow);
  color: #aaa;
}

.phonebook-page .empty i {
  font-size: 44px;
  margin-bottom: 14px;
  display: block;
}

.phonebook-page .empty p {
  font-size: 14px;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */

/* ── تبلت ── */
@media (max-width: 1024px) {
  .pb-toolbar__search {
    flex: 1 1 220px;
    max-width: none;
  }

  .pb-toolbar__position {
    flex: 1 1 160px;
  }

  .phonebook-page .members-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

/* ── موبایل بزرگ ── */
@media (max-width: 820px) {
  .pb-toolbar-wrap {
    top: calc(var(--header-top-offset) + 68px);
    padding: 0 12px 12px;
  }

  .pb-toolbar {
    border-radius: 28px;
    padding: 12px 14px;
    gap: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .pb-toolbar__brand {
    grid-column: 1 / -1;
  }

  .pb-toolbar__tabs {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .pb-tab-btn {
    width: 100%;
    height: 40px;
    font-size: 12.5px;
    padding: 0 10px;
  }

  .pb-toolbar__search,
  .pb-toolbar__position {
    grid-column: 1 / -1;
    flex: none;
    max-width: none;
    min-width: 0;
  }

  .pb-toolbar__text span {
    display: none;
  }

  .pb-layout {
    flex-direction: column;
    padding: 12px;
    gap: 16px;
  }

  .pb-sidebar {
    width: 100%;
    position: static;
    max-height: none;
    overflow: visible;
  }

  /* sidebar: لیست عمودی مرتب */
  .phonebook-page .s-all {
    display: flex;
    margin: 0;
    border-bottom: 2px solid var(--pb-primary-pale);
  }

  .phonebook-page .s-list {
    display: block;
    padding: 0;
    margin: 0;
  }

  .phonebook-page .s-list li {
    width: 100%;
    max-width: none;
  }

  .phonebook-page .s-list li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    font-size: 13px;
    color: #333;
    border: none;
    border-bottom: 1px solid #f0f4f8;
    border-radius: 0;
    background: #fff;
    transition: background 0.15s, color 0.15s;
  }

  .phonebook-page .s-list li:last-child a {
    border-bottom: none;
  }

  .phonebook-page .s-list li a span:first-child {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .phonebook-page .s-list li a:hover,
  .phonebook-page .s-list li a.active {
    background: var(--pb-primary-pale);
    color: var(--pb-primary);
  }

  .phonebook-page .s-list li a.active {
    font-weight: 700;
    border-right: 3px solid var(--pb-primary);
  }

  .phonebook-page .badge {
    flex-shrink: 0;
    min-width: 28px;
    text-align: center;
  }

  /* scroll برای لیست بلند واحدها */
  .phonebook-page .sidebar-card {
    max-height: 320px;
    display: flex;
    flex-direction: column;
  }

  .phonebook-page .sidebar-head,
  .phonebook-page .s-all {
    flex-shrink: 0;
  }

  .phonebook-page .s-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .phonebook-page .members-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
    gap: 8px;
  }

  .phonebook-page .status-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .phonebook-page .clear-btn {
    align-self: flex-start;
  }
}

/* ── موبایل کوچک ── */
@media (max-width: 540px) {
  .phonebook-page {
    padding-top: calc(var(--header-top-offset) + 70px + 16px);
  }

  .pb-toolbar-wrap {
    top: calc(var(--header-top-offset) + 58px);
    padding: 0 10px 10px;
  }

  .pb-toolbar {
    border-radius: 22px;
    padding: 10px 12px;
  }

  .pb-toolbar__icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .pb-toolbar__text strong {
    font-size: 14px;
  }

  .pb-toolbar__search input,
  .pb-toolbar__position select {
    height: 38px;
    font-size: 12.5px;
  }

  .pb-tab-btn {
    height: 38px;
    font-size: 12px;
    padding: 0 8px;
  }

  .pb-tab-btn i {
    display: none;
  }

  .pb-layout {
    padding: 10px;
  }

  .phonebook-page .s-list li a {
    padding: 11px 14px;
    font-size: 12.5px;
  }

  .phonebook-page .members-grid {
    grid-template-columns: 1fr;
  }

  .phonebook-page .card {
    padding: 12px;
  }

  .phonebook-page .dept-hd {
    padding: 10px 14px;
    gap: 8px;
  }

  .phonebook-page .dept-name {
    font-size: 13px;
    white-space: normal;
  }

  .phonebook-page .status-text {
    font-size: 12px;
  }
}

/* ── موبایل خیلی کوچک ── */
@media (max-width: 360px) {
  .pb-toolbar {
    grid-template-columns: 1fr;
  }

  .pb-toolbar__tabs {
    grid-template-columns: 1fr;
  }
}