/* 实验室页面 - 三栏布局 */

.lab {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-cream-white);
  padding-top: var(--safe-top);
}

/* 顶部 header */
.lab__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: white;
  border-bottom: 1px solid var(--color-blue-10);
  flex-shrink: 0;
}

.lab__back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--color-blue-10);
  color: var(--color-deep-blue);
}

.lab__title {
  font-size: var(--fs-h2);
  font-weight: 600;
  color: var(--color-deep-blue);
}

.lab__actions {
  display: flex;
  gap: var(--space-sm);
}

.lab__icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-blue-10);
  color: var(--color-deep-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast) var(--ease-out);
}

.lab__icon-btn:active {
  background: var(--color-blue-30);
}

.lab__icon-btn--active {
  background: var(--color-orange-red);
  color: white;
}

/* 主体三栏 */
.lab__main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr; /* mobile: 单列 */
  gap: 0;
  overflow: hidden;
}

/* 移动端 Tab 切换 */
.lab__mobile-tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--color-blue-10);
}

.lab__mobile-tab {
  flex: 1;
  padding: var(--space-md);
  text-align: center;
  font-size: var(--fs-small);
  color: var(--color-silver-gray);
  border-bottom: 3px solid transparent;
  transition: all var(--duration-fast) var(--ease-out);
}

.lab__mobile-tab--active {
  color: var(--color-orange-red);
  border-bottom-color: var(--color-orange-red);
  font-weight: 600;
}

/* 三栏通用 */
.lab__col {
  background: white;
  display: none; /* mobile 默认隐藏，靠 tabs 切换 */
  flex-direction: column;
  overflow: hidden;
}

.lab__col--active {
  display: flex;
}

/* 左栏：任务清单 */
.tasks {
  padding: var(--space-md);
  overflow-y: auto;
  flex: 1;
}

.tasks__title {
  font-size: var(--fs-h2);
  font-weight: 600;
  color: var(--color-deep-blue);
  margin-bottom: var(--space-md);
}

.tasks__progress {
  background: var(--color-orange-10);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.tasks__progress-text {
  font-size: var(--fs-small);
  color: var(--color-deep-blue);
  margin-bottom: var(--space-xs);
  display: flex;
  justify-content: space-between;
}

.tasks__progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-orange-30);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.tasks__progress-fill {
  height: 100%;
  background: var(--color-orange-red);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out);
}

.tasks__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tasks__item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: white;
  border: 1px solid var(--color-blue-10);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.tasks__item:active {
  transform: scale(0.99);
}

.tasks__item--checked {
  background: var(--color-blue-10);
  opacity: 0.7;
}

.tasks__checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-silver-gray);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  background: white;
  transition: all var(--duration-fast) var(--ease-out);
}

.tasks__item--checked .tasks__checkbox {
  background: var(--color-orange-red);
  border-color: var(--color-orange-red);
}

.tasks__checkbox-icon {
  color: white;
  font-size: 14px;
  font-weight: bold;
  display: none;
}

.tasks__item--checked .tasks__checkbox-icon {
  display: block;
}

.tasks__item-content {
  flex: 1;
  min-width: 0;
}

.tasks__item-title {
  font-size: var(--fs-body);
  color: var(--color-deep-blue);
  line-height: 1.5;
}

.tasks__item--checked .tasks__item-title {
  text-decoration: line-through;
  color: var(--color-silver-gray);
}

.tasks__empty {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-silver-gray);
  font-size: var(--fs-small);
}

/* 中栏：对话 */
.chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-cream-white);
}

.chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

.chat__msg {
  margin-bottom: var(--space-md);
  display: flex;
  gap: var(--space-sm);
}

.chat__msg--user {
  flex-direction: row-reverse;
}

.chat__avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-blue-10);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat__msg--user .chat__avatar {
  background: var(--color-orange-10);
}

.chat__bubble {
  max-width: 75%;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: white;
  color: var(--color-deep-blue);
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
  word-wrap: break-word;
}

.chat__msg--user .chat__bubble {
  background: var(--color-orange-red);
  color: white;
}

.chat__msg--thinking .chat__bubble {
  background: var(--color-blue-10);
  color: var(--color-silver-gray);
  font-style: italic;
}

.chat__msg--error .chat__bubble {
  background: #FFE5DD;
  color: var(--color-orange-red);
}

.chat__input-area {
  background: white;
  border-top: 1px solid var(--color-blue-10);
  padding: var(--space-md);
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

.chat__textarea {
  flex: 1;
  border: 1px solid var(--color-blue-10);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font: inherit;
  font-size: var(--fs-body);
  resize: none;
  min-height: 44px;
  max-height: 120px;
  font-family: var(--font-zh);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.chat__textarea:focus {
  border-color: var(--color-orange-red);
}

.chat__send-btn,
.chat__voice-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-orange-red);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--ease-out);
}

.chat__send-btn:active,
.chat__voice-btn:active {
  transform: scale(0.95);
}

.chat__send-btn:disabled {
  background: var(--color-silver-gray);
}

.chat__voice-btn {
  background: var(--color-deep-blue);
}

/* 右栏：预览 */
.preview {
  background: var(--color-cream-white);
  display: flex;
  flex-direction: column;
}

.preview__header {
  padding: var(--space-md);
  background: white;
  border-bottom: 1px solid var(--color-blue-10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.preview__title {
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--color-deep-blue);
}

.preview__url {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--color-silver-gray);
  background: var(--color-blue-10);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview__frame {
  flex: 1;
  border: none;
  background: white;
}

/* 代码视图（默认隐藏） */
.lab__code-panel {
  display: none;
  background: #1E1E1E;
  color: #D4D4D4;
}

.lab__code-panel--visible {
  display: block;
}

.code-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.code-view__tabs {
  display: flex;
  background: #252526;
  border-bottom: 1px solid #333;
}

.code-view__tab {
  padding: var(--space-sm) var(--space-md);
  color: #969696;
  font-size: var(--fs-tiny);
  font-family: var(--font-mono);
  border-right: 1px solid #333;
  cursor: pointer;
}

.code-view__tab--active {
  color: white;
  background: #1E1E1E;
}

.code-view__editor {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  padding: var(--space-md);
  overflow: auto;
  white-space: pre;
  line-height: 1.5;
}

/* 响应式：平板及以上三栏并排 */
@media (min-width: 768px) {
  .lab__mobile-tabs {
    display: none;
  }

  .lab__main {
    grid-template-columns: 260px 1fr 1fr;
  }

  .lab__col {
    display: flex !important;
    border-right: 1px solid var(--color-blue-10);
  }

  .lab__col:last-child {
    border-right: none;
  }

  /* 代码视图作为第 4 列 */
  .lab__code-panel {
    width: 400px;
    border-left: 1px solid #333;
  }

  .lab__code-panel--visible + .lab__main {
    grid-template-columns: 260px 1fr 1fr 400px;
  }
}

@media (min-width: 1280px) {
  .lab__main {
    grid-template-columns: 300px 1fr 1fr;
  }
}

/* 保存指示器 */
.save-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: var(--fs-tiny);
  font-weight: 500;
  background: var(--color-blue-10);
  color: var(--color-deep-blue);
  transition: all var(--duration-base) var(--ease-out);
}

.save-indicator--pending {
  background: var(--color-blue-10);
  color: var(--color-silver-gray);
}

.save-indicator--saving {
  background: var(--color-orange-10);
  color: var(--color-orange-red);
  animation: save-pulse 1s ease-in-out infinite;
}

.save-indicator--saved {
  background: rgba(76, 175, 80, 0.15);
  color: #2e7d32;
}

.save-indicator--warning {
  background: rgba(255, 152, 0, 0.15);
  color: #e65100;
}

.save-indicator--error {
  background: rgba(244, 67, 54, 0.15);
  color: #c62828;
}

.save-indicator--fade {
  opacity: 0.5;
}

@keyframes save-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* 部署状态浮层 */
.deploy-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 42, 74, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 9999;
  color: white;
}

.deploy-overlay.active {
  display: flex;
}

.deploy-overlay__content {
  text-align: center;
  max-width: 400px;
  padding: var(--space-xl);
}

.deploy-overlay__icon {
  font-size: 80px;
  margin-bottom: var(--space-lg);
  animation: deploy-bounce 1s ease-in-out infinite;
}

.deploy-overlay__title {
  font-size: var(--fs-h1);
  margin-bottom: var(--space-md);
  color: white;
}

.deploy-overlay__desc {
  font-size: var(--fs-body);
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.deploy-overlay__progress {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.deploy-overlay__progress-bar {
  height: 100%;
  background: var(--color-orange-red);
  width: 0%;
  border-radius: var(--radius-full);
  transition: width 0.5s var(--ease-out);
}

.deploy-overlay__url {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  background: rgba(255, 255, 255, 0.1);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  margin-top: var(--space-md);
  word-break: break-all;
  color: var(--color-orange-30);
}

.deploy-overlay__close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 烟花动画 */
.fireworks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.firework {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: firework-burst 1.5s var(--ease-out) forwards;
}

@keyframes deploy-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

@keyframes firework-burst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx, 100px), var(--dy, -100px)) scale(0);
    opacity: 0;
  }
}
