/* styles.css - Styles for bulk email sender */

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

:root {
  --primary-color: #4472c4;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --light-bg: #f8f9fa;
  --dark-text: #333;
  --border-color: #dee2e6;
  --hover-bg: #e9ecef;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: var(--dark-text);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* 头部样式 */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.status-indicator {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  font-size: 14px;
}

.status-indicator.connected {
  background: rgba(40, 167, 69, 0.9);
}

/* 标签页 */
.tabs {
  display: flex;
  background: var(--light-bg);
  border-bottom: 2px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.3s;
  border-bottom: 3px solid transparent;
}

.tab-btn:hover {
  background: white;
}

.tab-btn.active {
  background: white;
  border-bottom-color: var(--primary-color);
  color: var(--primary-color);
}

.tab-content {
  display: none;
  padding: 30px;
}

.tab-content.active {
  display: block;
}

/* 卡片样式 */
.card {
  background: white;
}

.card h2 {
  margin-bottom: 24px;
  color: var(--primary-color);
  font-size: 24px;
}

/* 表单样式 */
.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--dark-text);
}

.required {
  color: var(--danger-color);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
  font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-group input[type="file"] {
  padding: 8px 0;
}

.form-group small {
  display: block;
  margin-top: 6px;
  color: var(--secondary-color);
  font-size: 13px;
}

.file-list {
  margin-top: 10px;
  padding: 10px;
  background: var(--light-bg);
  border-radius: 6px;
  display: none;
}

.file-list.has-files {
  display: block;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  margin: 4px 0;
  background: white;
  border-radius: 4px;
  font-size: 14px;
}

.file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-size {
  margin-left: 10px;
  color: var(--secondary-color);
  font-size: 12px;
}

.file-item-remove {
  margin-left: 10px;
  cursor: pointer;
  color: var(--danger-color);
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.file-item-remove:hover {
  background: var(--danger-color);
  color: white;
}

/* 按钮样式 */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: #365a9e;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(68, 114, 196, 0.3);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #5a6268;
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #218838;
}

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

.btn-danger:hover:not(:disabled) {
  background: #c82333;
}

.form-actions {
  display: flex;
  gap: 16px;
}

/* 进度显示 */
.progress-section {
  margin-top: 32px;
  padding: 24px;
  background: var(--light-bg);
  border-radius: 8px;
}

.progress-section h3 {
  margin-bottom: 20px;
  color: var(--primary-color);
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-item {
  background: white;
  padding: 16px;
  border-radius: 8px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 13px;
  color: var(--secondary-color);
  margin-bottom: 8px;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 600;
  color: var(--primary-color);
}

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

.stat-value.error {
  color: var(--danger-color);
}

.progress-bar-container {
  position: relative;
  width: 100%;
  height: 40px;
  background: white;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--info-color));
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 16px;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 600;
  color: var(--dark-text);
  z-index: 1;
}

.current-recipient {
  padding: 12px;
  background: white;
  border-radius: 8px;
  font-size: 14px;
  color: var(--secondary-color);
}

/* 报告样式 */
.report-section {
  margin-top: 32px;
  padding: 24px;
  background: linear-gradient(135deg, #d4fc79 0%, #96e6a1 100%);
  border-radius: 8px;
}

.report-section h3 {
  margin-bottom: 20px;
  font-size: 24px;
}

.report-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.report-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

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

.report-label {
  font-weight: 500;
}

.report-value {
  font-weight: 600;
  font-size: 18px;
}

.report-actions {
  display: flex;
  gap: 16px;
}

/* 筛选区域 */
.filter-section {
  padding: 20px;
  background: var(--light-bg);
  border-radius: 8px;
  margin-bottom: 24px;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  flex-direction: column;
}

.filter-group label {
  font-size: 13px;
  margin-bottom: 6px;
  font-weight: 500;
}

.filter-group input,
.filter-group select {
  padding: 10px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
}

.filter-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* 分页设置 */
.pagination-settings {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pagination-settings label {
  font-weight: 500;
}

.pagination-settings select {
  padding: 8px 12px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
}

.record-count {
  margin-left: auto;
  color: var(--secondary-color);
  font-size: 14px;
}

/* 表格样式 */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.data-table thead {
  background: var(--primary-color);
  color: white;
}

.data-table th,
.data-table td {
  padding: 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  font-weight: 600;
  white-space: nowrap;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 25px;
}

.data-table th.sortable:hover {
  background: #3a5fa4;
}

.sort-icon {
  position: absolute;
  right: 8px;
  opacity: 0.5;
  font-size: 12px;
}

.data-table th.sortable.sort-asc .sort-icon::before {
  content: '▲';
  opacity: 1;
}

.data-table th.sortable.sort-desc .sort-icon::before {
  content: '▼';
  opacity: 1;
}

.data-table th.sortable.sort-asc .sort-icon,
.data-table th.sortable.sort-desc .sort-icon {
  opacity: 1;
}

.data-table tbody tr:hover {
  background: var(--hover-bg);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  display: inline-block;
}

.status-completed {
  background: #d4edda;
  color: #155724;
}

.status-running {
  background: #d1ecf1;
  color: #0c5460;
}

.status-cancelled {
  background: #fff3cd;
  color: #856404;
}

.status-failed {
  background: #f8d7da;
  color: #721c24;
}

.action-btn {
  padding: 6px 12px;
  margin: 0 4px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  transform: translateY(-1px);
}

.btn-view {
  background: var(--info-color);
  color: white;
}

.btn-export {
  background: var(--success-color);
  color: white;
}

.btn-delete {
  background: var(--danger-color);
  color: white;
}

.btn-delete:hover {
  background: #c82333;
}

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

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
}

.page-btn {
  padding: 8px 12px;
  border: 2px solid var(--border-color);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  min-width: 40px;
}

.page-btn:hover:not(:disabled) {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.page-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

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

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

.modal-content {
  background: white;
  margin: 5% auto;
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.close {
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  color: var(--secondary-color);
}

.close:hover {
  color: var(--danger-color);
}

.detail-section {
  margin-bottom: 24px;
}

.detail-section h3 {
  margin-bottom: 12px;
  color: var(--primary-color);
}

.detail-item {
  padding: 8px 0;
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

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

.detail-label {
  font-weight: 500;
  min-width: 120px;
  color: var(--secondary-color);
}

.detail-value {
  flex: 1;
  color: var(--dark-text);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .container {
    margin: 0;
    border-radius: 0;
  }

  .header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .header h1 {
    font-size: 22px;
  }

  .tab-content {
    padding: 16px;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .filter-actions,
  .report-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px;
  }

  .modal-content {
    width: 95%;
    margin: 10% auto;
    padding: 20px;
  }
}

/* 动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeIn 0.5s ease;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--light-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--secondary-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}
