/* ========== 全局 ========== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 12px;
    --sidebar-width: 220px;
    --sidebar-collapsed: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--gray-50); color: var(--gray-900); line-height: 1.6; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ========== 导航 ========== */
.navbar { background: #fff; border-bottom: 1px solid var(--gray-200); position: sticky; top: 0; z-index: 100; }
.navbar .container { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.navbar-brand { font-size: 22px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.navbar-brand svg { width: 28px; height: 28px; }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a { font-size: 15px; color: var(--gray-700); font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: var(--primary); }
.nav-links .btn-sm { padding: 6px 16px; border-radius: 8px; font-size: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: 10px; font-size: 15px; font-weight: 500; border: none; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ========== Hero ========== */
.hero { background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #06b6d4 100%); color: #fff; padding: 48px 0; text-align: center; }
.hero h1 { font-size: 32px; margin-bottom: 8px; }
.hero p { font-size: 16px; opacity: 0.9; }

/* ========== 搜索栏 ========== */
.search-bar { background: #fff; border-radius: var(--radius); padding: 20px; margin: -30px auto 24px; max-width: 1200px; box-shadow: var(--shadow-lg); position: relative; z-index: 10; }
.search-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.search-row input, .search-row select { flex: 1; min-width: 120px; padding: 10px 14px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 14px; background: var(--gray-50); }
.search-row input:focus, .search-row select:focus { outline: none; border-color: var(--primary); background: #fff; }
.search-row .btn { min-width: 100px; justify-content: center; }

/* ========== 标签栏 ========== */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab { padding: 8px 20px; border-radius: 20px; font-size: 14px; background: #fff; border: 1px solid var(--gray-200); cursor: pointer; transition: all 0.2s; }
.tab.active, .tab:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ========== 房源卡片 ========== */
.section-title { font-size: 22px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.property-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-bottom: 32px; }
.property-card { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform 0.2s, box-shadow 0.2s; }
.property-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.property-card .card-img { width: 100%; height: 200px; object-fit: cover; background: var(--gray-200); }
.property-card .card-body { padding: 16px; }
.property-card .card-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.property-card .card-meta { display: flex; gap: 12px; font-size: 13px; color: var(--gray-500); margin-bottom: 8px; flex-wrap: wrap; }
.property-card .card-meta span { display: flex; align-items: center; gap: 4px; }
.property-card .card-price { font-size: 20px; font-weight: 700; color: var(--danger); }
.property-card .card-price small { font-size: 13px; font-weight: 400; color: var(--gray-500); }
.property-card .card-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.tag { padding: 2px 8px; border-radius: 4px; font-size: 12px; background: var(--gray-100); color: var(--gray-500); }
.tag-rent { background: #dbeafe; color: #1e40af; }
.tag-sale { background: #fef3c7; color: #92400e; }
.tag-featured { background: #fee2e2; color: #dc2626; }

/* ========== 详情页 ========== */
.detail-page { padding: 24px 0; }
.detail-grid { display: grid; grid-template-columns: 1fr 380px; gap: 24px; }
.detail-images { border-radius: var(--radius); overflow: hidden; }
.detail-main-img { width: 100%; height: 400px; object-fit: cover; background: var(--gray-200); }
.detail-thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.detail-thumbs img { width: 80px; height: 60px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.detail-thumbs img.active { border-color: var(--primary); }
.detail-info { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.detail-info h1 { font-size: 22px; margin-bottom: 12px; }
.detail-price { font-size: 28px; font-weight: 700; color: var(--danger); margin-bottom: 16px; }
.detail-price small { font-size: 14px; color: var(--gray-500); font-weight: 400; }
.detail-attrs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.detail-attr { padding: 10px; background: var(--gray-50); border-radius: 8px; text-align: center; }
.detail-attr label { font-size: 12px; color: var(--gray-500); display: block; }
.detail-attr span { font-size: 16px; font-weight: 600; }
.detail-desc { margin: 20px 0; padding: 16px; background: var(--gray-50); border-radius: 8px; font-size: 14px; color: var(--gray-700); line-height: 1.8; }
.detail-contact { background: linear-gradient(135deg, #eff6ff, #dbeafe); border-radius: var(--radius); padding: 20px; margin-top: 20px; }
.detail-contact h3 { font-size: 16px; margin-bottom: 12px; }
.contact-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }

/* ========== 后台布局 ========== */
.admin-layout { display: flex; min-height: calc(100vh - 60px); position: relative; }

/* ===== 侧边栏 ===== */
.admin-sidebar {
    width: var(--sidebar-width); background: var(--gray-900); color: #fff;
    flex-shrink: 0; transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column; overflow: hidden;
    position: relative; z-index: 50;
}

/* 侧边栏头部 */
.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 12px; border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: 56px;
}
.sidebar-header .header-text {
    font-size: 14px; font-weight: 600; white-space: nowrap;
    overflow: hidden; transition: opacity 0.2s, width 0.2s;
}
.sidebar-toggle-btn {
    width: 36px; height: 36px; border-radius: 8px; background: rgba(255,255,255,0.1);
    border: none; color: #fff; font-size: 14px; cursor: pointer; display: flex;
    align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: rgba(255,255,255,0.2); }
.sidebar-toggle-btn .icon-collapse { display: inline; }
.sidebar-toggle-btn .icon-expand { display: none; }

/* 收起状态 */
.admin-sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.admin-sidebar.collapsed .sidebar-header .header-text {
    opacity: 0; width: 0;
}
.admin-sidebar.collapsed .sidebar-toggle-btn .icon-collapse { display: none; }
.admin-sidebar.collapsed .sidebar-toggle-btn .icon-expand { display: inline; }

/* 导航链接 */
.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px; padding: 11px 16px;
    color: var(--gray-300); font-size: 14px; transition: all 0.2s;
    white-space: nowrap; position: relative;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-nav a .nav-icon {
    width: 20px; text-align: center; font-size: 16px; flex-shrink: 0;
}
.sidebar-nav a .nav-text {
    overflow: hidden; transition: opacity 0.2s, width 0.2s;
}

/* 收起时导航样式 */
.admin-sidebar.collapsed .sidebar-nav a {
    justify-content: center; padding: 11px 0;
}
.admin-sidebar.collapsed .sidebar-nav a .nav-text {
    opacity: 0; width: 0;
}
.admin-sidebar.collapsed .sidebar-nav .sidebar-label { display: none; }

/* 收起时 hover tooltip */
.admin-sidebar.collapsed .sidebar-nav a { position: relative; }
.admin-sidebar.collapsed .sidebar-nav a::after {
    content: attr(data-tip); position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
    background: var(--gray-900); color: #fff; padding: 6px 12px; border-radius: 6px;
    font-size: 13px; white-space: nowrap; z-index: 999; margin-left: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3); opacity: 0; pointer-events: none;
    transition: opacity 0.15s;
}
.admin-sidebar.collapsed .sidebar-nav a:hover::after { opacity: 1; }

.sidebar-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 8px 16px; }

/* ===== 内容区 ===== */
.admin-content { flex: 1; padding: 24px; min-width: 0; }

.admin-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.admin-card h2 { font-size: 18px; margin-bottom: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); text-align: center; }
.stat-card .stat-num { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 14px; color: var(--gray-500); margin-top: 4px; }

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--gray-200); }
th { background: var(--gray-50); font-weight: 600; white-space: nowrap; }
tr:hover { background: var(--gray-50); }

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 14px; background: #fff;
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check { display: flex; gap: 16px; flex-wrap: wrap; }
.form-check label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }

/* ========== 提示 ========== */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ========== 分页 ========== */
.pagination { display: flex; gap: 8px; justify-content: center; margin: 32px 0; }
.pagination a, .pagination span { padding: 8px 14px; border-radius: 8px; font-size: 14px; }
.pagination a { background: #fff; border: 1px solid var(--gray-200); }
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

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

/* ========== 底部 ========== */
.footer { background: var(--gray-900); color: var(--gray-300); padding: 32px 0; text-align: center; font-size: 14px; margin-top: 40px; }

/* ========== 移动端遮罩 ========== */
.sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 150;
}
.sidebar-overlay.active { display: block; }

/* 移动端浮动按钮 */
.mobile-fab {
    display: none; position: fixed; bottom: 24px; right: 24px; z-index: 250;
    width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff;
    border: none; font-size: 22px; cursor: pointer;
    box-shadow: 0 4px 16px rgba(37,99,235,0.4);
    align-items: center; justify-content: center;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .hero h1 { font-size: 24px; }
    .search-row { flex-direction: column; }
    .search-row input, .search-row select { min-width: auto; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .property-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .property-card .card-img { height: 150px; }
    .navbar .nav-links a.hide-mobile { display: none; }

    /* 移动端侧边栏：固定定位 + 滑入滑出 */
    .admin-sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        transform: translateX(-100%); width: 260px;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
        z-index: 200;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .admin-sidebar.mobile-open { transform: translateX(0); }

    /* 移动端强制展开显示文字 */
    .admin-sidebar.collapsed { width: 260px; }
    .admin-sidebar.collapsed .sidebar-header .header-text { opacity: 1; width: auto; }
    .admin-sidebar.collapsed .sidebar-nav a { justify-content: flex-start; padding: 11px 16px; gap: 12px; }
    .admin-sidebar.collapsed .sidebar-nav a .nav-text { opacity: 1; width: auto; }
    .admin-sidebar.collapsed .sidebar-toggle-btn .icon-collapse { display: inline; }
    .admin-sidebar.collapsed .sidebar-toggle-btn .icon-expand { display: none; }

    .mobile-fab { display: flex; }
    .admin-content { padding: 16px; padding-bottom: 80px; }
    .admin-card { padding: 16px; }
    .detail-contact { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .navbar .container { padding: 0 12px; }
    .navbar-brand { font-size: 18px; }
    .nav-links { gap: 8px; }
    .btn-sm { padding: 5px 10px; font-size: 12px; }
}
@media (max-width: 480px) {
    .property-grid { grid-template-columns: 1fr; }
    .hero { padding: 32px 0; }
    .hero h1 { font-size: 20px; }
    .detail-attrs { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stats-grid { grid-template-columns: 1fr; }
}
