﻿/* 首页专用样式 - 图标统一大小，标题不挤占卡片空间，布局跨度正确且高度撑开，支持右键菜单二级菜单 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.2s, color 0.2s;
    padding-top: 70px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

.datetime-area {
    text-align: center;
    margin-bottom: 2rem;
}

.datetime-time {
    font-size: 3.2rem;
    font-weight: 600;
    letter-spacing: 2px;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.datetime-date {
    font-size: 0.9rem;
    color: var(--text-light);
}

.search-wrapper {
    max-width: 700px;
    margin: 0 auto 2rem;
    position: relative;
}

.search-container {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border-radius: 3rem;
    padding: 0.2rem 0.2rem 0.2rem 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
}

.search-engine-select {
    padding-right: 0.5rem;
    border-right: 1px solid var(--border);
}

.engine-dropdown {
    background: transparent;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    padding: 0.5rem 0.2rem;
}

.search-input {
    flex: 1;
    border: none;
    padding: 0.8rem 0.5rem;
    font-size: 1rem;
    background: transparent;
    color: var(--text);
    outline: none;
}

.search-input::placeholder {
    color: var(--text-light);
    opacity: 0.7;
}

.search-btn {
    background: transparent;
    border: none;
    border-radius: 2.5rem;
    padding: 0.5rem 1.5rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-btn img {
    width: 20px;
    height: 20px;
    filter: invert(38%) sepia(98%) saturate(1548%) hue-rotate(209deg) brightness(96%) contrast(89%);
}

.search-btn:hover {
    color: var(--accent);
    background: rgba(139, 92, 246, 0.08);
}

.dashboard-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
    grid-auto-flow: dense;
    grid-auto-rows: minmax(100px, auto);
}

/* 卡片包装器 */
.dashboard-card-wrapper {
    display: flex;
    flex-direction: column;
    cursor: grab;
}

.dashboard-card-wrapper:active {
    cursor: grabbing;
}

.dashboard-card-wrapper.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* 卡片本身 */
.dashboard-item {
    background: var(--card-bg);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    flex: 1;
}

/* 1:1 布局强制正方形 */
.dashboard-card-wrapper.layout-1_1 .dashboard-item {
    aspect-ratio: 1 / 1;
}

.dashboard-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--accent);
}

/* 卡片内部容器（非小部件） */
.link-url, .tool-trigger {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0.5rem;
    flex: 1;
}

.tool-trigger {
    cursor: pointer;
}

/* 小部件专用样式 - 确保圆角与卡片一致，内容占满无留白 */
.widget-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    text-decoration: none;
    color: inherit;
    padding: 0 !important;
    border-radius: inherit;   /* 继承卡片圆角 */
}

.widget-content-full {
    width: 100%;
    height: 100%;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: inherit;   /* 继承卡片圆角 */
}

.item-icon-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.item-icon {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 12px;
}

.icon-placeholder {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
}

/* 标题独立于卡片外部 */
.item-title-outside {
    text-align: center;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0 0.2rem;
    color: var(--text);
    line-height: 1.3;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* 不同布局下的图标大小微调 */
.dashboard-card-wrapper.layout-2_2 .item-icon,
.dashboard-card-wrapper.layout-4_2 .item-icon,
.dashboard-card-wrapper.layout-2_4 .item-icon {
    width: 72px;
    height: 72px;
}
.dashboard-card-wrapper.layout-2_2 .icon-placeholder,
.dashboard-card-wrapper.layout-4_2 .icon-placeholder,
.dashboard-card-wrapper.layout-2_4 .icon-placeholder {
    width: 72px;
    height: 72px;
    font-size: 36px;
}

.dashboard-card-wrapper.layout-2_1 .item-icon {
    width: 64px;
    height: 64px;
}
.dashboard-card-wrapper.layout-2_1 .icon-placeholder {
    width: 64px;
    height: 64px;
    font-size: 32px;
}

.dashboard-card-wrapper.layout-1_2 .item-icon {
    width: 48px;
    height: 48px;
}
.dashboard-card-wrapper.layout-1_2 .icon-placeholder {
    width: 48px;
    height: 48px;
    font-size: 24px;
}

/* 大卡片标题稍大，但仍单行省略 */
.dashboard-card-wrapper.layout-2_2 .item-title-outside,
.dashboard-card-wrapper.layout-4_2 .item-title-outside,
.dashboard-card-wrapper.layout-2_4 .item-title-outside {
    font-size: 0.85rem;
}

/* 布局跨度 */
.dashboard-card-wrapper.layout-1_1 { grid-column: span 1; grid-row: span 1; }
.dashboard-card-wrapper.layout-1_2 { grid-column: span 1; grid-row: span 2; }
.dashboard-card-wrapper.layout-2_1 { grid-column: span 2; grid-row: span 1; }
.dashboard-card-wrapper.layout-2_2 { grid-column: span 2; grid-row: span 2; }
.dashboard-card-wrapper.layout-2_4 { grid-column: span 2; grid-row: span 4; }
.dashboard-card-wrapper.layout-4_2 { grid-column: span 4; grid-row: span 2; }

/* 右键菜单样式（主菜单） */
.context-menu {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 160px;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.context-menu-header {
    padding: 0.5rem 1rem;
    background: rgba(0,0,0,0.05);
    font-weight: 600;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-light);
}

.context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: 0.1s;
    font-size: 0.85rem;
    position: relative;
}

.context-menu-item:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* 二级菜单样式 */
.sub-menu {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    overflow: hidden;
    backdrop-filter: blur(8px);
    z-index: 10002;
}

.sub-menu .context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.sub-menu .context-menu-item:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* 工具弹窗 */
.tool-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.tool-modal-content {
    background: transparent;
    width: auto;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tool-modal-body {
    background: transparent;
    width: 100%;
}

.tool-modal-close {
    margin-top: 1rem;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: white;
    cursor: pointer;
}

/* 编辑弹窗 */
.modal-form {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

.modal-form .modal-content {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
}

.modal-form input,
.modal-form button {
    width: 100%;
    margin: 0.5rem 0;
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

/* 手动添加表单行内布局 */
.form-row-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.form-row-inline label {
    flex-shrink: 0;
    font-weight: 500;
}
.form-row-inline input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 2rem;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}
.form-row-inline .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

/* 在线列表滚动条细 */
#onlineLinksList {
    scrollbar-width: thin;
}
#onlineLinksList::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
#onlineLinksList::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 3px;
}
#onlineLinksList::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 3px;
}
.online-link-card {
    transition: transform 0.1s, background 0.1s;
}
.online-link-card:hover {
    background: rgba(59,130,246,0.1);
    transform: translateY(-2px);
}

/* 选项卡样式 */
.add-tab {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}
.add-tab.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}
.add-pane {
    padding: 1rem 0;
}

/* 响应式 */
@media (max-width: 640px) {
    .datetime-time { font-size: 2.2rem; }
    .search-container { margin: 0 1rem; }
    .dashboard-grid { gap: 0.75rem; }
    .item-icon { width: 48px; height: 48px; }
    .icon-placeholder { width: 48px; height: 48px; font-size: 24px; }
    .item-title-outside { font-size: 0.7rem; margin-top: 0.25rem; }
    .dashboard-card-wrapper.layout-1_2,
    .dashboard-card-wrapper.layout-2_1,
    .dashboard-card-wrapper.layout-2_2,
    .dashboard-card-wrapper.layout-2_4,
    .dashboard-card-wrapper.layout-4_2 {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }
    .dashboard-card-wrapper.layout-1_2 .dashboard-item,
    .dashboard-card-wrapper.layout-2_1 .dashboard-item,
    .dashboard-card-wrapper.layout-2_2 .dashboard-item,
    .dashboard-card-wrapper.layout-2_4 .dashboard-item,
    .dashboard-card-wrapper.layout-4_2 .dashboard-item {
        aspect-ratio: 1 / 1 !important;
    }
    .dashboard-card-wrapper.layout-2_2 .item-icon,
    .dashboard-card-wrapper.layout-4_2 .item-icon,
    .dashboard-card-wrapper.layout-2_4 .item-icon {
        width: 48px;
        height: 48px;
    }
    .dashboard-card-wrapper.layout-2_2 .icon-placeholder,
    .dashboard-card-wrapper.layout-4_2 .icon-placeholder,
    .dashboard-card-wrapper.layout-2_4 .icon-placeholder {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
}