/* 
 * 统一组件样式文件
 * 定义所有页面通用的图片显示尺寸、删除按钮、菜单和功能按钮样式
 */

/* ============================================
   颜色变量定义
   ============================================ */
:root {
    /* 主色调 */
    --primary-color: #2196F3;
    --secondary-color: #6a1b9a;
    --danger-color: #F44336;
    --success-color: #4CAF50;
    --warning-color: #FFC107;
    --info-color: #03A9F4;
    
    /* 删除按钮专用颜色 */
    --delete-btn-color: #ff4444;
    --delete-btn-hover-color: #ff0000;
    
    /* 中性色 */
    --light-gray: #f8f9fa;
    --medium-gray: #e9ecef;
    --dark-gray: #6c757d;
    --border-color: #e0e0e0;
    
    /* 阴影 */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* ============================================
   图片显示尺寸定义
   ============================================ */

/* 图片预览容器 */
.image-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
}

.image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
}

.image-gallery a {
    display: inline-block;
    margin: 5px;
}

.image-gallery img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
}

/* 标准图片项尺寸 */
.image-item {
    position: relative;
    width: 120px;
    height: 90px;
    overflow: visible;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 5px;
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 4px;
    position: relative;
    z-index: 0;
    pointer-events: none; /* 确保图片不会拦截删除按钮的点击事件 */
}

/* 图片预览项 */
.image-preview-item {
    position: relative;
    display: inline-block;
    margin: 0 10px 10px 0;
    width: 120px;
    height: 90px;
    overflow: visible;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    border-radius: 4px;
    display: block;
    overflow: hidden;
    pointer-events: none; /* 确保预览图片不会拦截删除按钮的点击事件 */
}

.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 10px 0;
}

/* 中等尺寸图片项（用于详情页） */
.image-item-medium {
    position: relative;
    width: 150px;
    height: 120px;
    overflow: visible;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 5px;
}

.image-item-medium img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 大尺寸图片项（用于全屏查看） */
.image-item-large {
    position: relative;
    width: 200px;
    height: 150px;
    overflow: visible;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 5px;
}

.image-item-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 懒加载图片占位符 */
.lazy-image {
    background: var(--light-gray);
    min-width: 200px;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lazy-image::after {
    content: "点击加载图片";
    color: var(--dark-gray);
}

/* ============================================
   统一的删除按钮样式
   ============================================ */

/* 删除图片按钮基础样式 */
.delete-image {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--delete-btn-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    line-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
    z-index: 100;
    pointer-events: auto; /* 确保按钮可以接收点击事件 */
    touch-action: manipulation; /* 优化触摸设备上的点击响应 */
    user-select: none; /* 防止文本选择 */
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

.delete-image:hover {
    background: var(--delete-btn-hover-color) !important;
    transform: scale(1.1);
}

.delete-image:active {
    transform: scale(0.95);
}

/* 针对特定类型的删除按钮，继承基础样式并确保可点击 */
.delete-hazard-image-btn,
.delete-inspection-image-btn,
.delete-rectification-image-btn {
    pointer-events: auto !important;
    touch-action: manipulation !important;
}

/* 用于JavaScript动态创建的删除按钮的内联样式字符串 */
.delete-image-inline-style {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--delete-btn-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    line-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 100;
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* 删除按钮的CSS文本（用于JavaScript设置） */
.delete-image-css-text {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    line-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 100;
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   统一的功能按钮样式
   ============================================ */

/* 标准按钮基础样式 */
.standard-button {
    background-color: var(--success-color);
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.standard-button:hover {
    background-color: #45a049;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.standard-button:active {
    transform: translateY(0);
}

.standard-button[disabled] {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* 操作按钮组 */
.action-btn {
    padding: 8px 16px;
    border-radius: 4px;
    color: white;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
    display: inline-block;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.action-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.action-btn:active {
    transform: translateY(0);
}

/* 查看按钮 */
.view-btn {
    background-color: var(--success-color);
}

.view-btn:hover {
    background-color: #388E3C;
}

/* 编辑按钮 */
.edit-btn {
    background-color: var(--primary-color);
}

.edit-btn:hover {
    background-color: #1976D2;
}

/* 删除按钮（功能按钮，非图片删除按钮） */
.delete-btn {
    background-color: var(--danger-color);
}

.delete-btn:hover {
    background-color: #D32F2F;
}

/* 返回按钮 */
.back-btn {
    display: inline-block;
    margin-top: 20px;
    padding: 8px 15px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.back-btn:hover {
    background-color: #1976D2;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* 取消按钮 */
.cancel-btn {
    background-color: var(--dark-gray);
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    margin-left: 10px;
}

.cancel-btn:hover {
    background-color: #7f8c8d;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* 保存按钮 */
.save-btn {
    background-color: var(--success-color);
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.save-btn:hover {
    background-color: #45a049;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* 提交按钮 */
.submit-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    background-color: #1976D2;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* 小尺寸操作按钮（用于表格中的操作列） */
.action-btn-small {
    padding: 3px 6px;
    margin-right: 3px;
    text-decoration: none;
    color: white;
    border-radius: 2px;
    font-size: 12px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    display: inline-block;
}

.action-btn-small:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* 彩色按钮变体 */
.purple-btn {
    background-color: var(--secondary-color);
}

.purple-btn:hover {
    background-color: #5E35B1;
}

.blue-btn {
    background-color: var(--primary-color);
}

.blue-btn:hover {
    background-color: #1976D2;
}

.red-btn {
    background-color: var(--danger-color);
}

.red-btn:hover {
    background-color: #D32F2F;
}

.green-btn {
    background-color: var(--success-color);
}

.green-btn:hover {
    background-color: #388E3C;
}

/* 按钮组容器 */
.button-group {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.button-group-center {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
    flex-wrap: wrap;
}

.button-group-right {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ============================================
   统一的菜单样式
   ============================================ */

/* 导航菜单 */
.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: #2c3e50;
}

.nav-menu li {
    margin: 0;
    padding: 0;
}

.nav-menu-item {
    display: block;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-menu-item:hover {
    background-color: #34495e;
    border-left-color: var(--primary-color);
    color: white;
}

.nav-menu-item.active {
    background-color: #34495e;
    border-left-color: var(--primary-color);
    font-weight: 600;
}

/* 下拉菜单 */
.dropdown-menu {
    position: absolute;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-md);
    padding: 5px 0;
    min-width: 150px;
    z-index: 1000;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu-item {
    display: block;
    padding: 8px 15px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
}

.dropdown-menu-item:hover {
    background-color: var(--light-gray);
    color: var(--primary-color);
}

.dropdown-menu-item.danger {
    color: var(--danger-color);
}

.dropdown-menu-item.danger:hover {
    background-color: #ffebee;
}

/* 标签页菜单 */
.tab-menu {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-menu-item {
    padding: 10px 20px;
    background-color: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark-gray);
    transition: all 0.3s ease;
    margin-bottom: -2px;
}

.tab-menu-item:hover {
    color: var(--primary-color);
    background-color: var(--light-gray);
}

.tab-menu-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

/* 上下文菜单 */
.context-menu {
    position: fixed;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    padding: 5px 0;
    min-width: 120px;
    z-index: 9999;
    display: none;
}

.context-menu.show {
    display: block;
}

.context-menu-item {
    display: block;
    padding: 8px 15px;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.context-menu-item:hover {
    background-color: var(--light-gray);
    color: var(--primary-color);
}

.context-menu-item.danger {
    color: var(--danger-color);
}

.context-menu-item.danger:hover {
    background-color: #ffebee;
}

/* ============================================
   响应式设计
   ============================================ */

@media (max-width: 768px) {
    /* 移动端图片尺寸调整 */
    .image-item {
        width: 100px;
        height: 75px;
    }
    
    .image-preview-item {
        width: 100px;
        height: 75px;
    }
    
    .image-item-medium {
        width: 120px;
        height: 90px;
    }
    
    .image-item-large {
        width: 150px;
        height: 110px;
    }
    
    /* 按钮组垂直排列 */
    .button-group,
    .button-group-center,
    .button-group-right {
        flex-direction: column;
        width: 100%;
    }
    
    .button-group button,
    .button-group a,
    .button-group-center button,
    .button-group-center a,
    .button-group-right button,
    .button-group-right a {
        width: 100%;
        text-align: center;
    }
    
    /* 操作按钮间距调整 */
    .action-btn-small {
        margin: 2px;
        padding: 4px 8px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    /* 小屏幕图片尺寸 */
    .image-item {
        width: 80px;
        height: 60px;
    }
    
    .image-preview-item {
        width: 80px;
        height: 60px;
    }
    
    /* 删除按钮尺寸调整 */
    .delete-image {
        width: 20px;
        height: 20px;
        font-size: 14px;
        line-height: 20px;
    }
    
    /* 标签页菜单垂直排列 */
    .tab-menu {
        flex-direction: column;
    }
    
    .tab-menu-item {
        border-bottom: 1px solid var(--border-color);
        border-left: 3px solid transparent;
        margin-bottom: 0;
    }
    
    .tab-menu-item.active {
        border-left-color: var(--primary-color);
        border-bottom-color: var(--border-color);
    }
}

