/* =========================================================
   电脑装机管理系统 · 店主后台 (web/admin/admin.css)
   基于 v4 单文件全量样式 + 登录页/客户意向徽标/分享管理新增样式
   ========================================================= */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "微软雅黑", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
}

/* ==================== 登录层 ==================== */
#loginPage {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #1F4E79 0%, #2e6da4 55%, #4a90c2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
}
.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 400px;
    padding: 40px 36px 32px;
    text-align: center;
}
.login-card h1 {
    font-size: 24px;
    color: #1F4E79;
    margin-bottom: 6px;
}
.login-sub {
    color: #888;
    font-size: 14px;
    margin-bottom: 28px;
}
.login-field {
    text-align: left;
    margin-bottom: 18px;
}
.login-field label {
    display: block;
    font-size: 13px;
    font-weight: bold;
    color: #333;
    margin-bottom: 6px;
}
.login-field input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-field input:focus {
    border-color: #1F4E79;
    box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.12);
}
.login-error {
    color: #ff4d4f;
    font-size: 13px;
    min-height: 18px;
    margin-bottom: 10px;
    text-align: center;
}
.login-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    letter-spacing: 4px;
    border-radius: 6px;
}

/* 登录验证码 */
.captcha-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.captcha-question {
    flex: 0 0 auto;
    min-width: 96px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    color: #1F4E79;
    background: #f0f4f8;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    padding: 8px 6px;
    letter-spacing: 1px;
}
.captcha-row input {
    flex: 1 1 auto;
}
.captcha-row .btn {
    flex: 0 0 auto;
}

/* ==================== 主页面 ==================== */
.main-page { display: block; }

/* 管理员标识 */
.admin-badge {
    background: #ff4d4f;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 10px;
}

/* 导航栏 */
.navbar {
    background: #1F4E79;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.navbar h1 { font-size: 18px; }

.navbar .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 导航栏标题：可点击返回首页 */
.navbar-brand {
    cursor: pointer;
    user-select: none;
    transition: opacity 0.15s;
}
.navbar-brand:hover { opacity: 0.8; }
.navbar-brand:active { opacity: 0.65; }

.nav-username {
    color: #cfe0f2;
    font-size: 13px;
    border: 1px solid rgba(255,255,255,0.35);
    padding: 3px 10px;
    border-radius: 14px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 内容区（占满屏宽） */
.content {
    padding: 20px;
}

/* 卡片 */
.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.card-title {
    font-size: 16px;
    font-weight: bold;
    color: #1F4E79;
}

/* 按钮 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.btn-primary { background: #1F4E79; color: white; }
.btn-success { background: #70AD47; color: white; }
.btn-danger { background: #ff4d4f; color: white; }
.btn-secondary { background: #6c757d; color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.stat-card .number {
    font-size: 28px;
    font-weight: bold;
    color: #1F4E79;
    line-height: 1;
}

.stat-card .number.profit { color: #70AD47; }
.stat-card .label { font-size: 13px; color: #666; margin-top: 0; }

/* 订单列表 */
.order-list {
    display: block;
    overflow-x: auto;
}

.order-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: pointer;
}

.order-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.order-title {
    font-size: 16px;
    font-weight: bold;
    color: #1F4E79;
}

.order-date {
    font-size: 13px;
    color: #999;
}

.order-info {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.info-item {
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.info-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.info-value {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.info-value.profit { color: #70AD47; }
.info-value.cost { color: #ff4d4f; }

.profit-rate {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
}

.profit-rate.high { background: #f6ffed; color: #52c41a; }
.profit-rate.medium { background: #fffbe6; color: #faad14; }
.profit-rate.low { background: #fff2f0; color: #ff4d4f; }

.order-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    white-space: nowrap;
}

/* 历史订单表格 */
.order-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: white;
}

.order-table th {
    background: #f0f4f8;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
}

.order-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.order-table tbody tr:hover { background: #f8fbff; }

.order-table .order-no { color: #999; font-size: 12px; }
.order-table .amount { font-weight: bold; color: #1F4E79; }
.order-table .cost { color: #ff4d4f; }
.order-table .profit { color: #70AD47; font-weight: bold; }

.order-table .btn { padding: 4px 8px; font-size: 12px; }

/* 订单状态筛选栏 */
.order-filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    background: #fafbfc;
}
.order-filter-chip {
    border: 1px solid #d9dde3;
    background: #fff;
    color: #555;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.order-filter-chip span { font-size: 11px; color: #999; }
.order-filter-chip.active {
    background: #1F4E79;
    border-color: #1F4E79;
    color: #fff;
}
.order-filter-chip.active span { color: #cfe0f2; }
.filter-hint { font-size: 12px; color: #aaa; margin-left: auto; }

/* 搜索框（订单列表） */
.order-keyword {
    border: 1px solid #d9dde3;
    border-radius: 18px;
    padding: 5px 12px;
    font-size: 13px;
    width: 180px;
    outline: none;
}
.order-keyword:focus { border-color: #1F4E79; }

/* 订单状态徽章 */
.order-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.6;
    white-space: nowrap;
}
.order-status.done { background: #e8f6ee; color: #1e9e5a; border: 1px solid #bfe6cf; }
.order-status.draft { background: #f3f4f6; color: #8a9099; border: 1px solid #e2e4e8; }
.order-status.revoked { background: #fde8e8; color: #c0392b; border: 1px solid #f5b7b1; font-weight: 600; }
.order-table tr.row-draft td { background: #fdfefe; }
.order-table tr.row-draft td.amount { color: #9aa0a8; }
/* 已作废订单行：整行淡红底 + 金额标红，便于快速识别 */
.order-table tr.row-revoked td { background: #fff5f5; }
.order-table tr.row-revoked td.amount { color: #c0392b; }

/* 客户意向徽标 / 来源徽标 */
.source-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.6;
    margin-left: 6px;
    vertical-align: 1px;
    white-space: nowrap;
}
.source-badge.customer { background: #fff1e0; color: #e67e22; border: 1px solid #f5c79a; }
.source-badge.owner { background: #eef2f6; color: #7d8a99; border: 1px solid #dde4ea; }

/* 客户意向引导横幅（编辑页 / 详情页） */
.intent-banner {
    background: #fff7e6;
    border: 1px solid #ffd591;
    color: #ad6800;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 订单详情状态横幅 */
.detail-status-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 14px;
    flex-wrap: wrap;
}
.detail-status-banner.done { background: #e8f6ee; border: 1px solid #bfe6cf; color: #1e6b42; }
.detail-status-banner.draft { background: #f3f4f6; border: 1px solid #e2e4e8; color: #6b7280; }
.detail-status-banner .banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-status-banner .banner-actions .btn { padding: 5px 12px; font-size: 13px; }

.detail-status-tip { font-size: 12px; color: #999; margin: 4px 0 12px; }

/* 表单 */
.form-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

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

.form-group label {
    font-size: 13px;
    color: #333;
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* 详情页只读表单 */
.readonly-grid input { background: #f5f6f8; color: #333; }

/* 配置表格 */
.config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.config-table th {
    background: #1F4E79;
    color: white;
    padding: 12px 8px;
    text-align: center;
    font-weight: bold;
}

.config-table td {
    padding: 10px 8px;
    border: 1px solid #e0e0e0;
    text-align: center;
}

.config-table tr:nth-child(even) {
    background: #f8f9fa;
}

.config-table input,
.config-table select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.config-table input[readonly] {
    background: #f5f5f5;
}

.price-input {
    width: 72px !important;
    text-align: right;
}

/* 配置单单价/成本/小计/利润 数字单元格与输入框紧凑化 */
.config-table td.amount,
.config-table input.price-input,
.config-table input.config-subtotal,
.config-table input.config-profit { font-size: 12px; }
.config-table td.price-cell { padding: 6px 4px; }
.config-table input[readonly] { font-size: 12px; }
/* 小计/利润 readonly 输入框收紧（默认撑满整列，改为 80px 内右对齐） */
.config-table input[id^="config-subtotal-"],
.config-table input[id^="config-profit-"] {
    width: 80px !important;
    text-align: right;
}

.total-row {
    background: #70AD47 !important;
    color: white;
    font-weight: bold;
}

.total-row td {
    border-color: #5a8f3c;
    font-size: 16px;
}

/* 推荐电源瓦数面板 */
.power-panel {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    background: #f5f8fc;
    border: 1px solid #e2e9f2;
    font-size: 13px;
    color: #33475b;
    line-height: 1.7;
}
.power-panel:empty { display: none; }
.power-panel .power-line + .power-line { margin-top: 6px; }
.power-panel .power-line strong { color: #1F4E79; }
.power-panel .power-line.warn { color: #ff4d4f; font-weight: bold; }
.power-panel .power-line.ok { color: #52a340; font-weight: bold; }

/* 上传区域 */
.upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #1F4E79;
}

.upload-area input { display: none; }

.upload-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.upload-preview .thumb-wrap {
    position: relative;
}
.upload-preview .thumb-wrap img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
    display: block;
}
.thumb-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: #ff4d4f;
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    cursor: pointer;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
}

.modal-header {
    background: #1F4E79;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    max-height: calc(90vh - 60px);
    overflow-y: auto;
}

.share-link-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    margin: 15px 0;
}

.share-link-box input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* 权限控制 */
.admin-only { display: none; }
.admin .admin-only { display: table-cell; }
.admin .admin-only-block { display: block; }
.admin-only-block { display: none; }
.admin .stats-grid.admin-only-block { display: grid; }

/* 配件库管理 */
.parts-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.parts-toolbar select,
.parts-toolbar input[type="text"] {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.parts-toolbar input[type="text"] { flex: 1; min-width: 220px; }

.parts-hint { font-size: 12px; color: #999; }

.parts-table td { vertical-align: middle; }

.parts-table .alias-input,
.parts-table .spec-input {
    width: 100%;
    padding: 5px 6px;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    font-size: 12px;
}

.parts-table .spec-input { min-width: 180px; }

.parts-table .alias-input:focus,
.parts-table .spec-input:focus {
    border-color: #1F4E79;
    outline: none;
    background: #f0f7ff;
}

.parts-pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.parts-pager .page-info { font-size: 13px; color: #666; }

.param-section-title {
    font-weight: bold;
    margin: 18px 0 12px;
    color: #1F4E79;
    border-left: 3px solid #1F4E79;
    padding-left: 8px;
    font-size: 15px;
}

.param-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.param-grid .form-group label { font-size: 13px; margin-bottom: 4px; }

.modal-content.modal-lg { max-width: 720px; }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state .icon {
    font-size: 64px;
    margin-bottom: 20px;
}

/* 分享链接管理 */
.share-manage-list { font-size: 13px; }
.share-manage-list .share-link-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #eee;
    border-radius: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    background: #fbfcfd;
}
.share-manage-list .share-link-main { min-width: 0; flex: 1 1 320px; }
.share-manage-list .share-link-url {
    color: #1F4E79;
    word-break: break-all;
    font-size: 13px;
    background: #fff;
    padding: 6px 8px;
    border: 1px solid #e6e9ee;
    border-radius: 4px;
}
.share-manage-list .share-link-meta { font-size: 12px; color: #888; margin-top: 4px; }
.share-link-status {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
}
.share-link-status.active { background: #e8f6ee; color: #1e9e5a; }
.share-link-status.revoked { background: #f3f4f6; color: #9aa0a8; }
.share-empty { color: #999; text-align: center; padding: 24px 0; }

/* Toast */
#toastBox {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: rgba(20, 30, 50, 0.92);
    color: #fff;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    animation: toastIn 0.25s ease;
    max-width: 80vw;
}
.toast.toast-error { background: rgba(200, 40, 40, 0.95); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 响应式 */
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .order-info { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .config-table { font-size: 12px; }
    .config-table th, .config-table td { padding: 8px 4px; }
    .navbar { flex-direction: column; gap: 10px; }
    .order-keyword { width: 100%; }
}

/* ========== 打印样式（保留 v4，工作台打印时干净排版） ========== */
@media print {
    body { background: #fff !important; }
    .navbar, .btn, .upload-area, .modal, .share-link-box { display: none !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd; }
}
