/* ======================================== */
/* Modern CSS Reset (现代 CSS 重置) */
/* ======================================== */
*, *::before, *::after {
    box-sizing: border-box; /* 统一盒模型 */
}

* {
    margin: 0;
    padding: 0;
    font: inherit; /* 继承父元素的字体属性 */
}

/* ======================================== */
/* Dark Mode Styles (深色模式样式) */
/* ======================================== */
body.dark-mode {
    background-color: #121212; /* 深色背景 */
    color: #e0e0e0; /* 浅色文字 */
}

body.dark-mode #search-input {
    background-color: rgba(40, 40, 40, 0.9); /* 搜索框背景 */
    border-color: #444;
    color: #e0e0e0;
}

body.dark-mode #search-input:focus {
    border-color: #66a0ff; /* 焦点状态边框颜色 */
}

body.dark-mode .modal-content {
    background: linear-gradient(135deg, #2d2d2d, #1a1a1a); /* 模态框渐变背景 */
}

body.dark-mode .modal-content h1,
body.dark-mode .modal-content h2,
body.dark-mode .modal-content h3 {
    color: #e0e0e0; /* 标题颜色 */
}

body.dark-mode .modal-content p,
body.dark-mode .modal-content label {
    color: #b0b0b0; /* 段落和标签颜色 */
}

body.dark-mode .quick-access-link {
    background-color: transparent; /* 快速访问链接背景 */
    border-color: transparent; /* 将边框颜色调整为深灰色 */
    box-shadow: none; /* 添加淡白色反光效果 */
}

body.dark-mode .quick-access-link:hover {
    background-color: #3d3d3d;
}

body.dark-mode .quick-access-link .link-title {
    color: #e0e0e0;
}

body.dark-mode .system-link {
    background-color: transparent; /* 系统链接背景 */
    border-color: transparent;
}

body.dark-mode .system-link:hover {
    background-color: #333;
}

body.dark-mode .form-group input {
    background-color: #2d2d2d; /* 表单输入框背景 */
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .form-group input:focus {
    border-color: #66a0ff;
}

body.dark-mode #search-engine,
body.dark-mode .setting-item select {
    background-color: #2d2d2d; /* 下拉选择器背景 */
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .time-display.dark-mode {
    color: #e0e0e0; /* 时间显示颜色 */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

body.dark-mode #cancel-quick-access {
    background-color: #444; /* 取消按钮背景 */
    color: #e0e0e0;
}

body.dark-mode #cancel-quick-access:hover {
    background-color: #555;
}

body.dark-mode .close:hover,
body.dark-mode .close:focus {
    color: #e0e0e0; /* 关闭按钮颜色 */
    background-color: #444;
}

body.dark-mode .setting-item {
    border-bottom-color: #444; /* 设置项底边框颜色 */
}

body.dark-mode .modal-content hr {
    background: linear-gradient(to right, transparent, #444, transparent); /* 分割线颜色 */
}

/* ======================================== */
/* Body and General Styles (全局样式) */
/* ======================================== */
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; /* 优先使用系统UI字体 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh; /* 最小高度为视口高度 */
    background-color: whitesmoke; /* 默认背景色 */
    background-size: cover; /* 背景图片覆盖整个区域 */
    background-position: center;
    background-repeat: no-repeat;
    padding: 20px;
    color: #333; /* 默认文字颜色 */
    line-height: 1.6;
}

/* ======================================== */
/* Time Display (时间显示) */
/* ======================================== */
.time-display {
    font-size: 4em;
    font-weight: bold;
    margin-bottom: 20px;
    color: white; /* 默认白色，适合深色背景 */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); /* 文字阴影增加可读性 */
}

.time-display.black {
    color: black; /* 黑色文字，适合浅色背景 */
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
}

/* ======================================== */
/* General Element Styling (通用元素样式) */
/* ======================================== */
img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
}

input, button, textarea, select {
    outline: none; /* 移除默认的焦点轮廓 */
}

/* ======================================== */
/* Search Container (搜索容器) */
/* ======================================== */
.search-container {
    display: flex;
    margin-bottom: 30px;
    align-items: center;
    width: 100%;
    max-width: 600px;
    gap: 12px;
    justify-content: center;
}

.search-input-container {
    position: relative; /* 用于定位搜索按钮 */
    flex: 1;
    max-width: 500px;
}

#search-input {
    width: 100%;
    padding: 14px 20px;
    padding-right: 100px; /* 为搜索按钮留出空间 */
    border: 1px solid #ddd;
    border-radius: 24px; /* 圆角 */
    font-size: 16px;
    box-sizing: border-box;
    background-color: rgba(255, 255, 255, 0.9); /* 半透明背景 */
    backdrop-filter: blur(10px); /* 毛玻璃效果 */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease; /* 平滑过渡效果 */
}

#search-input:focus {
    border-color: #4285f4; /* Google 蓝色 */
    box-shadow: 0 2px 15px rgba(66, 133, 244, 0.3);
}

#search-button {
    position: absolute; /* 定位在输入框内部 */
    right: 6px;
    top: 6px;
    height: calc(100% - 12px);
    padding: 0 24px;
    border: none;
    background-color: #4285f4;
    color: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    box-sizing: border-box;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#search-button:hover {
    background-color: #3367d6; /* 悬停时颜色变深 */
}

/* ======================================== */
/* Floating Settings Button (悬浮设置按钮) */
/* ======================================== */
.settings-button {
    display: none; /* 默认隐藏 */
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 50px;
    height: 50px;
    border: none;
    background-color: rgba(255, 255, 255, 0.8);
    color: #333;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 100;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.settings-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body.dark-mode .settings-button {
    background-color: rgba(40, 40, 40, 0.8);
    color: #e0e0e0;
}

/* Google Fonts 图标样式 */
.material-symbols-outlined {
  font-variation-settings:
  'FILL' 1,
  'wght' 400,
  'GRAD' 0,
  'opsz' 24
}

/* ======================================== */
/* Modal Styles (模态框通用样式) */
/* ======================================== */
.modal {
    display: none; /* 默认隐藏 */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6); /* 半透明遮罩 */
    backdrop-filter: blur(5px); /* 背景模糊 */
    animation: fadeIn 0.3s ease; /* 淡入动画 */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, #ffffff, #f5f7fa);
    margin: 10% auto;
    padding: 30px;
    border: none;
    width: 90%;
    max-width: 500px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease; /* 滑入动画 */
    position: relative;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ======================================== */
/* Quick Access (快速访问) */
/* ======================================== */
.quick-access-container {
    width: 100%;
    max-width: 800px;
    margin: 20px auto; /* 改为 auto 以实现水平居中 */
    padding: 20px;
}

.quick-access-links {
    display: flex; /* 改为 flex 布局 */
    justify-content: center; /* 水平居中 */
    flex-wrap: wrap; /* 允许换行 */
    gap: 12px;
}

.quick-access-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px;
    background-color: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden; /* 隐藏溢出的内容 */
}

.quick-access-link:hover {
    background-color: #e8eaed;
    transform: translateY(-2px); /* 悬停时轻微上浮 */
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

/* 拖拽悬停时的样式 */
.quick-access-link.drag-over {
    border-style: dashed;
    border-color: #4285f4;
    background-color: #e8f0fe;
}

.quick-access-link .link-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #4285f4; /* 默认图标背景色 */
    color: white;
    font-weight: bold;
    font-size: 24px;
}

.quick-access-link .link-title {
    font-size: 14px;
    color: #333;
    white-space: nowrap; /* 防止标题换行 */
    overflow: hidden;
    text-overflow: ellipsis; /* 超出部分显示省略号 */
    max-width: 100%;
}

/* 快速访问标题样式 */
.quick-access-links.hide-title .link-title {
    display: none;
}

.quick-access-links.hide-title .link-icon {
    margin-bottom: 0;
}

.quick-access-links.title-white .link-title {
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.quick-access-links.title-black .link-title {
    color: #333;
    text-shadow: none;
}

body.dark-mode .quick-access-links.title-white .link-title {
    color: #e0e0e0;
    text-shadow: none;
}

body.dark-mode .quick-access-links.title-black .link-title {
    color: #333;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.3);
}


/* 系统链接（如设置、添加）的特殊样式 */
.system-link {
    border: none;
    background-color: transparent;
}

.system-link:hover {
    background-color: #e6e6e6;
}

/* 设置链接图标的样式 */
.system-link .link-icon .material-symbols-outlined {
    font-size: 24px;
    color: white;
}

/* ======================================== */
/* Modal Form (模态框内表单) */
/* ======================================== */
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: #333;
}

.form-group input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.form-group input:focus {
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1); /* 焦点外发光效果 */
}

.modal-buttons {
    display: flex;
    justify-content: flex-end; /* 按钮靠右对齐 */
    gap: 10px;
    margin-top: 10px;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

#save-quick-access {
    background-color: #4285f4;
    color: white;
}

#save-quick-access:hover {
    background-color: #3367d6;
}

#cancel-quick-access {
    background-color: #f1f3f4;
    color: #333;
}

#cancel-quick-access:hover {
    background-color: #e8eaed;
}

/* 关闭按钮 (×) */
.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 20px;
    right: 25px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close:hover,
.close:focus {
    color: #333;
    background-color: #f0f0f0;
    text-decoration: none;
}

/* ======================================== */
/* Settings Modal Content (设置模态框内容) */
/* ======================================== */
.modal-content h1 {
    color: #202124;
    font-size: 28px;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 500;
}

.modal-content h2 {
    color: #202124;
    font-size: 22px;
    margin: 25px 0 15px;
    font-weight: 500;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 8px;
}

.modal-content h3 {
    color: #5f6368;
    font-size: 18px;
    margin: 20px 0 10px;
    font-weight: 500;
}

.modal-content p {
    color: #5f6368;
    margin: 10px 0;
    font-size: 15px;
}

.modal-content hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, #ddd, transparent); /* 渐变分割线 */
    margin: 25px 0;
}

/* 搜索引擎选择器 */
/* (样式已合并到下方的 .setting-item select 中以保持一致性) */

/* 设置模态框内的通用按钮样式 */
.modal-content button {
    padding: 12px 20px;
    border: none;
    background-color: #4285f4;
    color: white;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    margin-top: 15px;
    width: 100%;
    min-width: auto;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.modal-content button:hover {
    opacity: 0.9;
}

/* 特定按钮的颜色覆盖 */
.modal-content #reset-bg {
    background-color: #ea4335; /* 红色 */
}

.modal-content #todaybingwallpaper {
    background-color: #34a853; /* 绿色 */
}

/* 文件输入框样式 */
.modal-content input[type="file"] {
    margin-top: 10px;
    width: 100%;
    padding: 10px;
    border: 1px dashed #ddd;
    border-radius: 12px;
    background-color: #f8f9fa;
}

/* 设置项容器 */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.setting-item:last-of-type {
    border-bottom: none; /* 最后一项无下边框 */
}

.setting-item label {
    color: #333;
    font-size: 16px;
    flex-grow: 1;
}

/* ======================================== */
/* Toggle Switch (切换开关) */
/* ======================================== */
.toggle-container {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-checkbox {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 26px;
}

.toggle-label:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-checkbox:checked + .toggle-label {
    background-color: #4285f4;
}

.toggle-checkbox:focus + .toggle-label {
    box-shadow: 0 0 1px #4285f4;
}

.toggle-checkbox:checked + .toggle-label:before {
    transform: translateX(24px); /* 开关打开时滑块移动 */
}

.toggle-label:before {
    transition: transform 0.2s ease-in-out;
}

.toggle-label {
    transition: background-color 0.2s ease-in-out;
}

/* 设置项中的下拉选择器 */
.setting-item select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    font-size: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 子设置项，用于缩进 */
.sub-setting {
    margin-left: 20px;
    border-bottom: none;
    padding-top: 5px;
    padding-bottom: 5px;
}

/* ======================================== */
/* Responsive Styles (响应式样式) */
/* ======================================== */

/* 平板设备 (max-width: 768px) */
@media screen and (max-width: 768px) {
    .time-display {
        font-size: 3em;
    }

    body {
        padding: 15px;
    }
    
    .search-container {
        flex-direction: column;
        width: 100%;
        gap: 15px;
    }
    
    .search-input-container {
        width: 100%;
        max-width: 100%;
    }
    
    .modal-content {
        width: 95%;
        padding: 25px 20px;
        margin: 15% auto;
    }
    
    .modal-content button {
        width: 100%;
        min-width: auto;
        margin-bottom: 10px;
    }
    
    .modal-content input[type="file"] {
        width: 100%;
    }
}

/* 移动设备 (max-width: 480px) */
@media screen and (max-width: 480px) {
    .time-display {
        font-size: 2.5em;
    }

    body {
        padding: 10px;
    }
    
    .search-container {
        margin-bottom: 20px;
    }
    
    #search-input {
        padding: 12px 18px;
        padding-right: 90px;
        font-size: 16px;
    }
    
    #search-button {
        padding: 0 20px;
        font-size: 14px;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px 15px;
        margin: 20% auto;
    }
    
    .modal-content h1 {
        font-size: 24px;
    }
    
    .modal-content h2 {
        font-size: 20px;
    }
    
    .modal-content h3 {
        font-size: 17px;
    }
    
    .modal-content p {
        font-size: 14px;
    }
    
    .modal-content button {
        padding: 10px 15px;
        font-size: 14px;
    }
}

/* ======================================== */
/* Context Menu (右键上下文菜单) */
/* ======================================== */
.context-menu {
    display: none;
    position: absolute;
    z-index: 1001;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    min-width: 120px;
    font-size: 14px;
}

.context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.context-menu ul li {
    padding: 10px 16px;
    cursor: pointer;
    color: #333;
    transition: background-color 0.2s ease;
}

.context-menu ul li:hover {
    background-color: #f5f5f5;
}

/* 深色模式下的上下文菜单 */
body.dark-mode .context-menu {
    background-color: #2d2d2d;
    border-color: #444;
}

body.dark-mode .context-menu ul li {
    color: #e0e0e0;
}

body.dark-mode .context-menu ul li:hover {
    background-color: #3d3d3d;
}
