/* 根变量：定义全局样式变量 */
:root {
  --purple: #8a2be2; /* 紫色主题 */
  --glass-bg: rgba(255, 255, 255, 0.08); /* 毛玻璃背景 */
  --glass-border: rgba(255, 255, 255, 0.12); /* 毛玻璃边框 */
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3); /* 阴影效果 */
  --font: 'Segoe UI', system-ui, sans-serif; /* 字体 */
}

/* 全局样式：清除默认样式 */
* {
  box-sizing: border-box; /* 包含边框和内边距在元素的总宽度和高度内 */
  margin: 0; /* 外边距重置 */
  padding: 0; /* 内边距重置 */
}

/* 主体样式：设置页面整体外观 */
body {
  margin: 0; /* 外边距重置 */
  padding: 20px; /* 内边距 */
  font-family: var(--font); /* 使用变量定义的字体 */
  background: linear-gradient(135deg, #0f0524 0%, #2a0845 50%, #4a148c 100%); /* 渐变背景 */
  animation: galaxyFlow 20s ease infinite; /* 背景动画 */
  color: #fff; /* 文字颜色 */
  display: flex; /* 使用弹性布局 */
  align-items: center; /* 垂直居中对齐 */
  justify-content: center; /* 水平居中对齐 */
  min-height: 100vh; /* 设置最小高度为视窗高度的100% */
  min-width: 500vm;
}

/* 背景动画：定义背景渐变动画 */
@keyframes galaxyFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 毛玻璃效果：为卡片添加毛玻璃样式 */
.glass-card {
  background: var(--glass-bg); /* 使用变量定义的毛玻璃背景 */
  backdrop-filter: blur(12px); /* 模糊效果 */
  border-radius: 24px; /* 圆角 */
  border: 1px solid var(--glass-border); /* 使用变量定义的边框 */
  box-shadow: var(--shadow), inset 0 0 12px rgba(255, 255, 255, 0.05); /* 使用变量定义的阴影 */
  padding: 20px; /* 内边距 */
  width: 100%; /* 宽度设置为屏幕宽度的一半 */
  max-width: 800px; /* 最大宽度限制 */
  min-width: 320px; /* 最小宽度限制 */
  display: flex; /* 使用弹性布局 */
  flex-direction: column; /* 按列排列子元素 */
  gap: 30px; /* 子元素之间的间距 */
}

/* 粒子背景：设置粒子背景的样式 */
#particles-js {
  position: fixed; /* 固定定位 */
  inset: 0; /* 覆盖整个视窗 */
  z-index: -1; /* 置于最底层 */
}

.container {
  width: 100%;
  min-width: 1000px;
  height: 100%;
  min-height: 580px;
  text-align: center;
  position: relative;
  z-index: 1;
  margin-top: -180px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.search-container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 3.5rem 4rem;
  border-radius: 30px;
  width: 100%;
  max-width: 900px;
  text-align: center;
  z-index: 2;
  margin: 0 auto 30px;
  position: relative;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.2),
    inset 0 2px 4px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: cardFloat 3s ease-in-out infinite;
}

@keyframes cardFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.search-container::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 30px;
  padding: 2px;
  background: linear-gradient(
    135deg,
    rgba(255, 0, 200, 0.5),
    rgba(0, 255, 255, 0.5)
  );
  -webkit-mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.3;
}

.search-container::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 30px;
  background: linear-gradient(180deg, 
    rgba(255, 255, 255, 0.3), 
    rgba(255, 255, 255, 0.1)
  );
  z-index: -1;
  filter: blur(1px);
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.serarch-form {
    position: relative;
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    padding: 18px 35px;
    padding-right: 100px;
    border: none;
    border-radius: 20px;
    font-size: 17px;
    outline: none;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.search-input:focus {
  background: white;
  box-shadow: 
    0 6px 20px rgba(0, 0, 0, 0.15),
    inset 0 2px 4px rgba(255, 255, 255, 0.5);
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    height: 38px;
    min-width: 90px;
    padding: 0 15px;
    border: none;
    border-radius: 18px;
    background: var(--purple);
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-items: center;
    line-height: 1;
}

.search-btn:hover {
    background: #7b1fa2;
    transform: translateY(-50%) scale(1.05);
}

@media (max-width: 480px) {
    .search-input {
        padding-right: 90px;
    }

    .search-btn {
        min-width: 80px;
        font-size: 14px;
    }
}

.engine-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.engine-tab {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.engine-tab.active {
    background: var(--purple);
    font-weight: 500;
}

.weather-container {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    padding: 15px 25px;
    border-radius: 20px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 3;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
    cursor: pointer;
}

.weather-container:hover {
    transform: scale(1.05);
    background: rgba(0, 0, 0, 0.25);
}

.city-select {
    position: fixed;
    top: 90px;
    right: 20px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 15px;
    color: white;
    z-index: 3;
    display: none;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15),
                inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.city-select.show {
    display: flex;
}

.city-option {
    padding: 8px 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.city-option:hover {
    background: rgba(255, 255, 255, 0.2);
}

.city-search {
    padding: 8px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
    outline: none;
}

.time-block {
  text-align: center;
}

.time {
  font-size: 2.8rem;
  font-weight: 300;
  letter-spacing: 2px;
}

.date {
  font-size: 1.2rem;
  opacity: 0.85;
  margin-top: 4px;
  margin-bottom: 20px; /* 增加日期与搜索引擎之间的间距 */
}

.bookmarks {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.add-bookmark {
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-bookmark:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.icon-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.icon-preview {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.icon-select {
    position: relative;
    width: 100%;
}

.selected-icon {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-sizing: border-box;
    color: #333;
}

.selected-icon:hover {
    background: white;
}

.icon-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    padding: 10px;
    z-index: 1004;
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
    margin-top: 5px;
}

.icon-options.show {
    display: grid;
}

.icon-option {
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-radius: 8px;
    color: #333;
    transition: all 0.2s ease;
}

.icon-option:hover {
    background: rgba(33, 150, 243, 0.1);
    color: #2196f3;
}

.icon-option i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.bookmark-list {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.bookmark-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 12px 20px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    text-decoration: none;
    transition: all 0.3s ease;
}

.bookmark-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.bookmark-item i {
    margin-right: 12px;
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.bookmark-item span {
    font-size: 14px;
}

.bookmark-delete {
    position: absolute;
    right: -8px;
    top: -8px;
    width: 24px;
    height: 24px;
    background: #ff4757;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s;
}

.bookmark-item:hover .bookmark-delete {
    opacity: 1;
}

.bookmark-delete i {
    color: white;
    font-size: 12px;
    margin: 0;
}

/* 删除动画 */
.bookmark-item.removing {
    transform: scale(0.9);
    opacity: 0;
}

/* 错误提示 */
.input-error {
    color: #ff4757;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.bookmark-modal {
    display: none;
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    padding: 35px 40px;
    border-radius: 20px;
    color: white;
    z-index: 1001;
    max-width: 480px;
    width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.modal-title {
    text-align: center;
    font-size: 24px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
    margin: 0 0 30px 0;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 8px;
    font-size: 18px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.modal-body {
    padding: 0 10px;
}

.input-group {
    margin-bottom: 15px;
    width: 100%;
}

.input-group:nth-child(2) {
    margin-bottom: 10px;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 14px;
    color: #333;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.input-group input:focus {
    background: white;
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

.input-error {
    display: block;
    color: #ff4d4f;
    font-size: 12px;
    margin-top: 5px;
    min-height: 18px;
}

.modal-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.bookmark-modal-button {
    padding: 10px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.bookmark-modal-button.cancel {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.bookmark-modal-button.cancel:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.bookmark-modal-button.save {
    background: #2196f3;
    color: white;
    border: none;
}

.bookmark-modal-button.save:hover {
    background: #1976d2;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .search-btn {
        padding: 0 20px;
        font-size: 15px;
    }

    .search-container {
        padding: 2.5rem 2rem;
        width: 92%;
    }

    .time {
        font-size: 4rem;
    }

    .date {
        font-size: 1.2rem;
        margin-bottom: 2rem;
    }

    .search-box {
        width: 100%;
    }

    .search-input {
        width: calc(100% - 100px);
        padding: 15px 20px;
        font-size: 15px;
    }

    .search-btn {
        padding: 15px 20px;
        font-size: 15px;
        right: 5px;
    }

    .weather-container {
        padding: 10px 15px;
        font-size: 14px;
        top: 15px;
        right: 15px;
    }

     .bookmark-delete {
        opacity: 1 !important;
    }
    
    .bookmark-item {
        padding: 10px 15px;
    }
}

@media (max-width: 480px) {
    .search-container {
        padding: 2rem 1.5rem;
    }

    .time {
        font-size: 3.5rem;
    }

    .search-input {
        width: calc(100% - 80px);
        padding: 15px 25px;
    }

    .search-btn {
        padding: 10px 24px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .bookmark-modal {
        padding: 20px;
    }

    .icon-options {
        grid-template-columns: 1fr;
    }
}