/* ===================================================
   市井新物 - 主样式表（适配PC与手机）
   =================================================== */

/* 基础重置 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #2d3436;
    --accent: #e17055;
    --accent-hover: #d35445;
    --bg: #f5f6fa;
    --card-bg: #fff;
    --text: #2d3436;
    --text-light: #636e72;
    --border: #dfe6e9;
    --success: #00b894;
    --danger: #d63031;
    --warning: #fdcb6e;
    --info: #0984e3;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,.06);
    --max-width: 1200px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.main-content { flex: 1; padding: 20px 0; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 15px; }

/* 头部导航 */
.site-header {
    background: #fff;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}
.logo-img {
    height: 40px;
    width: auto;
    display: block;
}
.nav-toggle { display: none; background: none; border: none; font-size: 1.8em; cursor: pointer; color: var(--text); }
.main-nav { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.main-nav a {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-size: .95em;
    transition: all .2s;
    white-space: nowrap;
}
.main-nav a:hover { background: var(--bg); color: var(--accent); }

/* 底部 */
.site-footer {
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 20px 0;
    text-align: center;
    color: var(--text-light);
    font-size: .9em;
    margin-top: auto;
}

/* 通用组件 */
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }

/* 搜索区域 */
.search-hero {
    text-align: center;
    padding: 40px 20px 30px;
    background: linear-gradient(135deg, #e17055, #d35445);
    color: #fff;
    border-radius: var(--radius);
    margin-bottom: 30px;
}
.search-hero h1 { font-size: 1.8em; margin-bottom: 8px; }
.search-hero p { opacity: .9; margin-bottom: 20px; font-size: .95em; }
.search-box { display: flex; max-width: 600px; margin: 0 auto; }
.search-box input {
    flex: 1;
    padding: 12px 18px;
    border: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 1em;
    outline: none;
}
.search-box button {
    padding: 12px 28px;
    background: var(--text);
    color: #fff;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 1em;
    cursor: pointer;
    transition: background .2s;
}
.search-box button:hover { background: #000; }

/* 卡片列表 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #eee;
    display: block;
}
.card-body { padding: 16px; }
.card-category {
    display: inline-block;
    background: #ffeaa7;
    color: #e17055;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .8em;
    margin-bottom: 8px;
}
.card-title {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent); }
.card-desc {
    color: var(--text-light);
    font-size: .9em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 10px;
}
.card-meta { font-size: .8em; color: #b2bec3; display: flex; justify-content: space-between; }

/* 按钮 */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: var(--radius);
    font-size: .95em;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all .2s;
    text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: .85em; }
.btn-block { display: block; width: 100%; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: .95em; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95em;
    outline: none;
    transition: border-color .2s;
    background: #fff;
}
.form-control:focus { border-color: var(--accent); }
textarea.form-control { resize: vertical; min-height: 120px; }
select.form-control { cursor: pointer; }
.form-inline { display: flex; gap: 8px; }
.form-inline .form-control { flex: 1; }
.form-text { font-size: .8em; color: var(--text-light); margin-top: 4px; }

/* 提示消息 */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: .95em;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* 表格 */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: .9em; }
th { background: var(--bg); font-weight: 600; white-space: nowrap; }
tr:hover { background: #fafafa; }

/* 状态标签 */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .8em;
    font-weight: 500;
}
.badge-pending { background: #ffeaa7; color: #856404; }
.badge-approved { background: #c3e6cb; color: #155724; }
.badge-rejected { background: #f5c6cb; color: #721c24; }
.badge-active { background: #c3e6cb; color: #155724; }
.badge-disabled { background: #f5c6cb; color: #721c24; }

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 30px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-block;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: .9em;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text);
    background: #fff;
}
.pagination a:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 详情页 */
.detail-header { background: #fff; border-radius: var(--radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.detail-header h1 { font-size: 1.6em; margin-bottom: 12px; }
.detail-meta { color: var(--text-light); font-size: .9em; margin-bottom: 16px; display: flex; gap: 20px; flex-wrap: wrap; }
.detail-content {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    line-height: 1.8;
}
.detail-content img { max-width: 100%; border-radius: var(--radius); margin: 10px 0; }

/* 用户中心/管理后台布局 */
.page-section { background: #fff; border-radius: var(--radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.page-title { font-size: 1.4em; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid var(--bg); }
.page-subtitle { font-size: 1.1em; color: var(--text-light); margin-bottom: 16px; }


.editor-area {
    width: 100%;
    min-height: 350px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    outline: none;
    font-size: .95em;
    background: #fff;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.7;
    overflow-y: auto;
    word-break: break-word;
}
.editor-area:focus { border-color: var(--accent); }
.editor-area img { max-width: 100%; height: auto; border-radius: 4px; margin: 5px 0; }
/* contenteditable 占位符 */
.editor-area[data-placeholder]:empty:before {
    content: attr(data-placeholder);
    color: #999;
    pointer-events: none;
}

/* 编辑器工具栏 */
.editor-toolbar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
    padding: 6px 10px;
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}
.editor-toolbar button {
    padding: 4px 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: .8em;
    color: var(--text);
    white-space: nowrap;
    transition: all .15s;
}
.editor-toolbar button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.editor-toolbar .tool-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.editor-toolbar select, .editor-toolbar input[type="color"] {
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .8em;
    cursor: pointer;
    background: #fff;
    height: 28px;
}
.editor-toolbar input[type="color"] { width: 32px; padding: 2px; }

/* 统计卡片悬停 */
.stat-card {
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
}

/* 管理详情页 */
.detail-page { align-items: flex-start; }
.detail-page-cover { position: sticky; top: 80px; }
.view-description {
    font-size: .95em;
    line-height: 1.9;
}
.view-description img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.view-description p { margin-bottom: .8em; }
.view-description ul, .view-description ol { padding-left: 1.5em; margin-bottom: .8em; }

@media (max-width: 768px) {
    .detail-page { flex-direction: column; }
    .detail-page-cover { flex: none !important; width: 100%; position: static; }
    .detail-meta-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Tab 标签页 */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tabs a {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: .95em;
    transition: all .2s;
}
.tabs a.active, .tabs a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* 空状态 */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state .icon { font-size: 3em; margin-bottom: 10px; }
.empty-state p { margin-bottom: 16px; }

/* 模态弹窗 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,.15);
}
.modal-box h3 { margin-bottom: 16px; }

/* 移动端适配 */
@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .main-nav {
        display: none;
        position: absolute;
        top: 60px;
        left: 0; right: 0;
        background: #fff;
        flex-direction: column;
        padding: 10px;
        box-shadow: var(--shadow);
        border-top: 1px solid var(--border);
    }
    .main-nav.show { display: flex; }
    .main-nav a { width: 100%; padding: 12px 16px; }

    .search-hero { padding: 30px 15px 20px; }
    .search-hero h1 { font-size: 1.4em; }
    .search-box { flex-direction: column; }
    .search-box input { border-radius: var(--radius); margin-bottom: 8px; }
    .search-box button { border-radius: var(--radius); width: 100%; }

    .card-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .detail-header h1 { font-size: 1.3em; }
    .tabs { overflow-x: auto; flex-wrap: nowrap; }
    .tabs a { white-space: nowrap; }
}

/* 分享图弹窗 */
.share-modal-box {
    max-width: 640px;
    width: 95%;
    padding: 20px 16px;
}
.share-modal-box canvas {
    display: block;
    margin: 0 auto;
}
.share-modal-box .btn {
    min-width: 120px;
}

@media (max-width: 480px) {
    .card-grid { grid-template-columns: 1fr; gap: 12px; }
    .form-inline { flex-direction: column; }
    th, td { padding: 8px 10px; font-size: .85em; }
    .share-modal-box {
        padding: 16px 10px;
    }
}
