/**
 * 会员端（前台）移动端增强：安全区、触控、底部导航、全屏弹窗
 * 依赖：Bootstrap 3、Font Awesome
 */

html {
  -webkit-text-size-adjust: 100%;
}

body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* 导航栏：小屏标题缩短由模板 .brand-full / .brand-short 控制 */
.navbar-fixed-top {
  padding-top: env(safe-area-inset-top);
}

.navbar.navbar-white .navbar-brand {
  max-width: calc(100vw - 120px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  line-height: 1.3;
  padding-top: 14px;
  padding-bottom: 14px;
  height: auto;
}

.navbar-toggle {
  min-height: 44px;
  min-width: 44px;
  margin-top: 8px;
  margin-bottom: 8px;
}

@media (max-width: 767px) {
  .navbar.navbar-white #header-navbar > ul.navbar-nav:not(.navbar-right) > li > a {
    min-width: 0;
    width: 100%;
    text-align: left;
    padding-top: 14px;
    padding-bottom: 14px;
    margin: 4px 0;
    font-size: 15px;
  }
  .navbar.navbar-white #header-navbar > ul.navbar-nav:not(.navbar-right) > li > a:after {
    display: none;
  }
  .navbar-nav .open .dropdown-menu > li > a {
    padding-top: 12px;
    padding-bottom: 12px;
    font-size: 15px;
  }
}

/* 大屏隐藏底部 Tab；小屏显示 */
.member-bottom-nav {
  display: none;
}

@media (max-width: 991px) {
  .navbar.navbar-white .member-navbar-user {
    display: none !important;
  }

  .has-member-bottom-bar .content {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  .has-member-bottom-bar .footer {
    margin-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  .member-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    height: 56px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
    justify-content: space-around;
    align-items: stretch;
    overflow: visible;
  }
  .member-bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    color: #64748b;
    font-size: 11px;
    text-decoration: none !important;
    -webkit-tap-highlight-color: transparent;
  }
  .member-bottom-nav__item i {
    font-size: 20px;
    margin-bottom: 2px;
    line-height: 1;
  }
  .member-bottom-nav__item span {
    line-height: 1.2;
  }
  .member-bottom-nav__item.is-active {
    color: #2563eb;
    font-weight: 600;
  }

  /* 已登录第四格「用户」：dropup 一次点开菜单，无独立头像按钮 */
  .member-bottom-nav__user {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    min-width: 0;
  }
  .member-bottom-nav__user > .member-bottom-nav__user-btn.member-bottom-nav__item {
    flex: 1;
    cursor: pointer;
  }
  .member-bottom-nav__user.is-active > .member-bottom-nav__user-btn.member-bottom-nav__item,
  .member-bottom-nav__user.open > .member-bottom-nav__user-btn.member-bottom-nav__item {
    color: #2563eb;
    font-weight: 600;
  }
  /* 自管显隐（不依赖 Bootstrap dropdown 插件，避免页面重复加载 bootstrap.js 时双次 toggle） */
  .member-bottom-nav__user > .dropdown-menu.member-bottom-nav__user-menu {
    display: none;
  }
  .member-bottom-nav__user.open > .dropdown-menu.member-bottom-nav__user-menu {
    display: block;
  }
  .member-bottom-nav__user-menu {
    z-index: 1050;
    margin-bottom: 6px;
    min-width: 200px;
  }
  .member-bottom-nav__user .dropdown-menu > li > a {
    padding-top: 12px;
    padding-bottom: 12px;
    font-size: 15px;
  }
}

@media (min-width: 992px) {
  .has-member-bottom-bar .content {
    padding-bottom: 0;
  }
}

/* 表单：避免 iOS 聚焦时整体缩放，触控区域加大 */
@media (max-width: 767px) {
  input.form-control,
  select.form-control,
  textarea.form-control {
    font-size: 16px !important;
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .btn {
    min-height: 44px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .btn-sm,
  .btn-xs {
    min-height: 40px;
  }
}

/* 查询 / 查寝：分页条换行与按钮加宽 */
@media (max-width: 767px) {
  .pagination-bar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 0 8px;
  }
  .pagination-bar .btn {
    flex: 1;
    min-width: 120px;
  }
  .page-indicator {
    width: 100%;
    text-align: center;
    order: -1;
    font-size: 14px;
  }
  .filter-toolbar-stats {
    flex-direction: column;
    align-items: stretch !important;
  }
  .page-size-selector {
    margin-left: 0 !important;
    justify-content: space-between;
  }
}

/* 弹窗：小屏接近全屏，底部按钮易达 */
@media (max-width: 767px) {
  .modal-member-fs .modal-dialog {
    margin: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  }
  .modal-member-fs .modal-content {
    border-radius: 0;
    border: none;
    min-height: 100%;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: none;
  }
  .modal-member-fs .modal-header {
    flex-shrink: 0;
    padding: 16px 18px;
  }
  .modal-member-fs .modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 18px;
  }
  .modal-member-fs .modal-footer {
    flex-shrink: 0;
    padding: 12px 16px;
    border-top: 1px solid #edf2f7;
    display: flex;
    gap: 10px;
    justify-content: stretch;
  }
  .modal-member-fs .modal-footer .btn {
    flex: 1;
  }
}

/* 查寝：卡片列表仅小屏 */
.dc-card-list {
  display: none;
}
@media (max-width: 767px) {
  .dc-table-wrap.hide-xs-table {
    display: none !important;
  }
  .dc-card-list.show-xs-cards {
    display: block !important;
  }
}

.dc-student-card {
  background: #fff;
  border: 1px solid #eaecf0;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.dc-student-card__top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.dc-student-card__top img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}
.dc-student-card__name {
  font-weight: 600;
  font-size: 16px;
  color: #1e293b;
}
.dc-student-card__meta {
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}
.dc-student-card__meta span {
  display: block;
}
.dc-student-card .btn-edit-row {
  width: 100%;
  margin-top: 10px;
  min-height: 44px;
}

/* 统计页 */
@media (max-width: 767px) {
  .stats-page-wrap {
    margin: 16px auto !important;
    padding: 0 12px !important;
  }
  .metric-card.compact {
    height: auto;
    min-height: 140px;
    padding: 16px;
    margin-bottom: 12px;
  }
  .metric-card .v {
    font-size: 40px !important;
  }
  .dynamic-card {
    height: auto !important;
    min-height: 160px;
    margin-bottom: 16px;
  }
  .dynamic-head,
  .dynamic-row {
    grid-template-columns: 58px 52px 56px 1fr !important;
    font-size: 11px !important;
    gap: 4px !important;
  }
  .dynamic-list-wrap {
    height: 140px !important;
  }
  .chart-box {
    height: 240px !important;
    margin-bottom: 16px;
  }
  .top-block-row .col-md-4,
  .top-block-row .col-md-8 {
    width: 100%;
  }
  .charts-row-primary .col-md-4,
  .charts-row-secondary .col-md-4,
  .charts-row-secondary .col-md-8 {
    width: 100%;
  }
  .project-meta {
    font-size: 14px !important;
  }
}

/* 动态明细页工具栏 */
@media (max-width: 767px) {
  .dynamic-page-wrap .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .dynamic-page-wrap .toolbar .btn {
    width: 100%;
    margin-bottom: 4px;
  }
}

/* 查询页：折叠区按钮 */
.btn-filter-more {
  white-space: nowrap;
}

/* 学生详情弹窗内联布局在窄屏下改纵排 */
@media (max-width: 767px) {
  #detail-content p {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 8px;
  }
  #detail-content [style*="display:flex"] {
    display: block !important;
  }
  #detail-content img[alt="avatar"] {
    display: block;
    width: 100% !important;
    max-width: 200px;
    height: auto !important;
    margin: 0 auto 12px;
  }
}

/* 登录 / 会员中心区块留白 */
@media (max-width: 767px) {
  .user-section {
    margin: 24px 12px 0;
    padding: 16px;
  }
}

/* 统计面板内边距 */
@media (max-width: 767px) {
  .stats-wrap .panel-body {
    padding: 12px !important;
  }
  .stats-wrap .panel-heading .panel-title {
    font-size: 16px;
  }
}
