/* ==============================================
   이력 모아보기 스타일
   ============================================== */

/* 이력 컨테이너 */
.history-view-container {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.history-view-container.active {
  display: flex;
}

/* 이력 헤더 */
.history-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 2px solid #e0e0e0;
}

.history-view-title {
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.history-view-count {
  font-size: 14px;
  color: #6b7280;
  font-weight: 500;
}

/* 이력 필터 영역 */
.history-filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.history-filter-bar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #374151;
  font-weight: 500;
}

.history-filter-bar select,
.history-filter-bar input[type="date"] {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

.history-filter-bar select:focus,
.history-filter-bar input[type="date"]:focus {
  outline: none;
  border-color: #0D47A1;
}

/* 이력 목록 */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 날짜 구분선 */
.history-date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px 0;
  font-size: 14px;
  font-weight: 700;
  color: #0D47A1;
}

.history-date-divider:first-child {
  margin-top: 0;
}

.history-date-divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, #0D47A1, transparent);
}

/* 개별 이력 아이템 */
.history-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 16px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.history-item:hover {
  border-color: #0D47A1;
  box-shadow: 0 2px 8px rgba(13, 71, 161, 0.12);
  transform: translateX(4px);
}

/* 이력 타입 영역 */
.history-type-area {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.history-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

/* 이력 유형별 색상 */
.history-type-badge.error,
.history-type-badge.hardware_failure,
.history-type-badge.software_bug,
.history-type-badge.damage {
  background: #dc2626;
}

.history-type-badge.inbound {
  background: #059669;
}

.history-type-badge.outbound {
  background: #2563eb;
}

.history-type-badge.clamp {
  background: #7c3aed;
}

.history-type-badge.calibration {
  background: #0891b2;
}

.history-type-badge.repair {
  background: #d97706;
}

.history-type-badge.inspection {
  background: #4f46e5;
}

.history-type-badge.option_change {
  background: #be185d;
}

.history-type-badge.regular_maintenance {
  background: #65a30d;
}

.history-type-badge.default {
  background: #6b7280;
}

/* 이력 내용 영역 */
.history-content-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.history-equipment-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-equipment-model {
  font-size: 15px;
  font-weight: 700;
  color: #1f2937;
}

.history-equipment-serial {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

.history-equipment-category {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.history-equipment-category.cmm {
  background: #0D47A1;
}

.history-equipment-category.vmm {
  background: #037c62;
}

.history-equipment-category.form {
  background: #8B4513;
}

.history-equipment-category.others {
  background: #6c757d;
}

.history-desc {
  font-size: 14px;
  color: #374151;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: #9ca3af;
}

.history-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-meta-item svg {
  width: 14px;
  height: 14px;
}

/* 빈 상태 */
.history-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #9ca3af;
  text-align: center;
}

.history-empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.history-empty-state h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
  color: #6b7280;
}

.history-empty-state p {
  margin: 0;
  font-size: 14px;
}

/* 로딩 상태 */
.history-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #6b7280;
  font-size: 15px;
}

/* 더보기 버튼 */
.history-load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  margin-top: 16px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-load-more:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

/* 페이지네이션 */
.history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
  padding: 12px;
  flex-wrap: wrap;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled):not(.active) {
  border-color: #0D47A1;
  color: #0D47A1;
  background: #f0f5ff;
}

.pagination-btn.active {
  background: #0D47A1;
  border-color: #0D47A1;
  color: #fff;
}

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

.pagination-prev,
.pagination-next {
  padding: 0 14px;
  font-weight: 600;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  color: #9ca3af;
  font-size: 14px;
}

/* 반응형 */
@media (max-width: 768px) {
  .history-item {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .history-type-area {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .history-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .history-filter-bar label {
    width: 100%;
  }

  .history-filter-bar select,
  .history-filter-bar input[type="date"] {
    flex: 1;
  }

  .history-view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* 보기 모드 버튼 확장 (4열 그리드) */
.view-filter-buttons.expanded {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .view-filter-buttons.expanded {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .view-filter-buttons.expanded {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
