/**
 * Account / profile area — mobile-first responsive shell
 * Loaded globally from base.html (scoped to .cl-account-shell where relevant)
 */

/* —— Safe area + iOS viewport —— */
.cl-account-shell .cl-page {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

.cl-account-shell .cl-page,
.cl-account-shell .cl-page * {
  box-sizing: border-box;
}

.cl-account-shell .cl-page .row > [class*="col-"],
.cl-account-shell .cl-page .card,
.cl-account-shell .cl-page .card-body,
.cl-account-shell .cl-page .btn,
.cl-account-shell .cl-page .badge,
.cl-account-shell .cl-page .form-control,
.cl-account-shell .cl-page .form-select,
.cl-account-shell .cl-page .form-check,
.cl-account-shell .cl-page .input-group,
.cl-account-shell .cl-page .table-responsive {
  max-width: 100%;
  min-width: 0;
}

.cl-account-shell .cl-page .text-break,
.cl-account-shell .cl-page .small,
.cl-account-shell .cl-page code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cl-account-shell .cl-page .table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cl-account-shell .cl-page img,
.cl-account-shell .cl-page video,
.cl-account-shell .cl-page canvas,
.cl-account-shell .cl-page svg {
  max-width: 100%;
  height: auto;
}

.cl-account-hub {
  margin-bottom: 1.5rem;
}

/* —— Sticky subnav (thumb-friendly, no sidebar crush) —— */
.cl-account-hub__nav {
  position: sticky;
  /* Header is sticky with safe-area padding; keep subnav flush under it */
  top: calc(var(--cl-header-h, 76px) + env(safe-area-inset-top, 0px));
  z-index: 50;
  margin: 0 0 1.25rem;
  padding: 0.35rem 0 0.5rem;
  background: linear-gradient(
    180deg,
    var(--cl-bg, #f8fafc) 0%,
    var(--cl-bg, #f8fafc) 70%,
    transparent 100%
  );
}

.cl-account-hub__nav-scroll {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding: 0.15rem 0.25rem 0.35rem;
  scrollbar-width: thin;
}

.cl-account-hub__nav-scroll::-webkit-scrollbar {
  height: 4px;
}

.cl-account-hub__nav-scroll::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 4px;
}

.cl-account-hub__nav-link {
  flex: 0 0 auto;
  scroll-snap-align: start;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid var(--cl-border, #e2e8f0);
  color: var(--cl-text-muted, #475569);
  background: var(--cl-surface, #fff);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cl-account-hub__nav-link:hover {
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--cl-navy, #0b1f3a);
  background: rgba(234, 242, 255, 0.6);
}

.cl-account-hub__nav-link:focus-visible {
  outline: 2px solid var(--cl-blue, #2563eb);
  outline-offset: 2px;
}

.cl-account-hub__nav-link.is-active {
  background: var(--cl-sky, #eaf2ff);
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--cl-navy, #0b1f3a);
  font-weight: 700;
}

/* —— Profile / account cards —— */
.cl-account-profile__grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .cl-account-profile__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
}

.cl-account-profile__actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

@media (min-width: 576px) {
  .cl-account-profile__actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .cl-account-profile__actions .btn {
    width: auto;
  }
}

.cl-account-profile__actions .btn {
  width: 100%;
}

@media (min-width: 576px) {
  .cl-account-profile__actions .btn {
    width: auto;
    min-width: 10rem;
  }
}

/* —— My listings (list replaces cramped tables) —— */
.cl-my-listings {
  border-radius: 14px;
  overflow: hidden;
}

.cl-my-listings__item {
  padding: 1rem 1.1rem;
}

.cl-my-listings__row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 576px) {
  .cl-my-listings__row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
  }
}

.cl-my-listings__title {
  font-weight: 600;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.cl-my-listings__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

@media (max-width: 575px) {
  .cl-my-listings__actions {
    justify-content: stretch;
  }

  .cl-my-listings__actions .btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }

  .cl-my-listings__actions form {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }

  .cl-my-listings__actions form .btn {
    width: 100%;
  }
}

/* —— Touch-friendly buttons in account shell —— */
.cl-account-shell .cl-page .btn-sm {
  min-height: 2.75rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

.cl-account-shell .cl-page .btn:not(.btn-sm) {
  min-height: 2.75rem;
}

/* —— Mobile: make top action buttons full-width —— */
@media (max-width: 575px) {
  .cl-account-shell .cl-page .cl-account-actions .btn {
    width: 100%;
  }
}

/* —— Notifications & inbox rows —— */
.cl-account-shell .cl-notif-row,
.cl-account-shell .cl-msg-inbox-row {
  gap: 0.75rem;
}

@media (max-width: 575px) {
  .cl-account-shell .cl-notif-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .cl-account-shell .cl-notif-row .text-end {
    text-align: left !important;
  }

  .cl-account-shell .cl-notif-row .btn {
    width: 100%;
  }

  .cl-account-shell .cl-msg-inbox-row {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .cl-account-shell .cl-msg-inbox-row > span {
    align-self: flex-end;
  }
}

/* —— Message thread —— */
.cl-msg-thread__composer .form-control {
  font-size: 1rem;
}

.cl-msg-thread__composer .btn-primary {
  width: 100%;
}

@media (min-width: 576px) {
  .cl-msg-thread__composer .btn-primary {
    width: auto;
    min-width: 8rem;
  }
}

.cl-msg-thread__bubble {
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* —— Listing image manager (touch + wrap) —— */
.listing-image-manager .cl-listing-img-tile {
  width: 100%;
  max-width: 160px;
  flex: 1 1 calc(50% - 0.35rem);
  min-width: min(140px, 100%);
}

@media (min-width: 576px) {
  .listing-image-manager .cl-listing-img-tile {
    flex: 0 0 140px;
    width: 140px;
    max-width: 140px;
  }
}

.listing-image-manager .cl-listing-img-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  width: 100%;
}

.listing-image-manager .cl-listing-img-actions .btn {
  min-height: 40px;
  font-size: 0.8125rem;
}

/* —— Business dashboard —— */
.cl-biz-dash-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--cl-text-muted, #475569);
  padding: 0.35rem 0;
}

.cl-biz-dash-details summary:focus-visible {
  outline: 2px solid var(--cl-blue, #2563eb);
  outline-offset: 2px;
  border-radius: 8px;
}

.cl-biz-dash-code {
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 0.8125rem;
}

/* —— Listing cards: long location lines —— */
.cl-lcard__loc {
  overflow-wrap: anywhere;
}

.cl-lcard__price {
  flex-wrap: wrap;
}

/* —— Auth/account overflow hardening —— */
.cl-account-shell .cl-account-card-head {
  gap: 0.6rem;
}

.cl-account-shell .cl-account-card-head > :first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cl-account-shell .cl-account-kv-row {
  gap: 0.5rem;
}

.cl-account-shell .cl-account-kv-row > :first-child {
  min-width: 0;
}

.cl-account-shell .js-favorite-dashboard-card {
  min-width: 0;
}

.cl-account-shell .js-favorite-dashboard-card .card-body > .d-flex {
  min-width: 0;
}

.cl-account-shell .js-favorite-dashboard-card h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cl-account-shell .js-favorite-dashboard-card .cl-fav-btn-wrap {
  flex: 0 0 auto;
}

.cl-account-shell .js-favorite-dashboard-toggle {
  color: #64748b;
  border-color: #cbd5e1;
}

.cl-account-shell .js-favorite-dashboard-toggle.is-active {
  color: #e11d48;
  border-color: rgba(225, 29, 72, 0.35);
  background: rgba(225, 29, 72, 0.08);
}

.cl-account-shell .js-favorite-dashboard-toggle.is-active:hover {
  color: #be123c;
  border-color: rgba(190, 18, 60, 0.45);
  background: rgba(225, 29, 72, 0.12);
}

.cl-account-shell .js-favorites-pagination {
  gap: 0.5rem;
}

.cl-account-shell .js-favorites-page-label {
  overflow-wrap: anywhere;
}

.cl-account-danger-actions .btn {
  width: 100%;
}

/* —— Saved searches: dense rows (minimal content, no oversized cards) —— */
.cl-account-shell .cl-saved-searches-list {
  border: 1px solid var(--cl-border, #e2e8f0);
  border-radius: 12px;
  background: var(--cl-surface, #fff);
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.cl-account-shell .cl-saved-searches-list .list-group-item {
  padding: 0.45rem 0.65rem;
  border-color: var(--cl-border, #e2e8f0);
}

.cl-account-shell .cl-saved-searches-list .list-group-item.text-muted {
  padding: 0.55rem 0.65rem;
  font-size: 0.875rem;
}

.cl-account-shell .cl-saved-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem 0.75rem;
}

.cl-account-shell .cl-saved-search-row__main {
  flex: 1 1 200px;
  min-width: 0;
}

.cl-account-shell .cl-saved-search-row__title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--cl-navy, #0b1f3a);
}

.cl-account-shell .cl-saved-search-row__hint {
  font-size: 0.8125rem;
  color: var(--cl-text-muted, #64748b);
}

.cl-account-shell .cl-saved-search-row__meta {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.15rem;
  line-height: 1.35;
}

.cl-account-shell .cl-saved-search-row__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  flex: 1 1 260px;
  justify-content: flex-end;
}

.cl-account-shell .cl-saved-search-alerts-form .form-select-sm {
  min-width: 5.5rem;
  max-width: 7rem;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.cl-account-shell .cl-saved-search-actions .btn {
  white-space: nowrap;
}

@media (max-width: 767.98px) {
  .cl-account-shell .cl-saved-search-row__toolbar {
    justify-content: flex-start;
    flex-basis: 100%;
    padding-top: 0.15rem;
    border-top: 1px dashed rgba(148, 163, 184, 0.45);
    margin-top: 0.15rem;
  }
}

@media (min-width: 576px) {
  .cl-account-danger-actions .btn {
    width: auto;
  }
}

@media (max-width: 767.98px) {
  .cl-account-shell .cl-account-card-head {
    flex-wrap: wrap;
    align-items: stretch !important;
  }

  .cl-account-shell .cl-account-card-head .btn {
    width: 100%;
  }

  .cl-account-shell .cl-account-kv-row {
    flex-wrap: wrap;
  }

  .cl-account-shell .js-favorites-pagination {
    flex-wrap: wrap;
    justify-content: center !important;
  }

  .cl-account-shell .js-favorites-pagination .js-favorites-prev,
  .cl-account-shell .js-favorites-pagination .js-favorites-next {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 0;
    text-align: center;
  }

  .cl-account-shell .js-favorites-pagination .js-favorites-page-label {
    width: 100%;
    text-align: center;
    order: 3;
  }

  .cl-account-shell .modal-dialog {
    max-width: calc(100vw - 1rem);
    margin: 0.5rem auto;
  }
}

@media (max-width: 575.98px) {
  .cl-account-shell .cl-page {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
}
