/* ============================================
   校园闲置物品交易系统 - 全局样式
   ============================================ */

/* CSS 变量 */
:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #EEF2FF;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

/* 重置 */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   导航栏
   ============================================ */
.navbar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.nav-brand:hover {
    color: var(--primary-dark);
}

.nav-search {
    flex: 1;
    max-width: 480px;
}

.search-form {
    display: flex;
    align-items: center;
    background: var(--gray-100);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.search-form:focus-within {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 16px;
    font-size: 14px;
    outline: none;
    color: var(--gray-800);
}

.search-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.search-btn:hover {
    color: var(--primary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.nav-link {
    padding: 8px 14px;
    font-size: 14px;
    color: var(--gray-600);
    border-radius: var(--radius);
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-post {
    background: var(--primary);
    color: white !important;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-post:hover {
    background: var(--primary-dark) !important;
}

.nav-link-login {
    background: var(--gray-100);
    font-weight: 500;
}

/* 用户下拉菜单 */
.nav-user-dropdown {
    position: relative;
    cursor: pointer;
}

.nav-user {
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    background: var(--primary-light);
    border-radius: var(--radius);
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 140px;
    overflow: hidden;
    z-index: 200;
}

.nav-user-dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--gray-700);
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: var(--gray-50);
    color: var(--primary);
}

/* ============================================
   分类导航
   ============================================ */
.category-bar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0;
}

.category-bar .container {
    display: flex;
    gap: 0;
    overflow-x: auto;
}

.category-item {
    padding: 12px 20px;
    font-size: 14px;
    color: var(--gray-600);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.category-item:hover {
    color: var(--primary);
    background: var(--gray-50);
}

.category-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* ============================================
   主内容区
   ============================================ */
.main-content {
    padding: 24px 20px;
    min-height: calc(100vh - 200px);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-800);
}

.item-count {
    font-size: 14px;
    color: var(--gray-500);
}

/* ============================================
   商品网格
   ============================================ */
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.item-card {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.25s;
    display: flex;
    flex-direction: column;
}

.item-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.item-image {
    position: relative;
    height: 200px;
    background: var(--gray-100);
    overflow: hidden;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
}

.item-category-tag {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255,255,255,0.95);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.item-info {
    padding: 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.item-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-title a {
    color: var(--gray-800);
}

.item-title a:hover {
    color: var(--primary);
}

.item-desc {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.item-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--danger);
}

.item-date {
    font-size: 12px;
    color: var(--gray-400);
}

.item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--gray-500);
    padding-top: 8px;
    border-top: 1px solid var(--gray-100);
}

.item-location {
    font-size: 12px;
}

/* ============================================
   空状态
   ============================================ */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--gray-400);
}

.empty-state p {
    margin: 16px 0 24px;
    font-size: 16px;
}

/* ============================================
   商品详情页
   ============================================ */
.breadcrumb {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 20px;
}

.breadcrumb a {
    color: var(--gray-500);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.detail-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}

.detail-image-section {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--gray-100);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-image {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
}

.detail-image-placeholder {
    text-align: center;
    padding: 60px;
    color: var(--gray-400);
}

.detail-image-placeholder p {
    margin-top: 12px;
    font-size: 14px;
}

.detail-info-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-category {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    width: fit-content;
}

.detail-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.3;
}

.detail-price-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
}

.detail-price {
    font-size: 32px;
    font-weight: 800;
    color: var(--danger);
}

.detail-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

.status-available {
    background: #ECFDF5;
    color: #065F46;
}

.status-reserved {
    background: #FFFBEB;
    color: #92400E;
}

.status-sold {
    background: var(--gray-100);
    color: var(--gray-500);
}

.detail-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px 0;
    border-top: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
}

.detail-info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-label {
    font-size: 12px;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 14px;
    color: var(--gray-700);
    font-weight: 500;
}

.detail-description {
    padding: 8px 0;
}

.detail-description h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-800);
}

.detail-description p {
    font-size: 14px;
    color: var(--gray-600);
    line-height: 1.8;
}

.detail-actions {
    display: flex;
    gap: 12px;
    padding-top: 8px;
}

/* ============================================
   按钮样式
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.btn-outline {
    background: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-danger {
    background: white;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 16px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

/* ============================================
   表单样式
   ============================================ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
}

.auth-container {
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px 32px;
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.logo-icon {
    color: var(--primary);
    margin-bottom: 12px;
}

.auth-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 6px;
}

.auth-header p {
    font-size: 14px;
    color: var(--gray-500);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
}

.required {
    color: var(--danger);
}

.form-input {
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    outline: none;
    transition: all 0.2s;
    background: white;
    color: var(--gray-800);
    width: 100%;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

select.form-input {
    cursor: pointer;
    appearance: auto;
}

.form-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.auth-footer {
    text-align: center;
    font-size: 14px;
    color: var(--gray-500);
    padding-top: 8px;
}

.link {
    color: var(--primary);
    font-weight: 500;
}

.link:hover {
    text-decoration: underline;
}

.demo-info {
    text-align: center;
    margin-top: 8px;
    padding: 10px;
    background: #FEFCE8;
    border-radius: var(--radius);
    font-size: 13px;
    color: #713F12;
}

/* ============================================
   表单页面（发布商品）
   ============================================ */
.form-page {
    max-width: 640px;
    margin: 0 auto;
}

.form-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 32px;
}

.form-header {
    text-align: center;
    margin-bottom: 24px;
}

.form-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
}

.form-header p {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* ============================================
   页脚
   ============================================ */
.footer {
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 20px 0;
    text-align: center;
    font-size: 13px;
    color: var(--gray-500);
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 768px) {
    .nav-container {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 16px;
        gap: 10px;
    }

    .nav-search {
        order: 3;
        max-width: 100%;
        flex-basis: 100%;
    }

    .nav-links {
        gap: 4px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 13px;
    }

    .item-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 14px;
    }

    .detail-container {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
    }

    .detail-price {
        font-size: 26px;
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .auth-card {
        padding: 28px 20px;
    }

    .detail-info-grid {
        grid-template-columns: 1fr;
    }

    .detail-actions {
        flex-direction: column;
    }

    .category-bar .container {
        padding: 0 10px;
    }

    .category-item {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* ============================================
   My Items 状态标签
   ============================================ */
.item-status-badge {
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

.badge-available {
    background: #ECFDF5;
    color: #065F46;
}

.badge-reserved {
    background: #FFFBEB;
    color: #92400E;
}

.badge-sold {
    background: var(--gray-100);
    color: var(--gray-500);
}

.item-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px solid var(--gray-100);
}