/* ============================================================
   新品运营管理平台 - 样式表
   适配钉钉H5微应用 + 桌面端
   ============================================================ */

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

:root {
    --primary: #1677ff;
    --primary-hover: #4096ff;
    --success: #52c41a;
    --warning: #faad14;
    --danger: #ff4d4f;
    --bg: #f5f5f5;
    --white: #ffffff;
    --border: #e8e8e8;
    --text: #333333;
    --text-secondary: #888888;
    --text-light: #bbbbbb;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 8px;
    --header-height: 52px;
    --accent-yellow: #fff3cd;
    --accent-green: #d4edda;
    --accent-red: #f8d7da;
    --accent-blue: #d1ecf1;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================================
   头部导航
   ============================================================ */

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.user-name {
    font-weight: 500;
}

.user-role {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    background: rgba(255,255,255,0.25);
}

.user-role.role-总监 { background: #ff4d4f; }
.user-role.role-经理 { background: #faad14; color: #333; }
.user-role.role-员工 { background: rgba(255,255,255,0.3); }

/* ============================================================
   数据看板
   ============================================================ */

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    padding: 12px 16px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}

.stat-value.negative { color: var(--danger); }
.stat-value.positive { color: var(--success); }

/* ============================================================
   筛选栏
   ============================================================ */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.filter-select,
.filter-date {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--white);
    color: var(--text);
    outline: none;
}

.filter-select:focus,
.filter-date:focus {
    border-color: var(--primary);
}

.filter-sep {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ============================================================
   按钮
   ============================================================ */

.btn {
    padding: 7px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--white);
    color: var(--primary);
    border: 1px solid var(--primary);
}

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

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   数据表格
   ============================================================ */

.table-container {
    margin: 12px 16px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 1200px;
}

.data-table thead {
    background: #fafafa;
    position: sticky;
    top: 0;
}

.data-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 12px;
}

.data-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: #f0f7ff;
}

.data-table .text-right {
    text-align: right;
}

.data-table .text-center {
    text-align: center;
}

.loading-cell {
    text-align: center;
    color: var(--text-secondary);
    padding: 32px !important;
}

.no-data {
    text-align: center;
    color: var(--text-light);
    padding: 40px !important;
}

.highlight-cell {
    font-weight: 600;
    color: var(--primary);
}

.warn-cell {
    color: var(--warning);
}

.bad-cell {
    color: var(--danger);
}

.good-cell {
    color: var(--success);
}

/* ============================================================
   模态弹窗
   ============================================================ */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

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

.modal-header h2 {
    font-size: 17px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #f0f0f0;
}

.modal-body {
    padding: 16px 20px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--primary);
}

.form-static {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
}

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

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

textarea.form-input {
    resize: vertical;
    min-height: 60px;
}

/* ============================================================
   Toast提示
   ============================================================ */

.toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    border-radius: 20px;
    font-size: 14px;
    z-index: 300;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* ============================================================
   响应式
   ============================================================ */

@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 8px 10px;
    }

    .stat-card {
        padding: 10px 8px;
    }

    .stat-value {
        font-size: 18px;
    }

    .filter-bar {
        padding: 8px 10px;
        gap: 6px;
    }

    .table-container {
        margin: 8px 10px;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        margin-top: auto;
    }

    .modal-overlay {
        align-items: flex-end;
    }
}

@media (max-width: 400px) {
    .dashboard {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   同步状态
   ============================================================ */

.sync-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.sync-badge.success {
    background: var(--accent-green);
    color: #155724;
}

.sync-badge.error {
    background: var(--accent-red);
    color: #721c24;
}

/* 管理器可编辑标记 */
.manager-edit {
    background: var(--accent-yellow);
    padding: 1px 4px;
    border-radius: 3px;
}

/* ============================================================
   分页
   ============================================================ */

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin: 0 16px 16px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    gap: 10px;
}

.pagination-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pagination-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.page-size-label {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-size-select {
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    background: var(--white);
    color: var(--text);
    outline: none;
    cursor: pointer;
}

.page-size-select:focus {
    border-color: var(--primary);
}

.page-num {
    font-size: 13px;
    color: var(--text);
    min-width: 80px;
    text-align: center;
    display: inline-block;
}

@media (max-width: 768px) {
    .pagination-bar {
        margin: 0 10px 10px;
        padding: 8px 10px;
        flex-direction: column;
        align-items: stretch;
    }
    
    .pagination-left,
    .pagination-right {
        justify-content: center;
    }
}
