/* ============================================
   AI制造车间调度系统 - 布局框架
   左侧独立对话框 + 右侧主视图
   ============================================ */

/* === Reset === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

/* === 顶部导航栏 === */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 var(--space-lg);
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  box-shadow: var(--shadow-sm);
}

.top-bar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.top-bar__logo {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  border-radius: var(--radius-sm);
}

.top-bar__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.top-bar__center {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.top-bar__clock {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.top-bar__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.top-bar__status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.top-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* === 主布局 === */
.app-layout {
  display: flex;
  height: calc(100vh - 56px);
}

/* === 左侧独立对话框 === */
.insertion-panel {
  width: 42%;
  max-width: 520px;
  flex-shrink: 0;
  border-right: 1px solid var(--divider);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.insertion-panel > div {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* === 右侧主视图 === */
.main-stage {
  flex: 1;
  overflow-y: hidden;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* === 区域通用 === */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* 甘特图区域固定高度，不撑大 */
#ganttSection {
  flex: 0 0 auto;
  height: 320px;
  display: flex;
  flex-direction: column;
}

#ganttSection .section-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#ganttSection .gantt-wrapper {
  flex: 1;
  min-height: 0;
}

.section-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-md) var(--space-sm);
}

.section-card__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.section-card__body {
  padding: 0 var(--space-md) var(--space-md);
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* === 双列布局 === */
.tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  flex: 1;
  min-height: 0;
}

.tables-grid > .section-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tables-grid > .section-card .section-card__body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* === 按钮基础 === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}

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

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn--ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--primary-muted);
}

.btn--icon {
  padding: 6px;
  width: 32px;
  height: 32px;
}

.btn--sm {
  padding: 5px 10px;
  font-size: var(--text-xs);
}

/* === 响应式 === */
@media (max-width: 1279px) {
  .insertion-panel {
    position: fixed;
    left: -400px;
    top: 56px;
    bottom: 0;
    z-index: 90;
    transition: left var(--transition-slow);
    box-shadow: var(--shadow-lg);
  }

  .insertion-panel.is-open {
    left: 0;
  }

  .panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: 56px;
    background: rgba(0,0,0,0.15);
    z-index: 89;
  }

  .panel-overlay.is-visible {
    display: block;
  }
}

@media (max-width: 767px) {
  .tables-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .insertion-panel {
    width: 100%;
    left: -100%;
  }

  .top-bar__center {
    display: none;
  }
}
