/* ============================================
   损坏配件公示系统 - 全局样式
   移动端优先，一比一复刻设计稿
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-bg: #eff6ff;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --text-main: #1f2937;
    --text-sub: #6b7280;
    --text-light: #9ca3af;
    --bg-page: #f3f4f6;
    --bg-card: #ffffff;
    --border: #e5e7eb;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-page);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* 页面容器 - 模拟手机宽度居中 */
.app-container {
    max-width: 420px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-page);
    position: relative;
    padding-bottom: 70px;
}

/* ========== 顶部标题栏 ========== */
.header {
    background: var(--bg-card);
    padding: 16px 16px 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title .back-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-page);
    font-size: 18px;
    cursor: pointer;
}

.header-title .admin-entry {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 400;
    cursor: pointer;
}

/* ========== 搜索框 ========== */
.search-box {
    margin: 12px 0;
    position: relative;
}

.search-box input {
    width: 100%;
    height: 40px;
    border: none;
    background: var(--bg-page);
    border-radius: 20px;
    padding: 0 16px 0 40px;
    font-size: 14px;
    color: var(--text-main);
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-light);
}

.search-box::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
}

/* ========== 分类标签 ========== */
.category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tab {
    flex-shrink: 0;
    padding: 7px 18px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-sub);
    background: var(--bg-card);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    border: none;
}

.category-tab.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

/* ========== 配件卡片列表 ========== */
.parts-list {
    padding: 8px 16px 16px;
}

.part-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s;
}

.part-card:active {
    transform: scale(0.98);
}

.part-card-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: var(--bg-page);
    position: relative;
}

.part-card-image .video-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.part-card-body {
    padding: 12px 14px 14px;
}

.part-card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.part-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.part-card-meta {
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 10px;
}

.part-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.part-card-price {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
}

.part-card-date {
    font-size: 12px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========== 状态标签 ========== */
.status-tag {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 500;
    flex-shrink: 0;
}

.status-normal {
    background: var(--primary-bg);
    color: var(--primary);
}

.status-pending {
    background: var(--warning-bg);
    color: var(--warning);
}

.status-replaced {
    background: var(--success-bg);
    color: var(--success);
}

/* ========== 底部导航 ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 6px;
    color: var(--text-light);
    font-size: 11px;
    cursor: pointer;
    gap: 2px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item svg {
    width: 22px;
    height: 22px;
}

/* ========== 详情页 ========== */
.detail-video {
    width: 100%;
    background: #000;
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.detail-video video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.detail-video .video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b, #334155);
    color: rgba(255,255,255,0.5);
    font-size: 13px;
}

.detail-video .play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.detail-video .play-btn::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 18px solid var(--primary);
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    margin-left: 4px;
}

.detail-info {
    background: var(--bg-card);
    margin: 12px;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.detail-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text-main);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.detail-field label {
    display: block;
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.detail-field .value {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 500;
}

.detail-field .value.price {
    color: var(--primary);
    font-size: 16px;
    font-weight: 700;
}

.detail-section {
    background: var(--bg-card);
    margin: 0 12px 12px;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.detail-section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.detail-section-title .icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-section-content {
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.8;
}

.detail-replace-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.detail-replace-row:last-child {
    border-bottom: none;
}

.detail-replace-row .label {
    color: var(--text-light);
}

.detail-replace-row .val {
    color: var(--text-main);
    font-weight: 500;
}

/* ========== 后台管理样式 ========== */
.admin-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    padding: 20px 16px;
}

.admin-header h1 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.admin-header p {
    font-size: 12px;
    opacity: 0.8;
}

.stats-row {
    display: flex;
    gap: 10px;
    padding: 16px;
}

.stat-card {
    flex: 1;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px 8px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card .num {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 2px;
}

.stat-card .num.blue { color: var(--primary); }
.stat-card .num.green { color: var(--success); }
.stat-card .num.orange { color: var(--warning); }

.stat-card .label {
    font-size: 11px;
    color: var(--text-sub);
}

.admin-list {
    padding: 0 16px 16px;
}

.admin-part-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 12px;
}

.admin-part-card img {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-page);
}

.admin-part-info {
    flex: 1;
    min-width: 0;
}

.admin-part-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.admin-part-meta {
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 4px;
}

.admin-part-price {
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
}

.admin-part-date {
    font-size: 11px;
    color: var(--text-light);
}

.admin-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.admin-btn {
    flex: 1;
    padding: 6px 0;
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
    cursor: pointer;
    border: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.admin-btn.edit {
    background: var(--primary-bg);
    color: var(--primary);
}

.admin-btn.qr {
    background: #f0fdf4;
    color: #16a34a;
}

.admin-btn.delete {
    background: #fef2f2;
    color: var(--danger);
}

/* 悬浮添加按钮 */
.fab-add {
    position: fixed;
    bottom: 86px;
    right: calc(50% - 200px);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
    cursor: pointer;
    z-index: 99;
    border: none;
}

@media (max-width: 440px) {
    .fab-add {
        right: 20px;
    }
}

/* ========== 表单样式 ========== */
.form-container {
    padding: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-main);
    background: var(--bg-card);
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

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

.form-group .hint {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
}

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

.form-row .form-group {
    flex: 1;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.btn-secondary {
    width: 100%;
    padding: 12px;
    background: var(--bg-page);
    color: var(--text-sub);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 8px;
}

/* ========== 登录页 ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-card h2 {
    text-align: center;
    font-size: 20px;
    margin-bottom: 6px;
    color: var(--text-main);
}

.login-card .subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 24px;
}

.login-error {
    background: #fef2f2;
    color: var(--danger);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

/* ========== 二维码弹窗 ========== */
.qr-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.qr-modal {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    max-width: 300px;
    width: 100%;
}

.qr-modal h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-main);
}

.qr-modal img {
    width: 200px;
    height: 200px;
    margin: 0 auto 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.qr-modal p {
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 16px;
    word-break: break-all;
}

.qr-modal .close-btn {
    width: 100%;
    padding: 10px;
    background: var(--bg-page);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-sub);
    cursor: pointer;
}

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

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

/* ========== 物业动态页 ========== */
.news-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.news-card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

.news-card-content {
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.7;
    margin-bottom: 8px;
}

.news-card-date {
    font-size: 11px;
    color: var(--text-light);
}

/* ========== 工具类 ========== */
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
