/* Branches tab — Maui BranchesPage + BranchDetailPopup parity (Phase 6) */

.dz-branches {
  display: flex;
  flex-direction: column;
  gap: 10px;
  direction: rtl;
  /* اسکرول با body — محتوا زیر فید تب‌بار مثل محصولات */
}

.dz-branches-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

.dz-branches-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 14px;
  border-radius: 24px;
  background: transparent;
  border: 1px solid var(--dz-gray-400);
  direction: ltr;
  flex-shrink: 0;
}

.dz-branches-search__actions {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dz-branches-search__ico {
  width: 20px;
  height: 20px;
  color: var(--dz-text-muted);
  display: inline-flex;
}

.dz-branches-search__ico .dz-ico {
  width: 20px;
  height: 20px;
}

.dz-branches-search input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--dz-text);
  text-align: right;
  min-width: 0;
  direction: rtl;
}

.dz-branches-search input::-webkit-search-cancel-button,
.dz-branches-search input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.dz-branches-search input::placeholder {
  color: var(--dz-gray-400);
}

.dz-branches-search__clear {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--dz-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.dz-branches-search__clear .dz-ico {
  width: 16px;
  height: 16px;
}

.dz-branches-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex-shrink: 0;
}

.dz-branches-tab {
  min-height: 50px;
  border-radius: 10px;
  border: 1px solid var(--dz-primary);
  background: transparent;
  color: var(--dz-primary);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 8px 10px;
}

@media (prefers-color-scheme: dark) {
  .dz-branches-tab {
    border-color: #333;
    color: var(--dz-secondary-dark);
  }
}

.dz-branches-tab.is-on {
  background: var(--dz-primary);
  color: #fff;
  border-color: transparent;
}

@media (prefers-color-scheme: dark) {
  .dz-branches-tab.is-on {
    background: var(--dz-secondary);
    color: #fff;
  }
}

.dz-branches-list-wrap {
  position: relative;
  min-height: 120px;
  overflow: visible;
}

.dz-branches-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 4px;
}

.dz-branch-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--dz-border);
  border-radius: 8px;
  background: var(--dz-surface);
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  text-align: right;
  direction: rtl;
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.dz-branch-row:hover {
  border-color: color-mix(in srgb, var(--dz-primary) 35%, var(--dz-border));
  background: color-mix(in srgb, var(--dz-primary) 4%, var(--dz-surface));
}

.dz-branch-row.is-pulse {
  background: #dde1e8;
}

@media (prefers-color-scheme: dark) {
  .dz-branch-row {
    background: var(--dz-surface-2);
    box-shadow: none;
  }

  .dz-branch-row.is-pulse {
    background: #3a3a3a;
  }
}

.dz-branch-row__pin {
  color: var(--dz-text);
  display: inline-flex;
  width: 18px;
  height: 18px;
}

.dz-branch-row__pin .dz-ico {
  width: 15px;
  height: 15px;
}

.dz-branch-row__body {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  direction: rtl;
}

.dz-branch-row__name {
  font-size: 1rem;
  color: var(--dz-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.dz-branch-row__city {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 5px;
  /* Maui: PrimaryDark #5D189F */
  background: #5D189F;
  color: #fff;
  font-size: 0.6rem;
  line-height: 1.4;
  max-width: 7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (prefers-color-scheme: dark) {
  .dz-branch-row__city {
    /* Secondary #8A2BE2 — تیره‌تر از SecondaryDark توکن دارک */
    background: #8A2BE2;
    color: var(--dz-secondary-dark-text);
  }
}

.dz-branch-row__chevron {
  color: var(--dz-text-muted);
  display: inline-flex;
  width: 16px;
  height: 16px;
}

.dz-branch-row__chevron .dz-ico {
  width: 14px;
  height: 14px;
}

.dz-branches-loading,
.dz-branches-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 12px;
  color: var(--dz-gray-400);
  text-align: center;
}

.dz-branches-loading__spin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--dz-primary-dark) 25%, transparent);
  border-top-color: var(--dz-primary-dark);
  animation: dz-branches-spin 0.75s linear infinite;
}

@keyframes dz-branches-spin {
  to { transform: rotate(360deg); }
}

.dz-branches-empty__msg {
  margin: 0;
  white-space: pre-line;
  font-size: 0.92rem;
}

.dz-branches-retry {
  width: auto;
  margin: 0;
  padding: 8px 16px;
}

.dz-branches-refresh {
  text-align: center;
  font-size: 0.8rem;
  color: var(--dz-text-muted);
  padding: 6px 0 10px;
}

/* —— Detail sheet (centered — نه زیر تب‌بار/فوتر) —— */
.dz-branches-sheet-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  z-index: 80;
}

.dz-branches-sheet {
  width: min(100%, 420px);
  max-height: min(460px, calc(100dvh - 48px));
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 14px 14px;
  border-radius: 20px;
  background: var(--dz-surface);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
  direction: rtl;
  animation: dz-branches-sheet-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes dz-branches-sheet-in {
  from { transform: translateY(28%); opacity: 0.55; }
  to { transform: translateY(0); opacity: 1; }
}

.dz-branches-sheet__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  flex-shrink: 0;
}

.dz-branches-sheet__eyebrow {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--dz-gray-400);
}

.dz-branches-sheet__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dz-text);
}

.dz-branches-sheet__city {
  padding: 2px 6px;
  border-radius: 5px;
  background: #5D189F;
  color: #fff;
  font-size: 0.6rem;
}

@media (prefers-color-scheme: dark) {
  .dz-branches-sheet__city {
    background: #8A2BE2;
    color: var(--dz-secondary-dark-text);
  }
}

.dz-branches-sheet__scroll {
  overflow: auto;
  transform: scaleX(-1);
  min-height: 0;
  flex: 1;
  padding-inline-end: 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dz-branches-sheet__scroll > * {
  transform: scaleX(-1);
}

.dz-branches-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dz-branches-block__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border-radius: 16px;
  /* Maui Light: Gray100 */
  background: #E1E1E1;
  color: #350066;
  font-size: 0.78rem;
}

.dz-branches-block__bar .dz-ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #ed24ff; /* SecondaryDarkText */
}

@media (prefers-color-scheme: dark) {
  .dz-branches-block__bar {
    /* Maui Dark: MidnightBlue #190649 (نه توکن remapped) */
    background: #190649;
    color: #E1E1E1; /* Gray100 / Gray200 light text */
  }

  .dz-branches-block__bar .dz-ico {
    color: #9f58e1; /* SecondaryDark */
  }
}

.dz-branches-block__bar--contact {
  background: #8A2BE2; /* Secondary — ثابت در هر دو تم */
  color: #fff;
}

.dz-branches-block__bar--contact .dz-ico {
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .dz-branches-block__bar--contact {
    background: #8A2BE2;
    color: #fff;
  }

  .dz-branches-block__bar--contact .dz-ico {
    color: #fff;
  }
}

.dz-branches-field {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 4px 6px;
  align-items: start;
  margin-inline-start: 12px;
  font-size: 0.72rem;
}

.dz-branches-field__ico {
  color: var(--dz-primary);
  display: inline-flex;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.dz-branches-field__ico .dz-ico {
  width: 15px;
  height: 15px;
}

.dz-branches-field__dot {
  width: 6px;
  height: 6px;
  margin-top: 5px;
  border-radius: 1px;
  background: var(--dz-primary);
}

@media (prefers-color-scheme: dark) {
  .dz-branches-field__ico {
    color: #fff;
    background: transparent;
  }

  .dz-branches-field__dot {
    background: #fff;
  }
}

.dz-branches-field__label {
  /* Maui Light: Secondary */
  color: #8A2BE2;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .dz-branches-field__label {
    /* Maui Dark: Gray100 — یک پله روشن‌تر از value */
    color: #E1E1E1;
  }
}

.dz-branches-field__value {
  /* Maui Light: Gray500 */
  color: #6E6E6E;
  line-height: 1.5;
  word-break: break-word;
}

@media (prefers-color-scheme: dark) {
  .dz-branches-field__value {
    /* Maui Dark: Gray400 */
    color: #919191;
  }
}

.dz-branches-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 12px 0;
}

.dz-branches-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  border: 0;
  border-radius: 16px;
  background: var(--dz-primary);
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* Map-app chooser (parity with Android system picker) */
.dz-branches-map-backdrop {
  z-index: 80;
}

.dz-branches-map-sheet {
  position: fixed;
  left: 50%;
  /* Sit above floating tab bar (host ~30px + bar + safe-area); match fade clearance. */
  bottom: calc(108px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 400px);
  padding: 18px 16px 14px;
  border-radius: 18px;
  background: var(--dz-surface, #fff);
  color: var(--dz-text, #1a1028);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  box-sizing: border-box;
  z-index: 81;
}

@media (min-width: 900px) {
  .dz-branches-map-sheet {
    bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }
}

.dz-branches-map-sheet__title {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.dz-branches-map-sheet__lead {
  margin: 0 0 14px;
  font-size: 0.85rem;
  opacity: 0.75;
  text-align: center;
}

.dz-branches-map-sheet__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dz-branches-map-sheet__item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--dz-primary, #350066) 10%, transparent);
  color: var(--dz-primary, #350066);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
}

.dz-branches-map-sheet__cancel {
  width: 100%;
  margin-top: 12px;
}

.dz-branches-action .dz-ico {
  width: 16px;
  height: 16px;
  /* Maui Light: SecondaryDarkText */
  color: #ed24ff;
}

@media (prefers-color-scheme: dark) {
  .dz-branches-action {
    /* Maui Dark: SecondaryDarkText bg */
    background: #ed24ff;
    color: #fff;
  }

  .dz-branches-action .dz-ico {
    /* Maui Dark: Primary #350066 — تیره‌تر از Secondary remapped */
    color: #350066;
  }
}

.dz-branches-action.is-disabled {
  pointer-events: none;
  background: var(--dz-gray-200);
  color: var(--dz-gray-300);
}

.dz-branches-action.is-disabled .dz-ico {
  color: var(--dz-gray-300);
}

@media (prefers-color-scheme: dark) {
  .dz-branches-action.is-disabled {
    background: #333;
    color: #666;
  }

  .dz-branches-action.is-disabled .dz-ico {
    color: #666;
  }
}
