/* ========== Messages ========== */
/* ========== Message List Page ========== */
.msg-layout {
  display: flex;
  min-height: 100vh;
  background: #f5f5f5;
}

/* ===== Content ===== */
.msg-content {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

/* Breadcrumb */
.msg-breadcrumb {
  font-size: 13px;
  color: #999;
  margin-bottom: 20px;
}
.msg-breadcrumb a {
  color: #999;
  text-decoration: none;
  transition: color 0.2s;
}
.msg-breadcrumb a:hover { color: #e2383e; }
.msg-breadcrumb span { margin: 0 6px; color: #ccc; }
.msg-breadcrumb .current { color: #1a1a1a; }

/* Header */
.msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.msg-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
}
.msg-header-actions {
  display: flex;
  gap: 8px;
}
.msg-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #666;
}
.msg-header-btn:hover {
  color: #e2383e;
  border-color: #e2383e;
}
.msg-header-btn.primary {
  background: #e2383e;
  border-color: #e2383e;
  color: #fff;
}
.msg-header-btn.primary:hover {
  background: #c62d32;
}

/* Stats */
.msg-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.msg-stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.msg-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.msg-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.msg-stat-icon svg { width: 22px; height: 22px; fill: #fff; }
.msg-stat-icon.all { background: linear-gradient(135deg, #e2383e, #ff6b6b); }
.msg-stat-icon.order { background: linear-gradient(135deg, #1890ff, #40a9ff); }
.msg-stat-icon.system { background: linear-gradient(135deg, #722ed1, #9254de); }
.msg-stat-icon.audit { background: linear-gradient(135deg, #52c41a, #73d13d); }
.msg-stat-icon.promo { background: linear-gradient(135deg, #fa8c16, #ffa940); }
.msg-stat-icon.invitation { background: linear-gradient(135deg, #13c2c2, #36cfc9); }
.msg-stat-icon.sourcing { background: linear-gradient(135deg, #389e0d, #52c41a); }
.msg-stat-icon.payment { background: linear-gradient(135deg, #eb2f96, #f759ab); }
.msg-stat-info {}
.msg-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.2;
}
.msg-stat-label {
  font-size: 13px;
  color: #999;
  margin-top: 2px;
}

/* Tabs */
.msg-tabs {
  display: flex;
  background: #fff;
  border-radius: 10px 10px 0 0;
  border-bottom: 1px solid #f0f0f0;
  padding: 0 8px;
}
.msg-tab {
  background: none;
  border: none;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  padding: 14px 18px;
  position: relative;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.msg-tab:hover { color: #333; }
.msg-tab.active { color: #e2383e; font-weight: 600; }
.msg-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 18px;
  right: 18px;
  height: 2px;
  background: #e2383e;
  border-radius: 1px;
}
.msg-tab-count {
  font-size: 11px;
  background: #e2383e;
  color: #fff;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}
.msg-tab-count.zero {
  background: #d9d9d9;
}

/* Filter bar */
.msg-filter {
  background: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #f0f0f0;
  flex-wrap: wrap;
}
.msg-filter-label {
  font-size: 13px;
  color: #999;
  flex-shrink: 0;
}
.msg-filter-select,
.msg-filter-input {
  padding: 7px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  color: #333;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.msg-filter-select:focus,
.msg-filter-input:focus {
  border-color: #e2383e;
  box-shadow: 0 0 0 2px rgba(226,56,62,0.1);
}
.msg-filter-select { min-width: 120px; }
.msg-filter-input { width: 240px; }
.msg-filter-btn {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #666;
}
.msg-filter-btn:hover { color: #e2383e; border-color: #e2383e; }
.msg-filter-btn.primary {
  background: #e2383e;
  border-color: #e2383e;
  color: #fff;
}
.msg-filter-btn.primary:hover { background: #c62d32; }

/* Batch bar */
.msg-batch {
  background: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f0f0f0;
}
.msg-batch-left {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: #666;
}
.msg-batch-left label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.msg-batch-left input[type="checkbox"] {
  accent-color: #e2383e;
  width: 15px;
  height: 15px;
}
.msg-batch-actions {
  display: flex;
  gap: 8px;
}
.msg-batch-btn {
  background: none;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}
.msg-batch-btn:hover {
  color: #e2383e;
  border-color: #e2383e;
}
.msg-batch-count {
  font-size: 13px;
  color: #999;
}
.msg-batch-count b { color: #e2383e; }

/* ===== Message List ===== */
.msg-list {
  background: #fff;
}

.msg-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid #fafafa;
  background-color: #ffffff;
  transition: background 0.2s;
  cursor: pointer;
  position: relative;
}
.msg-item:hover { background: #fafafa; }
.msg-item.unread { background: #fff8f8; }
.msg-item.unread:hover { background: #fff1f0; }

.msg-item-check {
  padding-top: 8px;
  flex-shrink: 0;
}
.msg-item-check input {
  accent-color: #e2383e;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.msg-item-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.msg-item-icon svg { width: 20px; height: 20px; fill: #fff; }
.msg-item-icon.order-icon { background: linear-gradient(135deg, #e2383e, #ff6b6b); }
.msg-item-icon.audit-icon { background: linear-gradient(135deg, #52c41a, #73d13d); }
.msg-item-icon.system-icon { background: linear-gradient(135deg, #1890ff, #40a9ff); }
.msg-item-icon.promo-icon { background: linear-gradient(135deg, #fa8c16, #ffa940); }
.msg-item-icon.payment-icon { background: linear-gradient(135deg, #722ed1, #9254de); }
.msg-item-icon.invitation-icon { background: linear-gradient(135deg, #13c2c2, #36cfc9); }
.msg-item-icon.sourcing-icon { background: linear-gradient(135deg, #389e0d, #52c41a); }

.msg-item-body {
  flex: 1;
  min-width: 0;
}
.msg-item-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.msg-item-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-item-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 500;
  flex-shrink: 0;
}
.msg-item-tag.order { background: #fff1f0; color: #e2383e; }
.msg-item-tag.audit { background: #f6ffed; color: #52c41a; }
.msg-item-tag.system { background: #e6f7ff; color: #1890ff; }
.msg-item-tag.promo { background: #fff7e6; color: #fa8c16; }
.msg-item-tag.payment { background: #f9f0ff; color: #722ed1; }

.msg-item-desc {
  font-size: 13px;
  color: #888;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}
.msg-item-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: #bbb;
}
.msg-item-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.msg-item-meta-item svg { width: 13px; height: 13px; fill: #ccc; }

.msg-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
  padding-top: 2px;
}
.msg-item-time {
  font-size: 12px;
  color: #bbb;
  white-space: nowrap;
}
.msg-item-dot {
  width: 8px;
  height: 8px;
  background: #e2383e;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s;
}
.msg-item-dot:hover { transform: scale(1.3); }
.msg-item-actions {
  display: flex;
  gap: 8px;
}
.msg-item-action {
  background: none;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}
.msg-item-action:hover {
  color: #e2383e;
  border-color: #e2383e;
}
.msg-item-action.danger:hover {
  color: #ff4d4f;
  border-color: #ff4d4f;
}

/* ===== Empty State ===== */
.msg-empty {
  text-align: center;
  padding: 80px 20px;
}
.msg-empty-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: #f5f5f5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-empty-icon svg { width: 40px; height: 40px; fill: #d9d9d9; }
.msg-empty-title {
  font-size: 16px;
  color: #999;
  margin-bottom: 8px;
}
.msg-empty-desc {
  font-size: 13px;
  color: #ccc;
}

/* ===== Pagination ===== */
.msg-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 24px 20px;
  background: #fff;
}
.msg-page-btn {
  min-width: 32px;
  height: 32px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  transition: all 0.2s;
}
.msg-page-btn:hover { color: #e2383e; border-color: #e2383e; }
.msg-page-btn.active {
  background: #e2383e;
  border-color: #e2383e;
  color: #fff;
}
.msg-page-btn.disabled {
  color: #d9d9d9;
  cursor: not-allowed;
}
.msg-page-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* ===== Detail Modal ===== */
.msg-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: msg-fadein 0.2s;
}
.msg-modal-overlay.show { display: flex; }

@keyframes msg-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

.msg-modal {
  background: #fff;
  border-radius: 12px;
  width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: msg-slideup 0.3s ease;
  overflow: hidden;
}

@keyframes msg-slideup {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.msg-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #f0f0f0;
}
.msg-modal-header h3 {
  font-size: 17px;
  font-weight: 600;
  color: #1a1a1a;
}
.msg-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}
.msg-modal-close:hover { background: #f5f5f5; }
.msg-modal-close svg { width: 20px; height: 20px; fill: #999; }

.msg-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.msg-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
}
.msg-modal-meta-item {
  font-size: 13px;
  color: #999;
}
.msg-modal-meta-item b {
  color: #666;
  font-weight: 500;
}

.msg-modal-content {
  font-size: 14px;
  color: #333;
  line-height: 1.8;
}
.msg-modal-content p { margin-bottom: 12px; }
.msg-modal-content .highlight {
  background: #fff7e6;
  border-left: 3px solid #fa8c16;
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  margin: 12px 0;
  font-size: 13px;
  color: #d48806;
}
.msg-modal-content .info-box {
  background: #e6f7ff;
  border-left: 3px solid #1890ff;
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  margin: 12px 0;
  font-size: 13px;
  color: #0958d9;
}
.msg-modal-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}
.msg-modal-content table th,
.msg-modal-content table td {
  padding: 8px 12px;
  border: 1px solid #f0f0f0;
  font-size: 13px;
  text-align: left;
}
.msg-modal-content table th {
  background: #fafafa;
  color: #666;
  font-weight: 500;
}

.msg-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.msg-modal-btn {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #666;
}
.msg-modal-btn:hover {
  color: #e2383e;
  border-color: #e2383e;
}
.msg-modal-btn.primary {
  background: #e2383e;
  border-color: #e2383e;
  color: #fff;
}
.msg-modal-btn.primary:hover { background: #c62d32; }

/* ===== Confirm Modal ===== */
.msg-confirm-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
}
.msg-confirm-overlay.show { display: flex; }
.msg-confirm-box {
  background: #fff;
  border-radius: 10px;
  padding: 28px 32px;
  width: 380px;
  text-align: center;
  animation: msg-slideup 0.25s ease;
}
.msg-confirm-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  background: #fff1f0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-confirm-icon svg { width: 24px; height: 24px; fill: #e2383e; }
.msg-confirm-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
}
.msg-confirm-desc {
  font-size: 13px;
  color: #999;
  margin-bottom: 24px;
}
.msg-confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.msg-confirm-btn {
  padding: 8px 24px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #666;
}
.msg-confirm-btn:hover { color: #e2383e; border-color: #e2383e; }
.msg-confirm-btn.danger {
  background: #e2383e;
  border-color: #e2383e;
  color: #fff;
}
.msg-confirm-btn.danger:hover { background: #c62d32; }

/* Responsive */
@media (max-width: 1200px) {
  .msg-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .msg-content { padding: 16px; }
  .msg-stats { grid-template-columns: repeat(2, 1fr); }
  .msg-filter { flex-direction: column; align-items: flex-start; }
  .msg-filter-input { width: 100%; }
  .msg-modal { width: 95%; }
}
