/**
 * 店铺管理页面样式
 * 设计原则：低耦合，与HTML/JS分离
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
}

/* 头部导航 */
.header {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    color: white;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.back-btn:hover {
    background: rgba(255,255,255,0.3);
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.header-right {
    display: flex;
    gap: 12px;
}

/* 主要内容区 */
.main-content {
    width: 100%;
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 24px;
    box-sizing: border-box;
}

/* 平台选择卡片 */
.platform-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.platform-card {
    min-width: 0;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.platform-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.platform-card.active {
    border-color: #3B82F6;
}

.platform-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.platform-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.platform-logo {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    overflow: hidden;
}

/* 品牌 Logo 通用样式（与 .platform-logo 配合） */
.brand-logo {
    width: 100%;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    letter-spacing: -0.02em;
    color: #fff;
    border-radius: 8px;
}
.brand-logo svg { width: 60%; height: 60%; }

.brand-logo--shopee {
    background: #ee4d2d;        /* Shopee 橙红 */
    font-size: 26px;
    font-style: italic;
}
.brand-logo--qoo10 {
    background: #d63031;        /* Qoo10 红 */
    font-size: 16px;
    letter-spacing: 0;
}
.brand-logo--tiktok {
    background: #000;           /* TikTok 黑 */
}
.brand-logo--lazada {
    background: #0f146d;        /* Lazada 蓝 */
    font-size: 20px;
}

/* 旧的彩色背景类不再使用，置为透明（防止覆盖 brand-logo） */
.platform-logo.shopee,
.platform-logo.qoo10,
.platform-logo.tiktok,
.platform-logo.lazada {
    background: transparent;
}

.platform-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.platform-stats {
    display: flex;
    gap: 24px;
}

.platform-stat {
    text-align: center;
}

.platform-stat .value {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.platform-stat .label {
    font-size: 12px;
    color: #999;
}

/* 店铺列表 */
.shops-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.section-header {
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.shops-list {
    padding: 0;
}

.shop-item {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.2s;
}

.shop-item:last-child {
    border-bottom: none;
}

.shop-item:hover {
    background: #fafafa;
}

.shop-logo {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 16px;
    flex-shrink: 0;
}

.shop-info {
    flex: 1;
    min-width: 0;
    padding-right: 16px;
}

.shop-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.shop-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    font-size: 13px;
    line-height: 20px;
    color: #6b7280;
}

.shop-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 20px;
    white-space: nowrap;
}

.shop-platform { min-width: 64px; }
.shop-region { min-width: 96px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.shop-region-code { font-weight: 500; }
.shop-region-name { color: #4b5563; }
.shop-expiry { font-variant-numeric: tabular-nums; }

.shop-status {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 76px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #9ca3af;
}

.status-dot.active {
    background: #52c41a;
}

.status-dot.expired {
    background: #ff4d4f;
}

.status-dot.pending {
    background: #faad14;
}

.shop-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* 自动发布开关 */
.shop-auto-publish {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 16px;
    flex-shrink: 0;
}

.auto-publish-label {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
}

/* Toggle开关 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    border-radius: 22px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #52c41a;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* 空状态 */
.empty-state {
    padding: 60px 24px;
    text-align: center;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
}

.empty-desc {
    font-size: 14px;
    color: #999;
    margin-bottom: 24px;
}

/* 按钮 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: #3B82F6;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd6;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #ff4d4f;
    color: white;
}

.btn-danger:hover {
    background: #ff7875;
}

.btn-success {
    background: #52c41a;
    color: white;
}

.btn-success:hover {
    background: #389e0d;
}

.btn-outline {
    background: white;
    border: 1px solid #d9d9d9;
    color: #333;
}

.btn-outline:hover {
    border-color: #3B82F6;
    color: #3B82F6;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    overflow: hidden;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 授权平台选择 */
.auth-platforms {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.auth-platform {
    min-width: 0;
    overflow-wrap: anywhere;
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-platform:hover {
    border-color: #3B82F6;
}

.auth-platform.selected {
    border-color: #3B82F6;
    background: #f0f5ff;
}

.auth-platform .icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.auth-platform .name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #3B82F6;
}

/* 加载状态 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f0;
    border-top-color: #3B82F6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 授权表单样式 */
.auth-form {
    padding: 0;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form .form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.auth-form .form-group label .required {
    color: #ff4d4f;
    margin-left: 2px;
}

.auth-form .form-group input,
.auth-form .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-form .form-group input:focus,
.auth-form .form-group textarea:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.auth-form .form-group input::placeholder,
.auth-form .form-group textarea::placeholder {
    color: #bbb;
}

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

/* 表单提示 */
.form-tip {
    background: #f6f8fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #666;
}

.form-tip p {
    margin: 0 0 10px 0;
    font-weight: 500;
    color: #333;
}

.form-tip ol {
    margin: 0;
    padding-left: 20px;
}

.form-tip li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.form-tip a {
    color: #3B82F6;
    text-decoration: none;
}

.form-tip a:hover {
    text-decoration: underline;
}

/* 表单操作按钮 */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
    margin-top: 10px;
}

/* 授权平台状态标签 */
.auth-platform .status {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
    padding: 3px 8px;
    background: #f5f5f5;
    border-radius: 10px;
    display: inline-block;
}

.auth-platform .status.available {
    color: #52c41a;
    background: #f6ffed;
}

.auth-platform.available {
    border-color: #52c41a;
    background: #f6ffed;
}

.auth-platform.available:hover {
    border-color: #389e0d;
}

/* TikTok平台logo */
.platform-logo.tiktok {
    background: #000000;
    color: white;
}

/* 配送组样式 */
.shop-delivery-groups {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.delivery-label {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
}

.delivery-tag {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    background: #e8f4fd;
    color: #1890ff;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
    cursor: default;
    transition: background 0.2s;
}

.delivery-tag-name {
    line-height: 16px;
}

.delivery-rule-status {
    color: #666;
    font-size: 11px;
    line-height: 15px;
}

.delivery-free-only-tip {
    flex-basis: 100%;
    color: #d46b08;
    background: #fff7e6;
    border: 1px solid #ffd591;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
    padding: 6px 10px;
}

.delivery-tag:hover {
    background: #bae7ff;
}

.delivery-loading {
    font-size: 12px;
    color: #bbb;
    font-style: italic;
}

.delivery-empty {
    font-size: 12px;
    color: #ccc;
}

/* 配送组编辑按钮 */
.delivery-edit-btn {
    cursor: pointer;
    font-size: 14px;
    opacity: 0.5;
    transition: opacity 0.2s;
    margin-left: 4px;
    display: inline-flex;
    align-items: center;
}

.delivery-edit-btn:hover {
    opacity: 1;
}

/* 刷新按钮加载中旋转动画 */
.delivery-edit-btn.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.delivery-edit-btn.is-loading .icon-svg {
    animation: spin 0.8s linear infinite;
}

/* 有别名的配送组标签 */
.delivery-tag.has-alias {
    background: #f0f5ff;
    border: 1px solid #adc6ff;
    color: #2f54eb;
}

/* 默认配送组标记 */
.delivery-tag.is-default {
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    color: #389e0d;
}

.delivery-default-badge {
    display: inline-block;
    background: #52c41a;
    color: white;
    font-size: 10px;
    padding: 0 4px;
    border-radius: 3px;
    margin-left: 4px;
    line-height: 16px;
    vertical-align: middle;
}

/* 默认配送组设置弹窗样式 */
.default-dg-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.default-dg-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.default-dg-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    display: flex;
    align-items: center;
    gap: 6px;
}

.default-dg-icon {
    font-size: 16px;
    color: #666;
    display: inline-flex;
    align-items: center;
}

.default-dg-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    background: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.default-dg-select:focus {
    border-color: #3f51b5;
    box-shadow: 0 0 0 2px rgba(63, 81, 181, 0.1);
}

/* 分隔线 */
.default-dg-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #bbb;
    font-size: 12px;
    margin: 4px 0;
}

.default-dg-divider::before,
.default-dg-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e8e8e8;
}

.default-dg-divider span {
    white-space: nowrap;
}

/* 别名编辑弹窗样式 */
.delivery-alias-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.delivery-alias-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
}

.delivery-alias-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.delivery-alias-no {
    font-size: 12px;
    color: #999;
    background: #e8e8e8;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.delivery-alias-name {
    font-size: 13px;
    color: #555;
}

.delivery-alias-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.delivery-alias-input:focus {
    border-color: #3f51b5;
    box-shadow: 0 0 0 2px rgba(63, 81, 181, 0.1);
}

.delivery-alias-input::placeholder {
    color: #bbb;
}

/* 响应式 */
@media (max-width: 768px) {
    .main-content {
        padding: 0 16px;
    }

    .platform-cards {
        grid-template-columns: 1fr;
    }

    .auth-platforms {
        grid-template-columns: 1fr;
    }

    .shop-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .shop-auto-publish {
        margin-right: 0;
    }

    .shop-info {
        width: 100%;
        padding-right: 0;
    }

    .shop-meta {
        gap: 6px 12px;
    }

    .shop-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
