/* ═══════════════════════════════════════════════════════════
   To B OPS Web Admin — 管理后台样式
   品牌色: #2C1810 (深棕) / #8B4513 (主色) / #D4A574 (金色)
   ═══════════════════════════════════════════════════════════ */

/* === Reset & Variables === */
:root {
    --sidebar-w: 220px;
    --topbar-h: 0px;
    --color-bg: #F8F5F1;
    --color-card: #FFFFFF;
    --color-border: #E8E0D8;
    --color-text: #2C1810;
    --color-text-2: #8B8682;
    --color-primary: #8B4513;
    --color-accent: #D4A574;
    --color-success: #2E7D32;
    --color-warning: #F57F17;
    --color-danger: #C62828;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(44,24,16,.06);
}

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

body.admin-body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    display: flex;
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--color-border); }
th { font-weight: 600; font-size: 12px; color: var(--color-text-2); text-transform: uppercase; letter-spacing: .5px; background: #FAF8F5; }

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: linear-gradient(180deg, #2C1810 0%, #3D2218 100%);
    color: #FFF;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-icon { font-size: 22px; }
.brand-text { font-size: 16px; font-weight: 700; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-footer { padding: 12px 0; border-top: 1px solid rgba(255,255,255,.1); }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 20px; color: rgba(255,255,255,.65);
    font-size: 14px; transition: all .15s; border-left: 3px solid transparent;
}
.nav-item:hover { color: #FFF; background: rgba(255,255,255,.06); }
.nav-item.active { color: var(--color-accent); background: rgba(212,165,116,.12); border-left-color: var(--color-accent); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

/* === Main Content === */
.main-content {
    flex: 1; margin-left: var(--sidebar-w);
    padding: 32px; min-height: 100vh;
}

/* === Page Header === */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--color-text); }

/* === Cards === */
.card {
    background: var(--color-card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--color-border);
}
.card-title { font-size: 16px; font-weight: 600; }

/* === Stats Grid === */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px; margin-bottom: 28px;
}
.stat-card {
    background: var(--color-card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px 24px;
}
.stat-label { font-size: 12px; color: var(--color-text-2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--color-text); }
.stat-value.accent { color: var(--color-primary); }
.stat-value.success { color: var(--color-success); }
.stat-value.warning { color: var(--color-warning); }
.stat-value.danger { color: var(--color-danger); }

/* === Status Badge === */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 500;
}
.badge-pending { background: #FFF3E0; color: #E65100; }
.badge-paid { background: #E3F2FD; color: #1565C0; }
.badge-producing { background: #F3E5F5; color: #7B1FA2; }
.badge-shipped { background: #E8F5E9; color: #2E7D32; }
.badge-completed { background: #E8F5E9; color: #1B5E20; }
.badge-cancelled { background: #FFEBEE; color: #B71C1C; }
.badge-refunding { background: #FFF8E1; color: #F57F17; }
.badge-default { background: #F5F5F5; color: #616161; }

/* === Table === */
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 600px; }
tr:hover { background: #FAF8F5; }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px; border-radius: 6px; font-size: 13px; font-weight: 500;
    border: none; cursor: pointer; transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--color-primary); color: #FFF; }
.btn-outline { background: none; border: 1px solid var(--color-border); color: var(--color-text); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: var(--color-danger); color: #FFF; }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--color-text-2); }
.form-input {
    width: 100%; padding: 9px 14px; border: 1px solid var(--color-border);
    border-radius: 6px; font-size: 14px; color: var(--color-text);
    background: #FAFAFA; transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--color-accent); background: #FFF; }

/* === Login Page === */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, #2C1810 0%, #5C3A28 50%, #D4A574 100%);
}
.login-card {
    width: 380px; background: #FFF; border-radius: 12px;
    padding: 44px 40px; box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.login-subtitle { font-size: 13px; color: var(--color-text-2); text-align: center; margin-bottom: 32px; }

/* === Empty State === */
.empty { text-align: center; padding: 60px 20px; color: var(--color-text-2); }
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }

/* === Alert === */
.alert { padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-info { background: #E3F2FD; color: #1565C0; }
.alert-warning { background: #FFF3E0; color: #E65100; }
.alert-success { background: #E8F5E9; color: #2E7D32; }

/* === Utility === */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.mt-sm { margin-top: 12px; }
.mt-md { margin-top: 20px; }
.mb-sm { margin-bottom: 12px; }
.mb-md { margin-bottom: 20px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--color-text-2); }
.text-right { text-align: right; }
.mono { font-family: "SF Mono", "Menlo", monospace; font-size: 12px; }

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar .brand-text, .sidebar .nav-label { display: none; }
    .main-content { margin-left: 60px; padding: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* === Product Form Layout === */
.product-form { display: grid; grid-template-columns: 280px 1fr; gap: 28px; }
.product-form-left { display: flex; flex-direction: column; gap: 20px; }
.product-form-right { display: flex; flex-direction: column; gap: 20px; }

/* === Image Upload Zone === */
.upload-zone {
    border: 2px dashed var(--color-border); border-radius: var(--radius);
    padding: 28px; text-align: center; cursor: pointer; transition: border-color .15s;
    background: #FAFAFA; min-height: 180px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.upload-zone:hover { border-color: var(--color-accent); background: #FFF; }
.upload-zone.has-image { padding: 0; border-style: solid; min-height: auto; }
.upload-zone.has-image img { width: 100%; height: 220px; object-fit: cover; border-radius: 6px; display: block; }
.upload-zone .upload-hint { color: var(--color-text-2); font-size: 13px; margin-top: 8px; }
.upload-zone .upload-icon { font-size: 36px; opacity: .4; margin-bottom: 8px; }

/* === Detail Images === */
.detail-images { display: flex; flex-wrap: wrap; gap: 10px; }
.detail-img-item {
    width: 72px; height: 72px; border-radius: 6px; overflow: hidden;
    border: 1px solid var(--color-border); position: relative;
}
.detail-img-item img { width: 100%; height: 100%; object-fit: cover; }
.detail-img-item .del-btn {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; border-radius: 10px; background: rgba(0,0,0,.55);
    color: #FFF; font-size: 11px; line-height: 18px; text-align: center; cursor: pointer;
    border: none;
}
.detail-upload-btn {
    width: 72px; height: 72px; border: 2px dashed var(--color-border); border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: var(--color-text-2); cursor: pointer;
}
.detail-upload-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* === Toggle Switch === */
.toggle-switch {
    display: inline-block; position: relative; width: 40px; height: 22px;
    background: #ccc; border-radius: 11px; cursor: pointer; transition: background .2s;
    vertical-align: middle;
}
.toggle-switch.active { background: var(--color-success); }
.toggle-switch::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px; background: #FFF; border-radius: 50%;
    transition: transform .2s;
}
.toggle-switch.active::after { transform: translateX(18px); }

/* === Product Thumbnail === */
.product-thumb {
    width: 40px; height: 40px; border-radius: 6px; object-fit: cover;
    background: #F5F3F0; border: 1px solid var(--color-border);
}
.product-thumb-placeholder {
    width: 40px; height: 40px; border-radius: 6px; background: #F5F3F0;
    border: 1px solid var(--color-border); display: flex; align-items: center;
    justify-content: center; font-size: 18px; color: #ccc;
}

/* === SKU Table in Form === */
.sku-table { width: 100%; border-collapse: collapse; }
.sku-table th { font-size: 12px; padding: 8px 10px; text-align: left; }
.sku-table td { padding: 6px 10px; }
.sku-table .form-input { margin: 0; }
.sku-row-remove {
    background: none; border: none; color: #999; cursor: pointer; font-size: 18px;
    padding: 4px 8px; line-height: 1;
}
.sku-row-remove:hover { color: var(--color-danger); }

/* === Status Dot === */
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 3px; margin-right: 6px; }
.status-dot.active { background: var(--color-success); }
.status-dot.inactive { background: #ccc; }
.status-dot.draft { background: var(--color-warning); }

/* === Action Buttons in Table === */
.actions { display: flex; gap: 6px; }
.btn-ghost {
    padding: 4px 10px; font-size: 12px; border: none; background: none;
    color: var(--color-primary); cursor: pointer; border-radius: 4px;
}
.btn-ghost:hover { background: rgba(139,69,19,.08); }
.btn-ghost.danger { color: var(--color-danger); }
.btn-ghost.danger:hover { background: rgba(198,40,40,.08); }

/* === Price Display === */
.price-range { font-weight: 500; white-space: nowrap; }

/* === Section Divider === */
.form-section-title {
    font-size: 14px; font-weight: 600; color: var(--color-text);
    padding-bottom: 8px; border-bottom: 1px solid var(--color-border);
    margin-bottom: 4px;
}

/* === AI Image Modal === */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.5); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
.modal-card {
    background: #fff; border-radius: 8px; box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    max-height: 90vh; overflow-y: auto;
}
.ai-img-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px; margin-top: 8px;
}
.ai-img-card { text-align: center; }
.ai-img-card img {
    width: 100%; height: 120px; object-fit: cover; border-radius: 4px;
    border: 2px solid transparent;
}
.ai-img-card.selected img { border-color: var(--color-primary); }
/* === Product Detail Page === */
.product-detail-wrap { display: grid; grid-template-columns: 1fr 375px; gap: 24px; align-items: start; }
.product-detail-main { display: flex; flex-direction: column; gap: 20px; }
.preview-frame { width: 375px; height: 700px; border: 10px solid #333; border-radius: 32px; overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,.15); background: #fff; position: sticky; top: 16px; }
.preview-frame iframe { width: 100%; height: 100%; border: none; }
@media (max-width: 900px) { .product-detail-wrap { grid-template-columns: 1fr; } .preview-frame { position: static; width: 100%; max-width: 375px; margin: 0 auto; } }

/* AI Grid (detail page) */
.ai-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.ai-grid-item { width: 140px; text-align: center; position: relative; }
.ai-grid-item img { width: 140px; height: 140px; object-fit: cover; border-radius: 8px; cursor: pointer; }
.badge { position: absolute; top: 4px; left: 4px; font-size: 11px; padding: 2px 6px; border-radius: 4px; color: #fff; }
.badge-pending_review { background: #9e9e9e; }
.badge-approved { background: #1565c0; }
.badge-rejected { background: #c62828; }
.badge-applied { background: #2e7d32; }

/* SKU Table (detail page) */
.sku-table { width: 100%; border-collapse: collapse; }
.sku-table th, .sku-table td { padding: 8px 10px; border-bottom: 1px solid #e0ddd8; font-size: 13px; text-align: left; }
.sku-table input { width: 100%; border: 1px solid #ddd; padding: 6px 8px; border-radius: 4px; font-size: 13px; }

/* Plan Cards (AI recommend) */
.plan-card-active { border-color: #f57f17 !important; background: #fff8e1 !important; }
.plan-card:hover { border-color: #bbb; background: #fafafa; }

/* x-cloak fallback: hide Alpine elements before init (CDN-blocked safety) */
[x-cloak] { display: none !important; }
