/**
 * 管理后台页面样式
 * 用于团队导航系统的管理界面
 */

/* ============================================
   Toast 通知系统
   ============================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 300px;
  max-width: 400px;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  border-left: 4px solid;
  backdrop-filter: blur(10px);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-icon {
  font-size: 1.5rem;
  font-weight: bold;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.2rem;
}

.toast-message {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

.toast-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toast-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toast-success {
  border-left-color: var(--success);
}

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

.toast-error {
  border-left-color: var(--error);
}

.toast-error .toast-icon {
  background: var(--error-light);
  color: var(--error);
}

.toast-warning {
  border-left-color: var(--warning);
}

.toast-warning .toast-icon {
  background: var(--warning-light);
  color: var(--warning);
}

.toast-info {
  border-left-color: var(--info);
}

.toast-info .toast-icon {
  background: var(--info-light);
  color: var(--info);
}

/* ============================================
   确认对话框
   ============================================ */
.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.confirm-overlay.show {
  opacity: 1;
}

.confirm-dialog {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border);
}

.confirm-overlay.show .confirm-dialog {
  transform: scale(1);
}

.confirm-icon {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 16px;
  color: var(--warning);
}

.confirm-message {
  font-size: 1rem;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.6;
}

.confirm-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.confirm-buttons .btn {
  min-width: 100px;
}

/* ============================================
   标签页导航
   ============================================ */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 32px;
  background: var(--bg-light);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.tab {
  padding: 12px 24px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius-md);
  font-weight: 500;
  position: relative;
}

.tab:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.tab.active {
  color: var(--primary);
  background: var(--bg-white);
  box-shadow: var(--shadow-md);
  font-weight: 600;
}

.tab-content {
  display: none;
}

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

/* ============================================
   区域标题和按钮
   ============================================ */
.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(
    135deg,
    var(--bg-light) 0%,
    rgba(99, 102, 241, 0.05) 100%
  );
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.section-title h3 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  margin: 0;
}

.section-title .title-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 2px 4px rgba(99, 102, 241, 0.2));
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
}

.section-title .title-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.section-title:hover .title-icon {
  transform: scale(1.1) rotate(5deg);
}

.section-title .btn {
  margin-left: auto;
  margin-bottom: 0;
}

/* ============================================
   按钮样式
   ============================================ */
.btn {
  padding: 12px 24px;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-hover) 100%
  );
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(0);
}

.btn-danger {
  background: linear-gradient(135deg, var(--error) 0%, #dc2626 100%);
}

.btn-danger:hover {
  box-shadow: 0 0 0 4px var(--error-light), var(--shadow-lg);
}

.btn-secondary {
  background: var(--bg-white);
  color: var(--text-primary);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-md);
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
}

.action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-buttons .btn-small {
  min-width: 70px;
}

/* ============================================
   表格样式
   ============================================ */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  margin-top: 20px;
  backdrop-filter: blur(10px);
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

th {
  background: linear-gradient(
    135deg,
    var(--bg-light) 0%,
    rgba(99, 102, 241, 0.05) 100%
  );
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: -0.01em;
  border-bottom: 2px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover {
  background: var(--bg-hover);
}

td a {
  color: var(--primary);
  text-decoration: none;
  max-width: 300px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td a:hover {
  text-decoration: underline;
}

/* ============================================
   模态框样式 - 统一现代化设计
   ============================================ */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 20px;
  overflow-y: auto;
  /* 确保模态框始终相对于视口居中 */
  box-sizing: border-box;
  /* 防止页面滚动影响定位 */
  overscroll-behavior: contain;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: 640px;
  width: 90%;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  /* 使用 margin: auto 确保在 flex 容器中垂直和水平居中 */
  margin: auto;
  /* 确保相对于视口定位，不受页面滚动影响 */
  position: relative;
  /* 防止内容超出视口 */
  flex-shrink: 0;
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(135deg, var(--bg-light) 0%, var(--bg-white) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

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

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

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-white);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
  border-color: var(--primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light), var(--shadow-md);
  transform: translateY(-1px);
}

.form-group textarea {
  resize: vertical;
  font-family: inherit;
}

.form-group input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.form-actions {
  display: none; /* 已移动到 modal-footer */
}

/* ============================================
   环境配置表单
   ============================================ */
.env-form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.env-form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.env-form-row .form-group:last-child {
  flex: 0 0 auto;
}

#projectEnvironments {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}

#projectEnvironments h3 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
}

#environmentsList > div {
  background: var(--bg-light);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

/* ============================================
   空状态样式
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  margin-top: 20px;
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 768px) {
  .section-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .section-title .btn {
    margin-left: 0;
    width: 100%;
  }

  .btn {
    width: 100%;
  }

  table {
    font-size: 0.85rem;
  }

  th,
  td {
    padding: 10px 12px;
  }

  .modal-content {
    padding: 24px;
    max-width: 95%;
  }

  .env-form-row {
    flex-direction: column;
    align-items: stretch;
  }
}
