/* ===== 机构详情页 · 独立样式（按块组织） ===== */

/* --- 页面容器 --- */
#page-institution-detail {
  position: relative;
  background: var(--bg);
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

#page-institution-detail.active {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
}

#page-institution-detail .page-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: transparent;
  backdrop-filter: none;
  border-bottom: none;
  z-index: 20;
}

#page-institution-detail .page-header h1 {
  color: var(--white);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

#page-institution-detail .back-btn {
  background: rgba(255, 255, 255, 0.92);
  border-color: transparent;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.detail-page {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: 16px;
}

.detail-block {
  background: var(--white);
}

.detail-block--section,
.detail-block--gallery,
.detail-block--tabs,
.detail-block + .detail-tab-panel {
  margin-top: 8px;
}

/* --- Block: Hero --- */
.detail-block--hero {
  background: transparent;
  margin-bottom: 0;
}

.detail-hero-cover {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: linear-gradient(165deg, #F5F0EB 0%, #E8E2DC 100%);
}

.detail-hero-cover > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.detail-hero-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, #F5F0EB 0%, #E8E2DC 100%) !important;
  z-index: 0;
}

.detail-hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.1) 0%, transparent 40%, rgba(0, 0, 0, 0.18) 100%);
  pointer-events: none;
  z-index: 2;
}

.bed-pill-large {
  padding: 4px 10px;
  font-size: 12px;
}

.verified-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary-dark);
  border: 1px solid rgba(232, 89, 12, 0.25);
}

/* --- Block: Header（标题 / 操作 / 资质 / 联系） --- */
.detail-block--header {
  position: relative;
  z-index: 5;
  margin-top: -18px;
  padding: 0;
  background: transparent;
}

.detail-header-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px;
  margin-bottom: 10px;
  position: relative;
  z-index: 2;
}

.detail-header-card {
  background: var(--white);
  border-radius: 14px 14px 0 0;
  padding: 16px;
}

.detail-header-main {
  margin-bottom: 4px;
}

.detail-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.45;
  margin: 0 0 6px;
  color: var(--text);
}

.detail-stars {
  font-size: 13px;
  color: var(--text-muted);
}

.detail-action-row {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 8px;
  margin: 14px 0 16px;
}

.btn-outline-sm,
.btn-primary-sm {
  min-width: 0;
  width: 100%;
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--white);
  text-align: center;
}

.btn-outline-sm.active {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
}

.btn-primary-sm {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.detail-qual-block {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 8px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

/* 统一 KV 行：左标签右内容 */
.detail-kv-list {
  display: flex;
  flex-direction: column;
}

.detail-kv-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.detail-kv-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-kv-row__label {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.detail-kv-row__value {
  min-width: 0;
  text-align: left;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.detail-kv-row__value a {
  color: var(--text);
  text-decoration: none;
}

.link-map {
  display: inline;
  margin-left: 6px;
  background: none;
  border: none;
  color: var(--link);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.verified-badge {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 8px;
  border-radius: 4px;
}

/* --- Block: Gallery --- */
.detail-block--gallery {
  padding: 12px 16px;
}

.detail-gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.detail-gallery::-webkit-scrollbar {
  display: none;
}

.gallery-item {
  flex-shrink: 0;
  width: 160px;
  height: 100px;
  border-radius: 8px;
  overflow: hidden;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- Block: Pricing（机构养老 / 喘息） --- */
.detail-block--section {
  padding: 16px;
}

.detail-section-title {
  font-size: 15px;
  font-weight: 600;
  padding-left: 8px;
  border-left: 3px solid var(--primary);
  margin: 0 0 14px;
}

.detail-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 24px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.detail-stats-row--compact {
  gap: 12px 20px;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.detail-stat {
  min-width: 64px;
}

.detail-stat__label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-stat__value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.detail-stat__value.is-green { color: var(--success); }
.detail-stat__value.is-orange { color: var(--warning); }
.detail-stat__value.is-gray { color: var(--text-muted); }

.detail-price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-price-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
}

.detail-price-item--highlight {
  grid-column: 1 / -1;
  background: #FFF9F5;
  border: 1px solid #FFE4CC;
}

.detail-price-item__label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-price-item__value {
  font-size: 16px;
  font-weight: 600;
  color: var(--price);
  line-height: 1.3;
}

.detail-price-item--highlight .detail-price-item__value {
  font-size: 20px;
}

.detail-price-item__unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
}

/* --- Block: Tabs --- */
.detail-block--tabs {
  position: sticky;
  top: 49px;
  z-index: 8;
  border-bottom: 1px solid var(--border);
}

.detail-tabs {
  display: flex;
}

.detail-tab {
  flex: 1;
  padding: 12px 4px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  position: relative;
}

.detail-tab.active {
  color: var(--primary);
  font-weight: 600;
}

.detail-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 2px;
  background: var(--primary);
}

.detail-tab-panel {
  display: none;
  background: var(--white);
}

.detail-tab-panel.active {
  display: block;
}

#tab-care {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 0 12px;
  background: var(--bg);
}

#tab-care .detail-subsection {
  margin: 0 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.detail-info-block {
  background: var(--white);
}

.detail-info-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}

.detail-info-row:last-child {
  border-bottom: none;
}

.detail-info-row__label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.detail-info-row__text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}

.detail-subsection {
  margin: 0;
  padding: 16px;
  background: var(--white);
}

.detail-subsection:last-child {
  margin-bottom: 0;
}

.detail-subsection__title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.verified-tag {
  font-size: 10px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-style: normal;
  margin-left: auto;
}

.capability-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cap-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
}

.cap-item.yes {
  background: #ECFDF5;
  color: var(--success);
  font-weight: 500;
}

.cap-item.no {
  background: var(--bg);
  color: var(--text-muted);
}

.detail-info-rows {
  display: flex;
  flex-direction: column;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row span {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.info-row strong {
  text-align: right;
  font-weight: 500;
}

.info-row strong.green { color: var(--success); }
.info-row strong.red { color: var(--danger); }

.price-table {
  margin-bottom: 8px;
}

.price-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.price-row span {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.price-row strong {
  text-align: right;
}

.price-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0 0;
}

.fee-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.fee-list-head,
.fee-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-light);
}

.fee-list-head {
  padding-top: 0;
  padding-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom-color: var(--border);
}

.fee-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.fee-item__main {
  flex: 1;
  min-width: 0;
}

.fee-item__name {
  display: block;
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

.fee-item__desc {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.fee-item__amount {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--price);
  white-space: nowrap;
}

.fee-item__amount small {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 1px;
}

/* --- 详情页底栏（独立于滚动内容） --- */
.detail-page-footer {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 100;
  width: 100%;
  max-width: 430px;
  box-sizing: border-box;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--white);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}

.detail-page-footer.is-visible {
  display: grid;
}

.detail-footer-btn {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.3;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
}

.detail-footer-btn--ghost {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}

.detail-footer-btn--primary {
  background: var(--primary);
  border: none;
  color: var(--white);
  font-weight: 600;
}
