/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f8f9fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部样式 */
.header {
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #4CAF50;
    text-decoration: none;
}

.logo span {
    color: #333;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 25px;
}

.nav-link {
    color: #555;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.3s;
    padding: 8px 12px;
    border-radius: 4px;
}

.nav-link:hover {
    color: #4CAF50;
    background: #f0f9f0;
}

.nav-link.active {
    color: #4CAF50;
    background: #f0f9f0;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.btn-outline {
    background: transparent;
    border: 1px solid #4CAF50;
    color: #4CAF50;
}

.btn-outline:hover {
    background: #4CAF50;
    color: white;
}

/* 页脚样式 */
.footer {
    background: #2c3e50;
    color: white;
    padding: 50px 0 20px;
    margin-top: 50px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    margin-bottom: 30px;
}

.footer-section h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #ecf0f1;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 10px;
}

.footer-section a {
    color: #bdc3c7;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-section a:hover {
    color: #4CAF50;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #34495e;
    color: #95a5a6;
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    
    .user-menu {
        margin-top: 10px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
    
    .product-main {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

/* 工具类 */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* 消息提示 */
.message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 修改 .loading 样式，强制独占一行并居中 */
.loading { 
    display: none; 
    color: #666; 
    margin-top: 20px;
    width: 100%;           /* 强制全宽 */
    text-align: center;    /* 文字居中 */
    font-size: 16px;
    clear: both;           /* 清除浮动 */
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 表单验证 */
.error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
}

.form-control.error-border {
    border-color: #dc3545;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}
/* =========================================
   修复右上角用户下拉菜单
   ========================================= */

/* =========================================
   修复右上角用户下拉菜单 (最终修正版)
   ========================================= */

.dropdown {
    position: relative;
    display: inline-block;
    cursor: pointer;
    height: 100%;
    z-index: 2000; /* 提高父容器层级 */
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px; /* 调整内边距 */
    height: 100%;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%; /* 紧贴底部 */
    background-color: #ffffff;
    min-width: 160px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border-radius: 8px;
    z-index: 2001; /* 确保在最上层 */
    padding: 8px 0;
    border: 1px solid #eee;
    
    /* 关键修改：去掉 margin-top，防止鼠标断连 */
    margin-top: 0; 
}

/* 关键修改：创建一个透明的“桥”，填补鼠标移动时的缝隙 */
.dropdown-content::before {
    content: "";
    position: absolute;
    top: -10px; /* 向上延伸 */
    left: 0;
    width: 100%;
    height: 10px;
    background: transparent;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 10px 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
    text-align: left;
    white-space: nowrap; /* 防止文字换行 */
}

.dropdown-item:hover {
    background-color: #f5f9f5;
    color: #4CAF50;
}
/* 修复头部布局对齐问题 */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-menu {
    display: flex;
    align-items: center;
}