/* ============================================
   校园闲置交易平台 - 主样式表
   融合 Element Plus 设计语言
   ============================================ */

/* --- CSS Variables --- */
:root {
    --primary: #4FADE6;
    --primary-dark: #3A8EC2;
    --primary-light: #E8F4FD;
    --secondary: #6C5CE7;
    --gradient: linear-gradient(135deg, #4FADE6 0%, #6C5CE7 100%);
    --gradient-hover: linear-gradient(135deg, #3A8EC2 0%, #5B4BD5 100%);
    --success: #67C23A;
    --warning: #E6A23C;
    --danger: #F56C6C;
    --info: #909399;
    --text-primary: #303133;
    --text-regular: #606266;
    --text-secondary: #909399;
    --text-placeholder: #C0C4CC;
    --border-color: #E4E7ED;
    --border-light: #EBEEF5;
    --bg-color: #F5F7FA;
    --bg-white: #FFFFFF;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
    --shadow-xl: 0 8px 40px rgba(0,0,0,0.16);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    color: var(--text-primary);
    background: var(--bg-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
ul { list-style: none; }
img { max-width: 100%; height: auto; }
.container { max-width: 1260px; margin: 0 auto; padding: 0 24px; width: 100%; }

/* --- Header --- */
.header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}
.header-inner { padding: 0 24px; }
.header-content {
    display: flex;
    align-items: center;
    gap: 28px;
    height: 64px;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex-shrink: 0;
}
.logo-icon { width: 38px; height: 38px; flex-shrink: 0; }
.logo h1 { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.logo-sub { font-size: 0.72rem; color: var(--text-secondary); display: block; margin-top: -2px; }

/* Search Bar */
.search-bar {
    flex: 1;
    max-width: 460px;
    display: flex;
    align-items: center;
    background: var(--bg-color);
    border: 2px solid transparent;
    border-radius: 50px;
    overflow: hidden;
    transition: all var(--transition);
    position: relative;
}
.search-bar:focus-within {
    background: var(--bg-white);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 173, 230, 0.12);
}
.search-icon {
    position: absolute;
    left: 16px;
    color: var(--text-placeholder);
    pointer-events: none;
}
.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 16px 10px 42px;
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    min-width: 0;
}
.search-bar input::placeholder { color: var(--text-placeholder); }
.search-bar button {
    padding: 10px 22px;
    background: var(--gradient);
    color: white;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition);
    white-space: nowrap;
}
.search-bar button:hover { opacity: 0.9; }

/* Header Actions */
.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: inherit;
}
.btn-gradient { background: var(--gradient); color: white; }
.btn-gradient:hover { background: var(--gradient-hover); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,173,230,0.35); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); color: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text-regular); }
.btn-ghost:hover { background: var(--bg-color); color: var(--primary); }
.btn-block { width: 100%; justify-content: center; padding: 12px 24px; font-size: 1rem; }

.btn-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 6px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all var(--transition);
}
.btn-user:hover { border-color: var(--primary); background: var(--primary-light); }

.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.user-dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 140px;
    z-index: 200;
}
.dropdown-menu.show { display: block; animation: fadeDown 0.15s ease; }
.dropdown-item {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-regular);
    transition: all var(--transition);
}
.dropdown-item:hover { background: var(--bg-color); color: var(--danger); }

/* --- Main Layout --- */
.main { flex: 1; padding: 28px 0; }
.main-layout { display: flex; gap: 24px; align-items: flex-start; }

/* --- Sidebar --- */
.sidebar { width: 220px; flex-shrink: 0; position: sticky; top: 92px; }
.sidebar-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.95rem;
}
.category-list { padding: 8px; }
.category-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-regular);
    transition: all var(--transition);
    margin-bottom: 2px;
}
.category-list li:hover { background: var(--primary-light); color: var(--primary); }
.category-list li.active {
    background: var(--gradient);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(79,173,230,0.3);
}
.cat-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.4;
    flex-shrink: 0;
}

/* --- Content --- */
.content { flex: 1; min-width: 0; }
.content-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.content-toolbar h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}
.toolbar-right { display: flex; align-items: center; gap: 14px; }
.goods-count { font-size: 0.85rem; color: var(--text-secondary); }

.sort-select-wrapper select {
    padding: 8px 36px 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-regular);
    background: var(--bg-white);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23909399' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color var(--transition);
}
.sort-select-wrapper select:focus { border-color: var(--primary); }

/* --- Goods Grid --- */
.goods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 18px;
}

/* --- Goods Card --- */
.goods-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-light);
    position: relative;
}
.goods-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}
.goods-card .card-top {
    position: relative;
    padding: 24px 20px 16px;
    background: linear-gradient(135deg, #F0F5FF 0%, #F5F0FF 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}
.goods-card .card-emoji {
    font-size: 3.5rem;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
.goods-card:hover .card-emoji { transform: scale(1.1); }
.goods-card .card-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    color: white;
    background: var(--gradient);
}
.goods-card .card-body { padding: 16px 18px 18px; }
.goods-card .card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}
.goods-card .card-price {
    font-size: 1.35rem;
    font-weight: 800;
    color: #F56C6C;
    margin-bottom: 12px;
    font-family: var(--font-mono);
}
.goods-card .card-price::before { content: '¥ '; font-size: 0.85rem; font-weight: 600; }
.goods-card .card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.goods-card .card-seller { display: flex; align-items: center; gap: 5px; }
.goods-card .card-seller-avatar {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
}
.goods-card .card-time { font-size: 0.75rem; }

/* Sold Overlay */
.goods-card.sold { opacity: 0.8; }
.goods-card.sold::after {
    content: '已售出';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 8px 24px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 700;
    z-index: 2;
    pointer-events: none;
}

/* --- Skeleton Loading --- */
.skeleton-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    height: 260px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}
@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

/* --- Detail Content --- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 28px;
}
.detail-main h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.detail-main .detail-desc {
    background: var(--bg-color);
    border-radius: var(--radius);
    padding: 16px 18px;
    color: var(--text-regular);
    line-height: 1.8;
    font-size: 0.9rem;
    margin-bottom: 20px;
    white-space: pre-wrap;
}
.detail-sidebar {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: fit-content;
}
.detail-price {
    font-size: 2rem;
    font-weight: 800;
    color: #F56C6C;
    font-family: var(--font-mono);
}
.detail-price::before { content: '¥ '; font-size: 1.2rem; }
.detail-contact {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 14px;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.detail-contact svg { margin-bottom: 4px; }
.detail-contact strong { color: var(--secondary); display: block; margin-top: 2px; }
.detail-seller {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease;
}
.modal-overlay.show { display: flex; }
.modal-panel {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-panel.modal-lg { max-width: 620px; }
.modal-header {
    padding: 28px 32px 0;
    position: relative;
    text-align: center;
}
.modal-header h3 { font-size: 1.35rem; font-weight: 700; margin-bottom: 4px; }
.modal-header p { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 20px; }
.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 34px; height: 34px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-color); color: var(--text-primary); }
.modal-body { padding: 4px 32px 32px; }

/* --- Form --- */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-regular);
    margin-bottom: 6px;
}
.required { color: var(--danger); }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-white);
    transition: all var(--transition);
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,173,230,0.12);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-placeholder); }
.form-group textarea { resize: vertical; min-height: 90px; }
.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23909399' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-switch { text-align: center; font-size: 0.85rem; color: var(--text-secondary); margin-top: 18px; }
.form-switch a { font-weight: 600; }

/* --- Toast --- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 600;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    max-width: 380px;
    border-left: 4px solid var(--primary);
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }

/* --- Footer --- */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-light);
    padding: 20px 0;
    margin-top: auto;
}
.footer-inner { text-align: center; color: var(--text-secondary); font-size: 0.85rem; }

/* --- Empty State --- */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 4rem; margin-bottom: 16px; }
.empty-state p { font-size: 1rem; }

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideInRight { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }

/* --- Responsive --- */
@media (max-width: 900px) {
    .main-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        position: static;
    }
    .category-list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    .category-list li { margin-bottom: 0; }
    .goods-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .header-content { gap: 14px; }
    .logo h1 { font-size: 1rem; }
    .logo-sub { display: none; }
    .search-bar { max-width: none; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .header-actions .btn-ghost { display: none; }
}

@media (max-width: 600px) {
    .header-content { flex-wrap: wrap; height: auto; padding: 10px 0; }
    .search-bar { order: 3; flex-basis: 100%; }
    .goods-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .goods-card .card-top { min-height: 100px; padding: 16px 12px 10px; }
    .goods-card .card-emoji { font-size: 2.5rem; }
    .goods-card .card-body { padding: 12px; }
    .goods-card .card-title { font-size: 0.82rem; }
    .goods-card .card-price { font-size: 1.1rem; }
    .content-toolbar h2 { font-size: 1.1rem; }
    .modal-panel { width: 95%; max-width: none; margin: 10px; border-radius: var(--radius-lg); }
    .modal-header { padding: 20px 20px 0; }
    .modal-body { padding: 4px 20px 24px; }
}
