/* 移动端样式 - 小屏幕设备 (<992px) */

@media (max-width: 991.98px) {
  :root {
    --form-padding-top: 16px;
    --form-container-bottom: 5%;
    --form-estimated-height: 120px; /* form 的估算高度：padding(16*2) + 内容高度(约88px，纵向排列) */
    --result-container-gap: 20px; /* result-container 底部与 form-container 顶部之间的间距 */
  }

  /* 生成结果图片容器 - 移动端调整位置和大小，底部与表单容器顶部对齐 */
  .result-container {
    bottom: calc(var(--form-container-bottom) + var(--form-estimated-height) + var(--result-container-gap));
    height: 110px;
  }

  .result-container.interacting {
    bottom: calc(2% + var(--form-estimated-height) + var(--result-container-gap));
  }

  /* 历史记录容器 - 移动端全宽 */
  .history-wrapper {
    width: 100%;
    max-width: 100vw;
    height: 110px;
    padding-right: var(--bs-gutter-x, 1rem); /* 移动端 Bootstrap 默认右边距 */
    padding-bottom: 15px; /* 底部内边距 */
    box-sizing: border-box; /* 确保 padding 包含在高度内 */
    overflow: visible; /* 确保内容不被裁切 */
  }

  /* Swiper wrapper - 移动端左对齐（确保覆盖基础样式） */
  .history-swiper .swiper-wrapper {
    align-items: flex-start !important; /* 左对齐，而不是居中 */
    justify-content: flex-start !important; /* 从左侧开始排列 */
  }

  /* Swiper slide - 移动端响应式控制：只显示最后 3 个 */
  .history-swiper .swiper-slide.history-slide-mobile {
    display: flex;
  }
  
  /* 移动端隐藏超出可见范围的元素 */
  .history-swiper .swiper-slide.history-slide-hidden-mobile {
    display: none !important;
  }

  /* 历史记录项 - 移动端稍微缩小 */
  .history-item {
    width: 80px;
    height: 80px;
    margin: 0 5px 0 0; /* 右侧5px外边距，左侧0 */
  }

  .history-item img {
    width: 80px;
    height: 80px;
    clip-path: circle(40px at center);
  }

  .history-item:hover img {
    clip-path: circle(40px at center);
  }

  /* 表单容器 - 移动端底部位置 */
  .form-container {
    bottom: var(--form-container-bottom);
  }

  .form-container {
    width: calc(100% - 20px);
    max-width: 100%;
  }

  .form-container-inner {
    max-width: 100%;
    padding: 0 10px;
  }

  .form {
    width: 100%;
    max-width: 100%;
  }

  .form-container.interacting {
    bottom: 2%;
  }

  /* 表单布局 - 移动端纵向排列 */
  .form {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 0;
  }

  .form__input-group {
    width: 100%;
    flex: 1;
    min-width: 0;
  }

  .form__input-controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .form__button-group {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
    gap: 8px;
  }

  .form textarea.form-control {
    width: 100%;
    flex: auto;
    min-width: 100%;
    box-sizing: border-box;
  }

  .form button.btn-primary,
  .form button.btn-voice-record {
    flex: 1;
    min-width: 0;
  }

  /* 移动端语音按钮样式（当显示时） */
  .form button.btn-voice-record {
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
  }

  /* 移动端：只有当按钮显示时才应用 flex 布局（不强制显示） */
  .form button.btn-voice-record:not([style*="display: none"]) {
    display: flex;
  }

  .form button.btn-voice-record i {
    flex-shrink: 0;
  }

  .form button.btn-voice-record span {
    display: inline !important;
    font-size: 13px;
  }

  .form-button-actions {
    margin-left: 8px;
  }

  .form-tip {
    font-size: 14px;
    margin-bottom: 6px;
    flex-wrap: nowrap;
    gap: 8px;
    width: 100%;
  }

  .form-tip > span {
    flex: 1;
    min-width: 0;
  }

  .form-button-actions {
    flex-shrink: 0;
  }
  
  /* 移动端侧边栏宽度调整为80% */
  .history-sidebar {
    width: 80%;
    left: -80%;
  }

  .form textarea {
    font-size: 16px; /* 移动端防止自动缩放 */
  }

  /* 移动端：确保语音输入切换按钮始终显示 */
  .voice-input-toggle-btn {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* Logo - 移动端中等尺寸 */
  .logo-container {
    top: 15px;
    left: 15px;
  }

  .logo-img {
    width: 120px; /* 移动端 logo 宽度，放大以适应更好的可见性 */
    height: auto;
  }

  .team-name {
    font-size: 16px;
    letter-spacing: 1px;
  }

  /* 全屏按钮和操作指南按钮 - 移动端调整大小 */
  .fullscreen-btn {
    top: 15px;
    right: 15px;
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .guide-btn {
    top: 15px;
    right: 70px;
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .exit-btn {
    top: 15px;
    right: 125px;
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  /* 操作指南提示框 - 移动端位置调整 */
  .guide-tooltip {
    top: 70px;
    right: 15px;
  }
}

/* 超小屏幕设备 (<576px) */
@media (max-width: 575.98px) {
  :root {
    --form-padding-top: 12px;
    --form-container-bottom: 3%;
    --form-estimated-height: 110px; /* form 的估算高度：padding(12*2) + 内容高度(约86px) */
    --result-container-gap: 15px; /* 超小屏幕间距稍小 */
  }

  .result-container {
    bottom: calc(var(--form-container-bottom) + var(--form-estimated-height) + var(--result-container-gap));
    height: 90px;
  }

  .result-container.interacting {
    bottom: calc(2% + var(--form-estimated-height) + var(--result-container-gap));
  }

  .history-wrapper {
    height: 90px;
    padding-right: var(--bs-gutter-x, 0.75rem); /* 超小屏幕 Bootstrap 默认右边距 */
    padding-bottom: 15px; /* 底部内边距 */
    box-sizing: border-box; /* 确保 padding 包含在高度内 */
    overflow: visible; /* 确保内容不被裁切 */
  }

  .history-item {
    width: 70px;
    height: 70px;
    margin: 0 5px 0 0; /* 右侧5px外边距，左侧0 */
  }

  .history-item img {
    width: 70px;
    height: 70px;
    clip-path: circle(35px at center);
  }

  .history-item:hover img {
    clip-path: circle(35px at center);
  }

  .form-container {
    bottom: var(--form-container-bottom);
    width: calc(100% - 16px);
  }

  .form {
    padding: 12px;
    border-radius: 12px;
  }

  .form-tip {
    font-size: 13px;
  }
  
  /* 超小屏幕侧边栏宽度调整为90% */
  .history-sidebar {
    width: 90%;
    left: -90%;
  }

  /* Swiper wrapper - 超小屏幕左对齐（确保覆盖基础样式） */
  .history-swiper .swiper-wrapper {
    align-items: flex-start !important; /* 左对齐，而不是居中 */
    justify-content: flex-start !important; /* 从左侧开始排列 */
  }

  /* Swiper slide - 超小屏幕无需额外外边距，使用 spaceBetween: 5 参数控制 */

  /* 超小屏幕优化语音按钮，确保显示图标和文字 */
  .form button.btn-voice-record {
    flex: 0 0 auto;      /* 不与"生成图片"平分整行，宽度由内容决定 */
    padding: 8px 12px;
    font-size: 12px;
    min-width: fit-content;
  }

  .form button.btn-voice-record span {
    display: inline !important;  /* 确保文字显示 */
    font-size: 11px;
    white-space: nowrap;
  }

  .form button.btn-voice-record i {
    font-size: 14px;
  }

  /* Logo - 超小屏幕更小尺寸 */
  .logo-container {
    top: 12px;
    left: 12px;
  }

  .logo-img {
    width: 100px; /* 超小屏幕 logo 宽度，放大以提高可见性 */
    height: auto;
  }

  .team-name {
    font-size: 14px;
    letter-spacing: 0.5px;
  }

  /* 全屏按钮 - 移动端调整大小 */
  /* 操作指南提示框 - 移动端适配 */
  .guide-tooltip-content {
    min-width: 280px;
    max-width: 90vw;
    padding: 20px;
  }

  .guide-tooltip-header {
    margin-bottom: 16px;
  }

  .guide-tooltip-header h4 {
    font-size: 18px;
  }

  .guide-item {
    padding: 10px;
    gap: 10px;
  }

  .guide-item i {
    font-size: 18px;
  }

  .guide-item span {
    font-size: 14px;
  }

  .fullscreen-btn {
    top: 15px;
    right: 15px;
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .guide-btn {
    top: 15px;
    right: 70px;
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .guide-tooltip {
    top: 70px;
    right: 15px;
  }
}

