/**
 * 小组件容器样式
 * 参考导航网格容器的高度和配色
 * 适配全局主题CSS变量
 */

/* 小组件容器 */
.widget-container {
    width: 100%;
    margin: 12px 0;
    padding: 0 8px;
    background: var(--bg-primary);
    border-top: 1px solid var(--bg-border);
    border-bottom: 1px solid var(--bg-border);
    border-left: none;
    border-right: none;
    border-radius: 0;
    backdrop-filter: var(--blur-enabled, blur(10px));
    -webkit-backdrop-filter: var(--blur-enabled, blur(10px));
    box-shadow: none;
}

/* 极简模式样式 */
body.minimal-style .widget-container {
    background: var(--bg-primary);
    border-top: 1px solid var(--bg-border);
    border-bottom: 1px solid var(--bg-border);
    border-left: none;
    border-right: none;
    box-shadow: none;
}

/* 小组件包装器 - 单行居中排列 */
.widget-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 12px 0;
    min-height: 150px; /* 确保容器有最小高度 */
}

/* 分类显示模式下的widget-wrapper - 强制保持容器高度 */
.widget-wrapper:has(.category-display-mode) {
    min-height: 174px; /* 150px(小组件高度) + 12px*2(padding) = 174px */
    align-items: stretch; /* 让子元素拉伸 */
    padding: 12px 0; /* 保持相同的垂直padding */
}

/* 单个小组件 */
.widget-item {
    background: transparent;
    border: 1px solid var(--bg-border);
    border-radius: var(--border-radius);
    padding: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 200px;
    height: 150px; /* 增加高度适应4行布局 */
    cursor: move;
    transition: all var(--transition-fast);
    user-select: none;
    -webkit-user-select: none;
}

/* 拖动状态 */
.widget-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    z-index: 1000;
}

/* 拖动悬停状态 */
.widget-item.drag-over {
    border-color: var(--link-color);
    transform: scale(1.02);
}

/* 极简模式样式 */
body.minimal-style .widget-item {
    background: transparent;
    border-color: var(--bg-border);
    box-shadow: none;
    cursor: move;
    transition: all var(--transition-fast);
    user-select: none;
    -webkit-user-select: none;
}

/* 极简模式拖动状态 */
body.minimal-style .widget-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    z-index: 1000;
}

/* 小牛搜索小组件特殊样式 */
.xiaoniu-search-widget .widget-content {
    flex: 1;
    padding: 0px;
    overflow: hidden;
}

/* 极简模式拖动悬停状态 */
body.minimal-style .widget-item.drag-over {
    border-color: var(--link-color);
    transform: scale(1.02);
}

/* 小组件标题 */
.widget-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color) !important;
    margin: 0;
    text-align: center;
    letter-spacing: 0.5px;
    padding: 8px 0;
    border-bottom: 1px solid var(--bg-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: transparent;
    border-radius: calc(var(--border-radius) - 1px) calc(var(--border-radius) - 1px) 0 0;
}

/* 小组件内容区 - 统一高度和对齐 */
.widget-content {
    flex: 1;
    padding: 0px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* 改为顶部对齐 */
    overflow: hidden;
    height: calc(100% - 33px); /* 减去标题高度 */
}

/* 加载文本 */
.loading-text {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    padding: 20px 0;
}

/* 移除可能冲突的全局样式，只保留组件内样式 */

/* 统一的小组件内部布局样式 - 确保每行都在同一水平线 */
.calendar-content-wrapper,
.clock-content-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    justify-content: flex-start; /* 顶部对齐 */
}

/* 统一的行高和位置 - 第1行 */
.calendar-content-wrapper .calendar-date,
.clock-content-wrapper .clock-time {
    height: 32px; /* 固定行高 */
    line-height: 32px; /* 垂直居中 */
    font-size: 16px;
    color: var(--text-color);
    font-weight: 600;
    text-align: center;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 时钟字体特殊处理 - 保持同样大小 */
.clock-content-wrapper .clock-time {
    font-family: 'Courier New', monospace;
    font-size: 20px; /* 与日历日期同样大小 */
}

/* 统一的行高和位置 - 第2行 */
.calendar-content-wrapper .calendar-week,
.clock-content-wrapper .clock-countdown {
    height: 20px; /* 固定行高 */
    line-height: 20px; /* 垂直居中 */
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 统一的行高和位置 - 第3行 */
.calendar-content-wrapper .calendar-festival,
.clock-content-wrapper .clock-stopwatch {
    height: 18px; /* 固定行高 */
    line-height: 18px; /* 垂直居中 */
    font-size: 10px;
    color: var(--link-color);
    text-align: center;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 统一的行高和位置 - 第4行 */
.calendar-content-wrapper .calendar-reminder,
.clock-content-wrapper .clock-alarms {
    height: 18px; /* 固定行高 */
    line-height: 18px; /* 垂直居中 */
    font-size: 10px;
    color: var(--warning-color);
    text-align: center;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 移除重复的颜色定义 - 已在上面的详细样式中定义 */

/* 响应式设计 */
@media (max-width: 768px) {
    .widget-container {
        padding: 0 4px;
        margin: 8px 0;
    }
    
    .widget-wrapper {
        gap: 12px;
    }
    
    .widget-item {
        width: 180px;
        height: 150px; /* 增加高度适应4行布局 */
    }
    
    .widget-title {
        font-size: 12px;
        padding: 6px 0;
    }
    
    /* 移动端统一样式 - 保持行高一致 */
    .calendar-content-wrapper .calendar-date,
    .clock-content-wrapper .clock-time {
        font-size: 12px;
        height: 28px;
        line-height: 28px;
    }
    
    .calendar-content-wrapper .calendar-week,
    .clock-content-wrapper .clock-countdown {
        font-size: 10px;
        height: 18px;
        line-height: 18px;
    }
    
    .calendar-content-wrapper .calendar-festival,
    .clock-content-wrapper .clock-stopwatch {
        font-size: 9px;
        height: 16px;
        line-height: 16px;
    }
    
    .calendar-content-wrapper .calendar-reminder,
    .clock-content-wrapper .clock-alarms {
        font-size: 9px;
        height: 16px;
        line-height: 16px;
    }
}

@media (max-width: 480px) {
    .widget-wrapper {
        gap: 8px;
        padding: 0 4px;
    }
    
    .widget-item {
        width: 160px;
        height: 140px; /* 保持高度一致 */
    }
    
    .widget-title {
        font-size: 11px;
        padding: 5px 0;
    }
    
    .widget-content {
        padding: 0px;
    }
}

/* 确保小屏幕下不会换行 */
@media (max-width: 380px) {
    .widget-wrapper {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 4px;
    }
    
    .widget-wrapper::-webkit-scrollbar {
        height: 4px;
    }
    
    .widget-wrapper::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .widget-wrapper::-webkit-scrollbar-thumb {
        background: var(--bg-border);
        border-radius: 2px;
    }
}

/* 分类显示模式样式 - 复用导航容器样式 */
.category-display-mode {
    background: var(--bg-primary);
    border: 1px solid var(--bg-border);
    border-radius: var(--border-radius);
    padding: 0px;
    backdrop-filter: var(--blur-enabled, blur(10px));
    -webkit-backdrop-filter: var(--blur-enabled, blur(10px));
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 150px; /* 与小组件高度完全一致 */
    min-height: 150px;
    max-height: 150px;
    margin: 0; /* 重置margin，通过JavaScript控制marginLeft */
}

/* 分类显示模式下的样式继承导航容器 */
.category-display-mode .category-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color) !important;
    margin: 0 0 0px 0;
    text-align: center;
    letter-spacing: 0.5px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--bg-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-display-mode .nav-links-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-border) transparent;
}

.category-display-mode .nav-links-grid::-webkit-scrollbar {
    width: 6px;
}

.category-display-mode .nav-links-grid::-webkit-scrollbar-track {
    background: transparent;
}

.category-display-mode .nav-links-grid::-webkit-scrollbar-thumb {
    background: var(--bg-border);
    border-radius: 3px;
}

.category-display-mode .nav-links-grid::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 极简模式 */
body.minimal-style .category-display-mode {
    background: var(--bg-primary);
    border-color: var(--bg-border);
    box-shadow: none;
}







/* 数据账户按钮样式 - 重置为文字样式 */
.widget-btn {
    padding: 0;
    font-size: 9px;
    font-weight: normal;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: color var(--transition-fast);
    text-decoration: none;
    display: inline;
    align-items: unset;
    justify-content: unset;
    min-height: unset;
    width: auto;
    box-sizing: unset;
    background: transparent;
    color: var(--text-color);
}

.widget-btn.primary {
    background: transparent;
    color: var(--link-color);
    font-weight: bold;
}

.widget-btn.primary:hover {
    color: var(--link-hover);
    background: transparent;
}

.widget-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
}

.widget-btn.secondary:hover {
    background: transparent;
    color: var(--text-color);
}

.widget-btn.success {
    background: transparent;
    color: var(--success-color);
    font-weight: bold;
}

.widget-btn.success:hover {
    background: transparent;
    color: var(--success-color);
}

/* 关闭按钮样式 - 与数据账户面板保持一致 */
.close-panel-btn {
    position: absolute;
    right: -40px;                    /* 精确定位到组件右侧 */
    top: 50%;
    transform: translateY(-50%);
    width: 40px;                      /* 合适的点击区域 */
    height: 80px;
    background: var(--theme-background-layer3, var(--bg-primary));  /* 跟随主题 */
    border: 1px solid var(--theme-border-layer3, var(--bg-border));
    writing-mode: vertical-rl;        /* 垂直文字排列 */
    text-orientation: mixed;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 8px 8px 0;
    color: var(--theme-text-color, var(--text-color));   /* 主题适配文字颜色 */
    font-size: 14px;
    transition: all 0.3s ease;      /* 平滑过渡效果 */
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.close-panel-btn:hover {
    background: var(--theme-hover-bg, var(--hover-bg)); /* 悬停效果 */
    transform: translateY(-50%) scale(1.05);
    color: var(--theme-text-color, var(--text-color));
}

/* 主题预设按钮容器样式 */
.widget-preset-buttons {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 3px !important;
    flex: 1 !important;
    align-content: start !important;
}

/* 主题预设小组件按钮样式 */
.widget-preset-btn {
    font-size: 9px !important;
    padding: 3px 2px !important;
    border: 1px solid var(--bg-border) !important;
    border-radius: 3px !important;
    background: var(--bg-primary) !important;
    color: var(--text-color) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    line-height: 1.1 !important;
    text-align: center !important;
    position: relative;
    overflow: hidden;
}

.widget-preset-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.widget-preset-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* 活跃的预设按钮状态 */
.widget-preset-btn.active {
    background: var(--active-bg) !important;
    color: var(--active-text-color) !important;
    border-color: var(--link-color) !important;
}

.widget-preset-btn.active:hover {
    background: var(--hover-bg) !important;
    color: var(--link-color) !important;
}

/* 主题模式按钮样式 */
.widget-mode-btn {
    flex: 1 !important;
    font-size: 8px !important;
    padding: 4px 2px !important;
    border: 1px solid var(--bg-border) !important;
    border-radius: 3px !important;
    background: var(--bg-primary) !important;
    color: var(--text-color) !important;
    cursor: pointer !important;
    transition: all var(--transition-fast) !important;
}

.widget-mode-btn:hover {
    background: var(--hover-bg);
    border-color: var(--link-color);
    transform: translateY(-1px);
}

/* 日夜间模式按钮样式 */
.widget-daynight-btn {
    flex: 1 !important;
    font-size: 7px !important;
    padding: 3px 1px !important;
    border: 1px solid var(--bg-border) !important;
    border-radius: 3px !important;
    background: var(--bg-primary) !important;
    color: var(--text-color) !important;
    cursor: pointer !important;
    transition: all var(--transition-fast) !important;
}

.widget-daynight-btn:hover {
    background: var(--hover-bg);
    border-color: var(--link-color);
    transform: translateY(-1px);
}

/* 装饰层按钮样式 */
.widget-decoration-btn {
    flex: 1 !important;
    padding: 4px 2px !important;
    border: 1px solid var(--bg-border) !important;
    border-radius: 3px !important;
    background: var(--bg-primary) !important;
    color: var(--text-color) !important;
    font-size: 7px !important;
    cursor: pointer !important;
    transition: all var(--transition-fast) !important;
}

.widget-decoration-btn:hover {
    background: var(--hover-bg);
    border-color: var(--link-color);
    transform: translateY(-1px);
}

/* 壁纸按钮样式 */
.widget-wallpaper-btn {
    flex: 1 !important;
    padding: 6px 4px !important;
    border: 1px solid var(--bg-border) !important;
    border-radius: 3px !important;
    background: var(--bg-primary) !important;
    color: var(--text-color) !important;
    font-size: 8px !important;
    cursor: pointer !important;
    font-weight: bold !important;
    transition: all var(--transition-fast) !important;
}

.widget-wallpaper-btn:hover {
    background: var(--hover-bg) !important;
    border-color: var(--link-color) !important;
    color: var(--text-color) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* 通用按钮效果 */
.widget-mode-btn:active,
.widget-daynight-btn:active,
.widget-decoration-btn:active,
.widget-wallpaper-btn:active {
    transform: translateY(0);
}

/* 关闭面板按钮样式 */
.widget-close-btn {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--bg-border) !important;
    color: var(--text-secondary) !important;
    cursor: pointer !important;
    font-size: 9px !important;
    line-height: 1.2 !important;
    padding: 8px 2px !important;
    border-radius: 3px !important;
    opacity: 0.9 !important;
    white-space: nowrap !important;
    box-shadow: var(--shadow-sm) !important;
    writing-mode: vertical-rl !important;
    text-orientation: mixed !important;
    transition: all var(--transition-fast) !important;
}

.widget-close-btn:hover {
    background: var(--hover-bg) !important;
    border-color: var(--link-color) !important;
    color: var(--text-color) !important;
    transform: translateY(-1px) !important;
}

.widget-close-btn:active {
    transform: translateY(0) !important;
}

/* 壁纸管理组件样式 */
.widget-wallpaper-container {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    padding: 4px !important;
    gap: 6px !important;
}

.widget-wallpaper-form {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
}

.widget-wallpaper-label {
    font-size: 6px !important;
    color: var(--text-color) !important;
    margin-bottom: 1px !important;
    line-height: 1 !important;
}

.widget-wallpaper-input {
    flex: 1 !important;
    font-size: 8px !important;
    padding: 3px 4px !important;
    border: 1px solid var(--bg-border) !important;
    border-radius: 3px !important;
    background: var(--bg-primary) !important;
    color: var(--text-color) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    transition: all var(--transition-fast) !important;
    height: 20px !important;
    min-height: 20px !important;
}

.widget-wallpaper-input:focus {
    border-color: var(--link-color) !important;
    box-shadow: var(--focus-shadow) !important;
}

.widget-wallpaper-input::placeholder {
    color: var(--text-tertiary) !important;
}

.widget-wallpaper-actions {
    display: flex !important;
    gap: 4px !important;
}

.widget-wallpaper-upload {
    display: flex !important;
    gap: 4px !important;
}

.widget-wallpaper-btn.upload-btn {
    background: var(--bg-secondary) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--bg-border) !important;
    transition: all var(--transition-fast) !important;
}

.widget-wallpaper-btn.upload-btn:hover {
    background: var(--accent-bg) !important;
    border-color: var(--accent-color) !important;
    color: var(--accent-color) !important;
}

/* 数据账户小组件样式 */
.widget-data-account-container {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    padding: 4px !important;
    gap: 4px !important;
}

.widget-data-account-status {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    margin-bottom: 4px !important;
}

.data-account-summary {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 3px 6px !important;
    background: var(--bg-secondary) !important;
    border: 1px solid var(--bg-border) !important;
    border-radius: 3px !important;
}

.account-info {
    display: flex !important;
    align-items: center !important;
}

.account-status-text {
    font-size: 8px !important;
    color: var(--text-color) !important;
    font-weight: 500 !important;
}

.widget-data-account-actions {
    display: flex !important;
    justify-content: center !important;
}

.widget-data-account-btn {
    font-size: 8px !important;
    padding: 4px 8px !important;
    border: 1px solid var(--bg-border) !important;
    border-radius: 3px !important;
    background: var(--bg-primary) !important;
    color: var(--text-color) !important;
    cursor: pointer !important;
    transition: all var(--transition-fast) !important;
}

.widget-data-account-btn:hover {
    background: var(--accent-bg) !important;
    border-color: var(--accent-color) !important;
    color: var(--accent-color) !important;
}

