/* 管理页面样式 */

/* 顶部标题栏 */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, #2c3e50, #2980b9);
    color: white;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 20px;
    justify-content: space-between;
    /* 让两端对齐 */
}

/* 新增：头部左侧容器 */
.header-left {
    display: flex;
    align-items: center;
}

.menu-toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 10px;
    margin-right: 10px;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
}

/* 新增：搜索框容器 */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

/* 新增：搜索图标 */
.search-icon {
    position: absolute;
    left: 15px;
    color: #95a5a6;
}

/* 新增：搜索输入框 */
#search-input {
    width: 250px;
    height: 36px;
    padding: 0 20px 0 40px;
    /* 左边留出图标位置 */
    border: none;
    border-radius: 18px;
    /* 圆角 */
    background-color: #ecf0f1;
    color: #2c3e50;
    font-size: 14px;
    transition: width 0.3s ease-in-out, background-color 0.2s;
}

#search-input::placeholder {
    color: #95a5a6;
}

#search-input:focus {
    outline: none;
    width: 300px;
    /* 聚焦时稍微变宽 */
    background-color: #fff;
}


.logo {
    height: 40px;
    margin-right: 10px;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

/* 布局 */
.manage-container {
    display: flex;
    height: calc(100vh - 60px);
    margin-top: 60px;
}

/* 侧边栏 */
.sidebar {
    width: 250px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    padding: 20px;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-nav {
    margin-bottom: 20px;
}

/* 侧边栏导航组 */
.nav-group {
    margin-bottom: 20px;
}

.nav-group-header {
    display: flex;
    align-items: center;
    padding: 10px;
    color: #2c3e50;
    font-weight: 600;
    font-size: 16px;
    border-radius: 5px;
    background: #e9ecef;
    margin-bottom: 5px;
}

.nav-group-header i {
    margin-right: 10px;
    color: #3498db;
}

.nav-group-items {
    padding-left: 15px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    color: #495057;
    text-decoration: none;
    border-radius: 5px;
    margin-bottom: 3px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.nav-item:hover {
    background: #e9ecef;
    color: #2c3e50;
}

.nav-item.active {
    background: #3498db;
    color: white;
}

.nav-item.active i {
    color: white;
}

.nav-item i {
    margin-right: 10px;
    color: #6c757d;
    font-size: 12px;
}

/* 主内容区 */
.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

/* 目录部分 */
.directory-section {
    margin-bottom: 40px;
}

.directory-title {
    font-size: 28px;
    color: #2c3e50;
    margin-bottom: 25px;
    padding-bottom: 12px;
    border-bottom: 2px solid #3498db;
}

.subdirectories {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 目录编辑器样式 */
.directory-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

/* 拖拽手柄 */
.drag-handle {
    cursor: grab;
    color: #adb5bd;
    margin-right: 10px;
    transition: color 0.2s ease;
}

.drag-handle:hover {
    color: #6c757d;
}

.drag-handle:active {
    cursor: grabbing;
}

/* 目录项样式调整 */
.directory-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.directory-name {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    background: #e9ecef;
}

/* 拖拽时的视觉效果 */
.sortable-ghost {
    opacity: 0.4;
    background: #e9ecef !important;
}

.sortable-chosen {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sortable-drag {
    opacity: 0.9;
    background: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* 类别部分 */
.category-section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.category-title {
    font-size: 20px;
    color: #343a40;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

/* 物品网格 */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 10px;
}

/* 物品卡片 */
.item-card {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.item-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 新增：卡片操作按钮容器 */
.card-actions {
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    display: flex;
    justify-content: space-between;
    opacity: 0;
    /* 默认隐藏 */
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    /* 隐藏时不可点击 */
    z-index: 10;
    /* 确保按钮在图片上层 */
}

.item-card:hover .card-actions {
    opacity: 1;
    /* 悬停时显示 */
    pointer-events: auto;
    /* 显示时可点击 */
}

/* 新增：通用操作按钮样式 */
.action-btn {
    background-color: rgba(44, 62, 80, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.action-btn:hover {
    background-color: rgba(44, 62, 80, 1);
    transform: scale(1.1);
}

.btn-edit {
    /* 左上角，无需额外样式 */
}

.btn-delete-card {
    /* 避免与之前的 .btn-delete 冲突 */
    /* 右上角，无需额外样式 */
}

.item-image {
    width: 100%;
    height: 140px;
    overflow: hidden;
    position: relative;
    border-radius: 8px 8px 0 0;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px 8px 0 0;
}

.item-info {
    padding: 12px;
}

.item-info h3 {
    margin: 0;
    font-size: 15px;
    color: #343a40;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-info p {
    margin: 4px 0;
    color: #6c757d;
    font-size: 13px;
    line-height: 1.4;
}

/* 类别编辑器样式 */
.category-editor {
    padding: 15px;
}

.category-item {
    background: white;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
}

/* 类别项样式调整 */
.category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
}

.category-name {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s ease;
}

.category-name:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.btn-delete {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-delete:hover {
    background: #dc3545;
    color: white;
}

/* 管理导航按钮 */
.manage-nav-btn {
    width: 100%;
    padding: 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background-color 0.2s ease;
}

.manage-nav-btn:hover {
    background: #2980b9;
}

.manage-nav-btn i {
    font-size: 16px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .menu-toggle-btn {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: -250px;
        top: 60px;
        bottom: 0;
        z-index: 1000;
        background: white;
    }

    .sidebar.active {
        transform: translateX(250px);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .item-image {
        height: 120px;
    }

    .item-info {
        padding: 10px;
    }

    .item-info h3 {
        font-size: 14px;
    }

    .item-info p {
        font-size: 12px;
    }

    .directory-title {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .category-title {
        font-size: 18px;
        margin-bottom: 15px;
    }
}

/* 加载动画 */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 悬浮按钮 */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: #3498db;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fab:hover {
    transform: scale(1.1);
    background: #2980b9;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.large {
    max-width: 800px;
}

.close-button {
    float: right;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    border: none;
    background: none;
}

.close-button:hover {
    color: #343a40;
}

/* 表单样式 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #495057;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 16px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* 自定义光标 */
#laser-cursor {
    width: 10px;
    height: 10px;
    background-color: red;
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 9999;
    mix-blend-mode: difference;
}

/* 拖拽提示 */
.subdirectory-list {
    min-height: 50px;
    padding: 10px;
    border-radius: 4px;
    background: #f8f9fa;
    transition: background-color 0.2s ease;
}

.subdirectory-list:empty {
    padding: 20px;
    border: 2px dashed #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.subdirectory-list:empty::after {
    content: '拖动类别到这里';
    color: #adb5bd;
    font-size: 14px;
    font-style: italic;
}

/* 拖拽时的目标区域高亮 */
.subdirectory-list.sortable-drag-enabled {
    background: #e9ecef;
    border: 2px dashed #adb5bd;
}