/* 搜索框样式 - Google 风格多引擎搜索栏 */
.search-container {
  text-align: center;
  margin: 24px auto 0;
  width: 600px;
}

.search-box {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 42px;
  /* 用 box-shadow 模拟边框避免抖动 */
  border-radius: 10px;
  background-color: #fff;
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.2);
  overflow: visible;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  border: 1px solid transparent; /* 预留位防止抖动 */
}

/* 聚焦状态：模拟谷歌搜索框聚焦的发光感 */
.search-box:focus-within {
  box-shadow: 0 1px 8px rgba(66, 133, 244, 0.3), 0 0 0 1px rgba(66, 133, 244, 0.1);
}

/* 搜索引擎图标 */
.search-box .icon {
  width: 40px;
  height: 100%;
  flex-shrink: 0;
  background-color: #fff;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 10px 0 0 10px;
}

/* 搜索输入框 */
.search-box input[type='text'] {
  flex: 1;
  height: 100%;
  padding: 0 15px;
  border: none;
  outline: none;
  background-color: #fff;
  color: #333;
  font-size: 14px;
  font-family: inherit;
}

.search-box input[type='text']::placeholder {
  color: #999;
}

/* 搜索引擎下拉选择 */
.search-box .select-wrapper {
  position: relative;
  display: inline-block;
  height: 100%;
  width: 80px;
  flex-shrink: 0;
}

.search-box select {
  height: 100%;
  padding: 0 20px 0 0;
  border: none;
  border-left: 1.5px solid #e0e0e0;
  border-right: 1.5px solid #e0e0e0;
  outline: none;
  background-color: #fff;
  cursor: pointer;
  color: #333;
  font-size: 14px;
  font-family: inherit;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 80px;
  text-align: center;
  text-align-last: center;
  box-sizing: border-box;
}

.search-box .select-wrapper::after {
  content: '▼';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #555;
  pointer-events: none;
}

/* 按钮主体 - 默认简单样式（IE11兼容） */
.search-box button {
  height: 100%;
  padding: 0 28px;
  border: none;
  outline: none;
  background-color: var(--color-primary);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  border-radius: 0 10px 10px 0;
}

.search-box button:hover {
  background-color: var(--color-primary-hover);
}

/* 支持现代浏览器的流光效果 */
@supports (background: conic-gradient(from 0deg, red, blue)) {
  .search-box button {
    background-color: transparent;
  }

  /* 按钮底层：360度旋转流光 */
  .search-box button::before {
    content: '';
    position: absolute;
    inset: -1.5px;
    border-radius: 0 10px 10px 0;
    background: conic-gradient(
      #4285f4, #ea4335, #fbbc05, #34a853, #4285f4
    );
    z-index: -2;
    animation: google-spin-fallback 4s linear infinite;
    filter: blur(0.3px);
  }

  /* 按钮中层：应用谷歌标准蓝遮罩 */
  .search-box button::after {
    content: '';
    position: absolute;
    inset: 0;
    /* Google 标准蓝色 */
    background-color: #1a73e8;
    border-radius: 0 10px 10px 0;
    z-index: -1;
    transition: background-color 0.2s ease;
  }

  /* Google 悬停状态：深色阶 */
  .search-box button:hover::after {
    background-color: #1557b0;
  }

  /* 更高级的浏览器使用 @property 优化动画 */
  @supports (--angle: 0deg) {
    @property --angle {
      syntax: '<angle>';
      initial-value: 0deg;
      inherits: false;
    }

    .search-box button::before {
      background: conic-gradient(
        from var(--angle, 0deg),
        #4285f4, #ea4335, #fbbc05, #34a853, #4285f4
      );
      animation: google-spin 4s linear infinite;
    }
  }
}

@keyframes google-spin {
  to { --angle: 360deg; }
}

@keyframes google-spin-fallback {
  to { transform: rotate(360deg); }
}

/* 悬停加速旋转并补 blur（@property 路径会覆盖 filter，此处补上） */
.search-box button:hover::before {
  animation-duration: 0.5s;
  filter: blur(0.3px);
}

/* 错误状态：红色晕染阴影 */
.search-box.error {
  border-color: rgba(234, 67, 53, 0.4);
  box-shadow: 0 1px 8px rgba(234, 67, 53, 0.25), 0 0 0 1px rgba(234, 67, 53, 0.1);
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
